Jump to content

Warning: mysql_fetch_array() expects parameter 1 to be resource


EmuX

Recommended Posts

I am getting these errors:

 

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\donate\index.php on line 35

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\donate\index.php on line 42

 

And here is the code:

 

<?php
header("Cache-control: no-cache, must-revalidate\r\n");
require_once("config.php");
if(isset($_GET['char']))
{
	$con = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS);
	mysql_select_db(MYSQL_DATA);
	$Name = mysql_real_escape_string($_GET['char']);
	$Realm = mysql_real_escape_string($_GET['realm']);
	$Realm = (int)$Realm+1;
	$res = mysql_query("SELECT sqlhost,sqluser,sqlpass,chardb FROM realms WHERE entry='{$Realm}'");
	$row = mysql_fetch_array($res);
	mysql_close($con);
	$con = mysql_connect($row['sqlhost'],$row['sqluser'],$row['sqlpass']);
	mysql_select_db($row['chardb']);
	$res = mysql_query("SELECT guid FROM characters WHERE name='{$Name}'");
	if(mysql_num_rows($res) == 1)
	{
		$row = mysql_fetch_array($res);
		echo $row['guid'];
	}
	else
	{
		echo "0";
		die;
	}
	mysql_close($con);
}
else
{
	$con = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS);
	mysql_select_db(MYSQL_DATA);
	$res = mysql_query("SELECT entry,name FROM realms");
	$REALMS = "{";
	while($row = mysql_fetch_array($res))
	{
		$REALMS .= ((int)$row['entry']-1).":\"".$row['name']."\",";
	}
	$REALMS .= "\"undefined\":0}";
	$result = mysql_query("SELECT entry,name,realm,description,price FROM rewards");
	$REWARDS = "{";
	while($row = mysql_fetch_array($res))
	{
		$REWARDS .= ((int)$row['entry']-1).":{name:\"".$row['name']."\",realm:".((int)$row['realm']-1).",description:\"".addslashes($row['description'])."\",price:".$row['price']."},";
		$DESCRIPTIONS .= "<div class=\"SlidingPanelsContent\" style=\"padding:2px;\">".$row['description']."</div>";
	}
	$REWARDS .= "\"undefined\":0}";
	$REWARDS = str_replace("\r","\\r",$REWARDS);
	$REWARDS = str_replace("\n","\\n",$REWARDS);
	include("form.php");
	mysql_close($con);
}
?>

 

Line 35:

 

while($row = mysql_fetch_array($res))

 

Line 42:

 

while($row = mysql_fetch_array($res))

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.