Fwd: Re: [PHP] Function to make a select box

From: Date: Tue, 04 Feb 2003 21:02:25 +0000
Subject: Fwd: Re: [PHP] Function to make a select box
Groups: php.general 
Request: Send a blank email to php-general+get-134333@lists.php.net to get a copy of this message
Date: Tue, 04 Feb 2003 22:02:12 +0100 To: "Leonard Burton" <lbburt0@pop.uky.edu> From: Chris Hayes <chayes@antenna.nl> Subject: Re: [PHP] Function to make a select box
Could anyone offer any suggestions? The following function prints a blank select box. $result= "select auto, '$field' from '$table' order by '$field' order by name asc";
what are these single quotes doing there? quotes in a query only go around STRINGS.
        (sorry if i sound patronizing, it is late here)
$result= mysql_query($result);
for debugging code please use $q="update members set company="\$company\", ........ $result=mysql_query($q) or
         die ('<hr>DB update failed in '.__FILE__.' line '.__LINE__.'<br>Query was:'.$q.'<br>mysql reported:'.mysql_error());
you would have gotten a meaningful mysql error message!
if ($result)
this 'if' will fail with errrors, not with empty result sets
Here is a working example that is not in a function: $result= mysql_query("select * from ledger_accounts order by name asc");
see, no quotes around the tablename here!


« previous php.general (#134333) next »