Re: What is wrong with this?

From: Date: Mon, 24 Feb 2003 19:22:38 +0000
Subject: Re: What is wrong with this?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136876@lists.php.net to get a copy of this message
At 02:04 24/02/03, you wrote:
Hi, yes in fact it worked...I also had the $numrows with wrong mysql command, it should be mysql_num_rows() instead of the mysql_fetch_rows(). Thx Ernest But now that this is working, i have another big problem...my $drop_down_list isn't assuming the value of the shown option...right here on the below part ******** for ($i = 0; $i < $num; $i++) {
            $aviao = mysql_result($resultaviao, $i, "aviao");
            $sk = mysql_result($resultaviao, $i, "sk");
            $drop_down_list .= "<optionvalue=$aviao>$aviao</option>";
        }
********** So he isn't getting the data from DB. He displays all records on DB available at aviao field, but he is not making the correct mysql query...
For debugging: - please show us the query if you believe it is wrong (echo $query;). - if you think something goes wrong at the mysql side, also do echo mysql_error(); after the mysql_query line, to get the mysql error. - echo $num . Also have a look at the html source to see whether it has the right options but another error than you expected.
            $drop_down_list .= "<optionvalue=$aviao>$aviao</option>";
Put some quotes around the tag value for just in case the $aviao has a space in it:
            $drop_down_list .= "<optionvalue=\"$aviao\">$aviao</option>";
FInally, why do you extract $sk when you do not use it?
Anyone knows why? ----- Original Message ----- From: "Ernest E Vogelsinger" <ernest@vogelsinger.at> To: "Miguel Brás" <molino26@netcabo.pt> Cc: <php-general@lists.php.net> Sent: Monday, February 24, 2003 9:45 AM Subject: Re: [PHP] What is wrong with this? At 10:37 24.02.2003, Miguel Brás said: --------------------[snip]-------------------- //logical request if ($nome) { $sql="aviao = '$nome' "; } if ($code) { $sql="code = '$code' "; }
       $query = "SELECT * FROM ssr WHERE";
       $query .= $sql;
--------------------[snip]-------------------- Hi, I've copied only the relevant lines of your program. The issue here is that your string concatenation results in
    SELECT * FROM ssr WHEREaviao = 'Airbus'
Note the missing space after "WHERE". Your code should better read $query = "SELECT * FROM ssr WHERE "; $query .= $sql; Have an eye on the added blank after WHERE. HTH, --
O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#136876) next »