Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/222571-phpsql-error/
Share on other sites

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 :D

 

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);
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/222571-phpsql-error/#findComment-1151069
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.