Empty query result in php

I'm having troubles with a PHP code. The problems come when I execute a SQL query with a PHP variable inside it. The result doesn't shows anything, and the field in the database is not empty. Tried out with a static id (not variable) and the query works fine.

Do you know where I'm doing it wrong?

The query code:

$consultaVideoSeleccionado1 = mysql_query("SELECT * FROM  videos WHERE  idvideo = `'.$videoSeleccionado.'`;", $conexion);
This question and answers originated from www.stackoverflow.com
Question by (5/8/2011 3:12:48 PM)

Answer

Try this:

$consultaVideoSeleccionado1 = mysql_query("SELECT * FROM  videos WHERE  idvideo = `'.$videoSeleccionado.'`;", $conexion) or die(mysql_error());

That will give you an error message.

The problem is that you use both ` and ' as escape characters as the same time.

$consultaVideoSeleccionado1 = mysql_query("SELECT * FROM  videos WHERE  idvideo = '$videoSeleccionado';", $conexion);

should work.

Often things will be more clear when you echo the query so you can see the final result.

Answer by

Find More Answers
Related Topics  php  mysql  query  phpmyadmin
Related Questions