Imaulle Posted December 24, 2010 Share Posted December 24, 2010 Hello, while($row = mysql_fetch_array($result)){ echo $row['HostName']. " - ". $row['UsedSlots']. " / ". $row['MaxSlots']; echo "<br />"; } the first line is causing error "PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" but it was working on the original server I was doing the setup with (which was newer) how can I get this to work? it's not working on MySQL client version: 5.0.91 it is working on MySQL client version: 5.1.52 but I need it working on both! thanks Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/ Share on other sites More sharing options...
revraz Posted December 24, 2010 Share Posted December 24, 2010 Your query above that is not working. Post your query. Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151063 Share on other sites More sharing options...
Imaulle Posted December 24, 2010 Author Share Posted December 24, 2010 oh oops,sorry $result = mysql_query("SELECT * FROM ServerList"); Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151064 Share on other sites More sharing options...
Imaulle Posted December 24, 2010 Author Share Posted December 24, 2010 Here is all of the code, I get the same sql error for both index.php and update.php I'm very very new to php/html/sql so if you'd like to make any suggestions/criticism I'd appreciate it index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Servers</title> <link href="6c87136.gz.css" rel="stylesheet" type="text/css" /> </head> <body> <br><br><center> <div style="width: 500px;"><div class="header-3 b-r-t-3 m-t-10"> <span class="f16">Servers</span></div><div class="panel-5 p-5"> <?php require_once('functions.php'); $mlink = @mysql_connect("localhost","user","pass"); mysql_select_db("database", $mlink); $result = mysql_query("SELECT * FROM ServerList"); while($row = mysql_fetch_array($result)){ echo $row['HostName']. " - ". $row['UsedSlots']. " / ". $row['MaxSlots']; echo "<br />"; } ?></div></div><br> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="jquery.blockUI.js"></script> <script type="text/javascript"> $(document).ajaxStart($.blockUI).ajaxStop($.unblockUI); $(document).ready(function() { $('#Button').click(function() { $.get('update.php', function(data) { location.reload(); }); }); }); </script><input id="Button" type="button" value="refresh"/> <br><br> <?php $result = mysql_query("SELECT * FROM UpdateTime"); $row = mysql_fetch_array($result,MYSQL_ASSOC); echo "current as of " . nicetime($row['TimeUpdated']); ?> </center></body></html> update.php <?php require_once('functions.php'); $mlink = @mysql_connect("localhost","username","password"); mysql_select_db("database", $mlink); $result = mysql_query("SELECT * FROM ServerList",$mlink); while($row = mysql_fetch_array($result)){ $server = new Whm; $server->init($row['HostName'],$row['UserName'],$row['PassHash']); $NewUsedSlots = count($server->listaccts()); mysql_query("UPDATE ServerList SET UsedSlots='$NewUsedSlots' WHERE HostName='{$row['HostName']}'",$mlink); } $CurrentTime = date("Y-m-d G:i"); mysql_query("UPDATE UpdateTime SET TimeUpdated='$CurrentTime'",$mlink); ?> Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151069 Share on other sites More sharing options...
Imaulle Posted December 24, 2010 Author Share Posted December 24, 2010 anyone? this crazy that it works on one server but not the other Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151095 Share on other sites More sharing options...
revraz Posted December 24, 2010 Share Posted December 24, 2010 Use mysql_error after your query to see if it tells you why it's failing. Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151097 Share on other sites More sharing options...
Imaulle Posted December 24, 2010 Author Share Posted December 24, 2010 oh wth, it says no database selected, but I select it right before? Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151100 Share on other sites More sharing options...
Imaulle Posted December 24, 2010 Author Share Posted December 24, 2010 omg I never added the user to the database :'( sorrry!!!!!!!!!!! thank you!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151101 Share on other sites More sharing options...
revraz Posted December 24, 2010 Share Posted December 24, 2010 Remove the @ before your connect string to see if it's failing. Quote Link to comment https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151102 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.