Jump to content

Website vs. WebServ PHP code issue


latino.ad7

Recommended Posts

I wrote some PHP/MySQL code and it works fine on my hard-drive throu WebServ. Yet when I place it on the internet, on the website, it generates an error.

 

Here is PHP code (after successfully connecting to the database):

165 $q = ("Select id, filename, name, author, bin from objects where category = 'category1'");

166 $r = mysql_query ($q, $link);

167

168 while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {

169 $arrid[$row['id']] = $row['id'];

170 $arrfilename[$row['id']] = $row['filename'];

171 $arrname[$row['id']] = $row['name'];

172 $arrauthor[$row['id']] = $row['author'];

173 $arrbin[$row['id']] = $row['bin'];

174}

175 $num = mysql_num_rows($r);

 

The error messages are:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in .../public_html/category.php on line 168

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in .../public_html/category.php on line 175

 

Link to comment
https://forums.phpfreaks.com/topic/192032-website-vs-webserv-php-code-issue/
Share on other sites

Ehem, no... I don't get it.

 

What I tried is I put:

echo "$r -- $q"; to check.

On the internet it seems empty("--"), while throu WebServ it seems fine: "Select id, filename, name, author, bin from objects where category = 'category1' -- Resource id #58 "

Hm, I'm actually using a link to get a variable:

 

Link: whatever/page.php?val=whatever&cat=Category

 

if ($cat == "Category") {

$q = ("Select id, filename, name, author, bin from objects where category = '".$val."'");

} elseif ($cat == "Author") {

$q = ("Select id, filename, name, author, bin from objects where author2 = '".$val."'");

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.