Jump to content

mysql_fetch_array() expects parameter 1 to be resource


cobusbo

Recommended Posts

This is my code

$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];
if(!isset($testip))
{
	$testip = "Debater";

}


$result = mysql_query("SELECT * FROM pm WHERE mxitid = \"$testip\" ORDER BY id DESC LIMIT $offset, $rowsperpage")or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result) or die($result."<br/><br/>".mysql_error()))
{
         


$name = $row['username'];
         $mid = $row['mxitid'];
         $message = $row['message'];
		$id = $row['id'];
		$date = $row['time'];
		$myip = $row['ip'];

$delete = '<a href="http://guniverse.hol.es/chat/pm.php?option=Delete&id=' . $id . '">Delete</a>';
$reply = '<a href="http://guniverse.hol.es/chat/pm.php?option=' . 'reply'. '&nname=' . $name . '&ip=' . $myip .'">Reply</a>';

echo '<b>' . $name . ':</b> <i>' . $message . ' - ' . '<span style="color:#828282">' . date( 'D H:i:s', $date ) . '</span> ' . $delete . " " . $reply .'</i><br>';


if($_GET['option']=='reply') {
    $mxitid = $_GET["ip"];
    $result = mysql_query("SELECT * FROM Users2 WHERE mxitid='".$mxitid."'", $conn); 
    $myrow = mysql_fetch_array($result);
?>
    <form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>">
Type in your message...<br>
      <input name="message" class="StringyChatFrm" type="text" size="20" maxlength="<? echo $name_size; ?>" value="<? echo $myrow["Username"]?>">
      <br>
      <input name="message1" class="StringyChatFrm" type="submit" value="Update">
    </form>

<?
  }
if ($_POST["message1"]) {
$ip = $_SERVER["HTTP_X_MXIT_USERID_R"];
if(!isset($ip))
{
	$ip = "Debater";

}

$result = mysql_query("SELECT * FROM Users2 WHERE mxitid = \"$ip\"");
$id = $_GET["id"];
$nname = $_GET["nname"];
$ip1 = $_GET["ip"];
$banby2 = $_SERVER["HTTP_X_MXIT_USERID_R"];

        $row = mysql_fetch_array($result);
        $mxitid = $row['mxitid'];
         $naam = $row['Username'];
		$rank = $row['rank'];
		$date = date("U");
$mxitid = $_GET["ip"];
$message = $_POST["message"];

$query = "INSERT INTO pm (username,mxitid,message,time) VALUES (\"$naam\",\"$ip1\",\"$message\",\"$date\")";

    $result = mysql_query($query, $conn) or die("Invalid query: " . mysql_error());

$query5 = "SELECT * FROM broadcast"; 
	 
$result1 = mysql_query($query5) or die(mysql_error());

$users = array();
while($row = mysql_fetch_array($result1)){
	if ($row['onorof'] != '')
$users[] = $row['onorof'];
	}


$batchSize = 50;                          // set size of your batches

$batches = array_chunk($users, $batchSize);


require_once ('MxitAPI.php');
/* Instantiate the Mxit API */
$key = 'a82a9fb77a9d435b8c8c066a5bbd9959';
$secret = 'c3a4f316361e4a7a8573bfe6c8652560';
$app = 'spamchat';
$nick = urldecode($_SERVER['HTTP_X_MXIT_NICK']);
$admin = array('m70141099002' , 'Debater', '27765238453', '');
$moderator = array('m52626156002', 'm51256041002' , 'm50079252002', '27723289551');

$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if (in_array($testip, $admin)){
    $col = "#ff0000";
$message1 = "#ff0000" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}
elseif (in_array($testip, $moderator)){
    $col = "#4CA64C";
$message1 = "#4CA64C" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}
else{
$col = "#000000";
$message1 = "#000000" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}

if(!isset($nick))
{
	$nick = "Debater";
}

$message = $_POST["message"];
$message1 = "$col" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";


$api = new MxitAPI($key, $secret);
$api->get_app_token('message/send');

foreach ($batches as $batch) {
    $list = implode(',', $batch);
    // process the batch list here
    $api->send_message($app, $ip1, $message1, 'true');
}



echo "Message has been Sent!";


}







}

Shows on page

 

 

Resource id #5

and after submiting the form I get the error

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u342037492/public_html/chat/pm.php on line 83
1

Line 83 is

$result = mysql_query("SELECT * FROM pm WHERE mxitid = \"$testip\" ORDER BY id DESC LIMIT $offset, $rowsperpage")or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result) or die($result."<br/><br/>".mysql_error()))
{

of the above code.

 

Where am I going wrong?

Link to comment
Share on other sites

This is my code

$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];
if(!isset($testip))
{
	$testip = "Debater";

}


$result = mysql_query("SELECT * FROM pm WHERE mxitid = \"$testip\" ORDER BY id DESC LIMIT $offset, $rowsperpage")or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result) or die($result."<br/><br/>".mysql_error()))
{
         


$name = $row['username'];
         $mid = $row['mxitid'];
         $message = $row['message'];
		$id = $row['id'];
		$date = $row['time'];
		$myip = $row['ip'];

$delete = '<a href="http://guniverse.hol.es/chat/pm.php?option=Delete&id=' . $id . '">Delete</a>';
$reply = '<a href="http://guniverse.hol.es/chat/pm.php?option=' . 'reply'. '&nname=' . $name . '&ip=' . $myip .'">Reply</a>';

echo '<b>' . $name . ':</b> <i>' . $message . ' - ' . '<span style="color:#828282">' . date( 'D H:i:s', $date ) . '</span> ' . $delete . " " . $reply .'</i><br>';


if($_GET['option']=='reply') {
    $mxitid = $_GET["ip"];
    $result = mysql_query("SELECT * FROM Users2 WHERE mxitid='".$mxitid."'", $conn); 
    $myrow = mysql_fetch_array($result);
?>
    <form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>">
Type in your message...<br>
      <input name="message" class="StringyChatFrm" type="text" size="20" maxlength="<? echo $name_size; ?>" value="<? echo $myrow["Username"]?>">
      <br>
      <input name="message1" class="StringyChatFrm" type="submit" value="Update">
    </form>

<?
  }
if ($_POST["message1"]) {
$ip = $_SERVER["HTTP_X_MXIT_USERID_R"];
if(!isset($ip))
{
	$ip = "Debater";

}

$result = mysql_query("SELECT * FROM Users2 WHERE mxitid = \"$ip\"");
$id = $_GET["id"];
$nname = $_GET["nname"];
$ip1 = $_GET["ip"];
$banby2 = $_SERVER["HTTP_X_MXIT_USERID_R"];

        $row = mysql_fetch_array($result);
        $mxitid = $row['mxitid'];
         $naam = $row['Username'];
		$rank = $row['rank'];
		$date = date("U");
$mxitid = $_GET["ip"];
$message = $_POST["message"];

$query = "INSERT INTO pm (username,mxitid,message,time) VALUES (\"$naam\",\"$ip1\",\"$message\",\"$date\")";

    $result = mysql_query($query, $conn) or die("Invalid query: " . mysql_error());

$query5 = "SELECT * FROM broadcast"; 
	 
$result1 = mysql_query($query5) or die(mysql_error());

$users = array();
while($row = mysql_fetch_array($result1)){
	if ($row['onorof'] != '')
$users[] = $row['onorof'];
	}


$batchSize = 50;                          // set size of your batches

$batches = array_chunk($users, $batchSize);


require_once ('MxitAPI.php');
/* Instantiate the Mxit API */
$key = 'a82a9fb77a9d435b8c8c066a5bbd9959';
$secret = 'c3a4f316361e4a7a8573bfe6c8652560';
$app = 'spamchat';
$nick = urldecode($_SERVER['HTTP_X_MXIT_NICK']);
$admin = array('m70141099002' , 'Debater', '27765238453', '');
$moderator = array('m52626156002', 'm51256041002' , 'm50079252002', '27723289551');

$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if (in_array($testip, $admin)){
    $col = "#ff0000";
$message1 = "#ff0000" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}
elseif (in_array($testip, $moderator)){
    $col = "#4CA64C";
$message1 = "#4CA64C" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}
else{
$col = "#000000";
$message1 = "#000000" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";



}

if(!isset($nick))
{
	$nick = "Debater";
}

$message = $_POST["message"];
$message1 = "$col" . "You Received a Mailbox message from " . $naam . " " ."\$Refresh\$";


$api = new MxitAPI($key, $secret);
$api->get_app_token('message/send');

foreach ($batches as $batch) {
    $list = implode(',', $batch);
    // process the batch list here
    $api->send_message($app, $ip1, $message1, 'true');
}



echo "Message has been Sent!";


}







}

Shows on page

 

and after submiting the form I get the error

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u342037492/public_html/chat/pm.php on line 83
1

Line 83 is

$result = mysql_query("SELECT * FROM pm WHERE mxitid = \"$testip\" ORDER BY id DESC LIMIT $offset, $rowsperpage")or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result) or die($result."<br/><br/>".mysql_error()))
{

of the above code.

 

Where am I going wrong?

Ok so I changed the code to 

$sql = "SELECT * FROM pm WHERE mxitid = \"$testip\" ORDER BY id DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn)or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result))
{

the resource 4 error is gone but I still get the error

 

mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u342037492/public_html/chat/pm.php on line 84

Link to comment
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.