Re: Probleme with MySQL queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> In fact the first return 0 results

So the problem is in your select, and if your select works when you
manually insert the value for id (iow, without using $var), the
problem has something to do with $var.

Is the data type of the ID column INT? Try the following and let us
know the output:

$var=107;
$query = mysql_query("SELECT * FROM table WHERE id={$var};") or
die(mysql_error()); // make sure to use double quotes
var_dump(mysql_error(), mysql_num_rows());

$var=mysql_real_escape_string("107");
$query = mysql_query("SELECT * FROM table WHERE id={$var};") or
die(mysql_error()); // make sure to use double quotes
var_dump(mysql_error(), mysql_num_rows());

$query = mysql_query("SELECT * FROM table WHERE id=107;") or
die(mysql_error()); // make sure to use double quotes
var_dump(mysql_error(), mysql_num_rows());

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux