Variable in MySQL query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aki
Forum Newbie
Posts: 8
Joined: Fri Jan 09, 2009 5:38 pm

Variable in MySQL query

Post 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>";
                }
    }
 
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Variable in MySQL query

Post by andyhoneycutt »

you forgot a semicolon ';' on line 16.
siapagweh
Forum Newbie
Posts: 3
Joined: Wed Jan 28, 2009 3:19 am

Re: Variable in MySQL query

Post by siapagweh »

Code: Select all

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