php - MySql query: Unknown column in 'where clause' -


i have simple select statement clause on php file so:

$con=mysqli_connect("hostname", "user", "pw", "db");     if (mysqli_connect_errno($con)) {     echo "failed connect mysql: " . mysqli_connect_error(); } $gettitle = mysqli_query($con, "select title tbltitle category='" .$col."'") or die("error: ". mysqli_error($con)); 

i've changed code suggested , added quotation mark on variable i'm getting internal server error @ $gettitle line. doing wrong here? can't print error can't point out what's going on.

update: suggested, i've used var dump on $gettitle , here's message got.

object(mysqli_result)#5 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> null ["num_rows"]=> int(1) ["type"]=> int(0) }

$col should within quote, otherwise seems category=music , mysql assumes music column.

if in php, use

"select title tbltitle category='".$col."'"; 

or

"select title tbltitle category='$col'"; 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -