Page 1 of 1

Variable in MySQL query

Posted: Wed Jan 28, 2009 3:13 pm
by Aki
For the code underneath, I get the message:
"Parse error: syntax error, unexpected T_VARIABLE in /customers/mangaworld.se/mangaworld.se/httpd.www/zarin/char.php on line 17"
The problem is that I included the $use variable in the MySQL query on line 17 (the code quote starts at 14), something I have never seen any other code, nor tried before. So I don't really know if it works at all, or if I just did something wrong that I can't see. If this is all wrong, how else can I do it to get whatever is in the $use variable from tempurl_user?

Code: Select all

 
    $q = mysql_query("SELECT item_name, item_pic, item_use FROM tempurl_items WHERE item_owner = '{$you}'");
    while($item = mysql_fetch_array($q)) {
        $use = $item['use']
                $q = mysql_query("SELECT {$use} FROM tempurl_user WHERE user_name = '{$you}'");
                while($user = mysql_fetch_array($q)) {
                    $output .= "<p>$user['use']</p>";
                }
    }
 

Re: Variable in MySQL query

Posted: Wed Jan 28, 2009 3:33 pm
by andyhoneycutt
you forgot a semicolon ';' on line 16.

Re: Variable in MySQL query

Posted: Wed Jan 28, 2009 7:50 pm
by siapagweh

Code: Select all

$use = $item['use'][b];[/b]
==> ; Semicolon