Re: passing variables to a sql statement

From: Date: Sun, 19 Jan 2003 03:25:13 +0000
Subject: Re: passing variables to a sql statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132157@lists.php.net to get a copy of this message
Hi, Sunday, January 19, 2003, 5:50:51 AM, you wrote: j> hi, i'm hoping someone can help me out here - im trying to pass a variable from a string j> in the href tag, however my sql breaks when i put a var in the statment. j> when i replace $foo with a number, the page works fine. can someone please tell me what im j> doing wrong? j> here is the error i get: j> Warning: Supplied argument is not a valid MySQL result resource in j> /home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php on line 11 j> here is my code: j> <?php j> $hostName="localhost"; j> $userName="xxxx"; j> $password="xxxx"; j> $database= "projects"; j> $tableName="project_descrip"; j> $descripQuery = "SELECT descrip from project_descrip where rowid=$foo"; j> mysql_connect($hostName, $userName, $password); j> $descripResult = mysql_db_query($database,$descripQuery); j> while($row = mysql_fetch_object($descripResult)){ $foo = $row->>descrip; j> echo("<font face=verdana size=1>"); j> echo("<a href='projects_descrip.php?rowid=$foobar'>" . j> "$foo</a>" . " | "); j> echo("</font>"); j> } ?>> j> thanks in advance, j> jennifer You need to put $foo in quotes like $descripQuery = "SELECT descrip from project_descrip where rowid='$foo'"; -- regards, Tom

« previous php.general (#132157) next »