I'm using AJAX to call some php, which returns display data:
AJAX:
- Code: Select all
var env_url = "page.php";
$.post(env_url,{ task: "taskVar"} , function(data) {
$("#env").html(data);
});
PHP excerpt:
- Code: Select all
$my_id = 'testID';
$sql_pm_check = mysql_query("select f.id, f.thread_id, f.to_id, f.from_id, f.time_sent, f.message, f.opened, f.recipientDelete, f.senderDelete
from (
select thread_id, max(id) as maxid
from mytable WHERE (to_id = $my_id OR from_id = $my_id) group by thread_id
) as x inner join mytable as f on f.thread_id = x.thread_id and f.id = x.maxid");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0)
{
echo $num_new_pm;
}
It ends up echoing the error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in page.php on line 44
I use the same query on another page, and it works fine, so the query is sound. And if I substitute it for the simple query:
$sql_pm_check = mysql_query("select id from mytable WHERE thread_id = '233'");
...it successfully echos $num_new_pm, so the AJAX/php connection seems fine.
Is there something obvious in there that's tripping me up?
Thanks for your time and help.


