Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-27-2012, 10:04 AM   #1
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
SQL fetch Errors?

Could one of the programming types give me a hand with this error that i am getting running a script on my server...

Quote:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/r3ading/public_html/admin/sets.php on line 175
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/r3ading/public_html/admin/sets.php on line 206
Here are the 2 lines of code it is telling me are faulty but i dont see *why* because the script works perfectly on another server...

174 & 175 line:
Code:
$query="SELECT COUNT(*) FROM $table_name";
list($total_links)=mysql_fetch_array(mysql_query($query));
203 to 207 lines:
Code:
$i=0;
$res=mysql_query($query);
echo "<td>";
while($r=mysql_fetch_array($res))
{
 $i++;
 $id=$r['id'];
 $dir_name=$r['dir_name'];
 $thumb=displayThumb($dir_name,$r['thumb']);
Any help you could offer would be appreciated, ive been on with my hosting tech support a few times about this but theyre telling me it a 'code' issue not a server issue, but i *know* for a fact this program works 100% on another server but they wont hear any of it
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 10:07 AM   #2
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
$table_name is not defined, or that table doesn't exist at all, or is perhaps corrupted... or perhaps you have wrong db credentials in your config file...

if you want me to take a closer look for a few bucks, icq: 33375924 or woj#at#wojfun#.#com
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 10:23 AM   #3
AndrewX
Confirmed User
 
AndrewX's Avatar
 
Industry Role:
Join Date: Jan 2004
Posts: 574
Try backing up and restoring the database tables again. Also note that 'warning' messages can be turned off in PHP configuration (debug mode), they are not errors which will halt your script.
__________________

█ ► XenLayer - Paravirtualization Professionals since 2008 - [ICQ: 297820698]
█ ► Reseller Hosting | OpenVZ VPS | XEN VPS | Dedicated Servers
AndrewX is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 10:34 AM   #4
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
I just repaired the SQL table and that seems to have fixed it for a few minutes.

Im now thinking there is an issue with my hosting companies SQL system perhaps?

Every time i run the program, if i 'repair' the table afterwards it works again.
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 11:08 AM   #5
AndrewX
Confirmed User
 
AndrewX's Avatar
 
Industry Role:
Join Date: Jan 2004
Posts: 574
At those lines the warning appears, change mysql_fetch_array to @mysql_fetch_array

It will make it silent.
__________________

█ ► XenLayer - Paravirtualization Professionals since 2008 - [ICQ: 297820698]
█ ► Reseller Hosting | OpenVZ VPS | XEN VPS | Dedicated Servers
AndrewX is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 11:16 AM   #6
alcstrategy
Confirmed User
 
Industry Role:
Join Date: May 2012
Posts: 124
Quote:
Originally Posted by AndrewX View Post
At those lines the warning appears, change mysql_fetch_array to @mysql_fetch_array

It will make it silent.
you get the error because you dont check if the result is valid

what good is making it silent if he needs for debugging assuming its not a live site and if it is a live site then set display_errors off in php config and then check error log, but add some code to handle that issue checking the result var

Also you should move away from mysql library at the very least use mysqli. The Mysql lib will be deprecated in php's future and its an old library that lacks support in many things
alcstrategy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 11:31 AM   #7
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
Well after getting on the phone with the host, it appears the error was with them blocking the server IP address from writing to SQL.

No idea how or why this happened, but the problem is now fixed and the script is working as it should be.

Thanks all for the assistance with this issue, its appreciated
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-27-2012, 09:26 PM   #8
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
You need to CAST the count to a named variable...

Code:
$query="SELECT COUNT(*) AS numrows FROM $table_name";
$ret = mysql_query($query);
$fetched = mysql_fetch_array($ret);
echo 'Amount = '.$fetched['numrows'];
That's some really horrible code, btw.

...glad you got it sorted out.
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.