Re: mysql query problem

From: Date: Thu, 26 Jul 2001 18:53:07 +0000
Subject: Re: mysql query problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10811@lists.php.net to get a copy of this message
on 7/26/01 11:11 AM, Steve Fitzgerald (sf@mnetsys.com) wrote: > ran the query in the MySQL client and got the ERROR 1054: Unknown column > '$ContactID' in 'where clause'. I know the column ContactID exists. Of course it did. It can't find the text $ContactID in the table. Try putting in a number (1,2,3, etc.) and see if it works. If it does, try echo'ing out the $ContactID and the $sql to the screen. See if $ContactID really is set and then try the output of $sql in the MySQL client. <?php echo 'ContactID is: ' , $ContactID, '<br>'; $sql="SELECT * FROM contacts WHERE ContactID='$ContactID'"; echo 'SQL query is: ' , $sql, '<br>'; $result = mysql_query($sql,$db); printf("%s\n", mysql_result($result,"FirstName")); printf("%s<br>\n", mysql_result($result,"LastName")); ?> Hope that helps. Sincerely, Paul Burney +-------------------------+---------------------------------+ | Paul Burney | P: 310.825.8365 | | Webmaster && Programmer | E: <webmaster@gseis.ucla.edu> | | UCLA -> GSE&IS -> ETU | W: <http://www.gseis.ucla.edu/> | +-------------------------+---------------------------------+

« previous php.db (#10811) next »