I’m a total noob to PHP, but I’m pretty sure this should be functional.
Here is the code. The code that was working, mind you, earlier this afternoon.
[php]<?php
$entity=$HTTP_GET_VARS[‘entity’]; // from index.html
$uput=$HTTP_GET_VARS[‘uput’]; // from index.html
$uput= trim($uput);
if (!$uput || !$entity)
{echo 'You did not enter any text. Please go back and enter a first line, or % to retrieve all results.';
exit;
}
$entity = addslashes($entity);
$uput = addslashes($uput);
$uput = str_replace(" ", "%", $uput);
$uput = str_replace("-", "%", $uput);
$db = mysql_connect('localhost', 'xxxxx', xxxx');
if (!$db)
{
echo 'Error: could not connect to database. Please try again.';
exit;
}
mysql_select_db('xxxxxxxxxxxxxxxxxxx');
$query = "select poem.poemid as id, fline, year, book, verse from poem
join pobib on poem.poemid=pobib.poemid
join bibal on pobib.bibalid=bibal.bibalid
where ".$entity." like '%".$uput."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
?>[/php]
Error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/zzl.org/s/a/p/sapphirefellows/htdocs/pobib.php on line 62
Line 62 here is [php]$num_results = mysql_num_rows($result);[/php], so I’m assuming a problem is being detected in the query. I can’t see the problem. The only thing I know is that poem.poemid has given the script problems in the past, but only in generating output. Solved this with the “as id”.
Anybody else see my error, or have any ideas about what might be causing the problem if not the code itself?
Thanks!