> hi, i'm hoping someone can help me out here - im trying to pass a
variable
> from a string in the href tag, however my sql breaks when i put a var
in
> the statment.
> when i replace $foo with a number, the page works fine. can someone
please
> tell me what im doing wrong?
> 
> here is the error i get:
> 
> Warning: Supplied argument is not a valid MySQL result resource in
>
/home/villany2k1/www.villany2k1.com/htdocs/projects/projects_descrip.php
> on line 11

That means your query failed. Use mysql_error() to find out why. 
 
> here is my code:
> 
> <?php
> $hostName="localhost";
> $userName="xxxx";
> $password="xxxx";
> $database= "projects";
> $tableName="project_descrip";
> 
> $descripQuery = "SELECT descrip from project_descrip where
rowid=$foo";
> mysql_connect($hostName, $userName, $password);
> $descripResult = mysql_db_query($database,$descripQuery);
>    while($row = mysql_fetch_object($descripResult)){

You shouldn't be using mysql_db_query() for one, it's depreciated. Use
mysql_select_db() along with mysql_query().

If rowid is an integer, then you don't need quotes around $foo,
otherwise, if it's a string, then you do.

where rowid='$foo'

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to