![]() |
mysql query variable
Hi
I have a mysql query with a variable within it that wont work, here it is PHP Code:
The problem is that the query does not recongise the variable $album_id Can anyone help with my problem Thanks in advance |
There is a back tick at the end of album_id after WHERE did'nt show up
|
I guess you need to provide a little more information.
What language are you using (SQL on it's own will not support variables, although binding come close) Maybe provide some of the lines around your statement including where the variable is declared. |
re mysql variable
I am using php
here's the code PHP Code:
PHP Code:
|
In the function inside the while loop you use an array called $image, but you are returning an array called $images
If that doesn't fix it I'd suggest that you add some print statements displaying the values of your query and other useful variables as you are executing the code. |
Hi graemef
That was a typo sorry. Howerver the query does not work SELECT `image_id`,`album_id`,`timestamp`,`ext` FROM images WHERE `album_id` = $album_id" sql returns this message #1054 Unknown column '$album_id' in where clause Thank you for your reply |
Place $album_id between single quotes.
Code:
SELECT `image_id`,`album_id`,`timestamp`,`ext` FROM images WHERE `album_id` = '$album_id'Code:
$image_query = mysql_query("SELECT `image_id`,`album_id`,`timestamp`,`ext` FROM images WHERE `album_id` = '" . $album_id . "'"); |
| All times are GMT -5. The time now is 10:51 PM. |