Page 1 of 1

[SOLVED] testing works but live does not

Posted: Thu Nov 27, 2003 3:52 am
by LannaThai
i am working on a webboard in Thai for an NGO - it works when testing with PHP Triad, however when I upload it - i get "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource" for lines 71 and 84.

here is the code: any suggestions please?

mysql_connect($host,$user,$passwd) OR die ('Could not select the database: ' . mysql_error() );
$sql = "select No from webboard_data where Category=$Category";
$result = mysql_db_query($dbname,$sql);
$NRow = mysql_num_rows($result);
$rt = $NRow%$list_page;
if($rt!=0) {
$totalpage = floor($NRow/$list_page)+1;
}
else {
$totalpage = floor($NRow/$list_page);
}
$goto = ($page-1)*$list_page;

// Query Thai
$sql = "select * from webboard_data where Category='$Category' order by No DESC limit $goto,$list_page";
$result = mysql_db_query($dbname,$sql);
$NRow = mysql_num_rows($result);

if($NRow==0) {
echo "<font size=2 face='MS Sans Serif'>?????????????</font><br><br>\n";

Posted: Thu Nov 27, 2003 4:02 am
by infolock
the reason for the error message is because it's found an error in your queries...

try using the query like this :

Code: Select all

<?php

// first query
$sql = "select No from webboard_data where Category='".$Category."'";


//second query
$sql = "select * from webboard_data where Category='".$Category."' order by No DESC limit ".$goto.",".$list_page."";

?>

Posted: Thu Nov 27, 2003 4:29 am
by twigletmac
Chances are it's a register_globals problem, have a read of:
viewtopic.php?t=511

Mac

Posted: Thu Nov 27, 2003 4:32 am
by infolock
good call mac, overlooked that possibility completely.

Posted: Thu Nov 27, 2003 8:00 am
by LannaThai
i checked phpinfo prior to posting - register_globals is on.

Posted: Thu Nov 27, 2003 8:31 am
by LannaThai
tried your suggestion infolock - same problem with lines 71 and 84. again, the only changes i made in the program from testing and live were to add a username and password to the config file, otherwise the files are the same. it seems like a perfect candidate for the register_globals solution but unfortunately not . . . .

Posted: Thu Nov 27, 2003 8:47 am
by LannaThai
i just figured it out! i am not sure why but when setting a username and password in the control panel for the database, the username and password have to agree with the username and password for the overall site, that is i can not set a username and password just for that database. not sure why that is but, when i changed the username and password, the problem went away.
thanks for your prompt responses!