[SOLVED] testing works but live does not

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
LannaThai
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 3:52 am
Location: N. Thailand

[SOLVED] testing works but live does not

Post 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";
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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."";

?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Chances are it's a register_globals problem, have a read of:
viewtopic.php?t=511

Mac
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

good call mac, overlooked that possibility completely.
LannaThai
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 3:52 am
Location: N. Thailand

Post by LannaThai »

i checked phpinfo prior to posting - register_globals is on.
LannaThai
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 3:52 am
Location: N. Thailand

Post 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 . . . .
LannaThai
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 3:52 am
Location: N. Thailand

Post 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!
Post Reply