Concatenation

How do I properly concatenate a variable in a SQL query? This is what I currently have:

$sql = 'SELECT image, name, description FROM phpbb_anime WHERE image = '.$animeimg.'';

you need to make sure that you generate single quote delimiters for your image string

when it reaches mysql, it wants to look like this –

WHERE image = 'foobar'

of course, that’s assuming image is a character column, not a numeric column

if it’s a numeric column, and $animeimg is supposed to be an integer, then you should not generate quotes into the sql

you can tell if your statement is correct by echoing $sql before you execute it

Do I need I need to put the actual SQL statement in double or single quotations?

can’t help you with that, sorry, i don’t do php

what did the echo of $sql produce?

Well I can’t particularly echo anything because I keep getting a SQL error

if you’re getting an sql error, you must’ve executed the $sql string using mysql_query() or whatever the command in php is called

could you do the echo before that, please

also, it might help if i could see the error message

$sql = "SELECT image, name, description FROM phpbb_anime WHERE image = '$animeimg'";
echo $sql;  

What is output by the echo?

When I echo that out it just outputs the code.

what happens if you submit the SELECT statement, with an appropriate value substituted for $animeimg, to mysql directly?