Log in

View Full Version : mySQL help please



boehwaa
07-29-2008, 11:25 PM
ive been busy alot trying to fix the problem but i cant resolve it:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 35
and
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 42 can someone please help me thx alot


<?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}";
$res = 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);
}
?>

tfit
08-02-2008, 07:44 AM
Is your conditional statement correct?

if
{}
else{}
}
else{}

sm1le
08-04-2008, 09:33 PM
lol I've never seen two elses at the same time, rather try use elseif()

allahverdi
08-05-2008, 04:54 AM
tfit, no, it is correct. Look at code. It starts with if, then there go another if, then else, then first if closed, then else.

tfit
08-05-2008, 06:20 AM
tfit, no, it is correct. Look at code. It starts with if, then there go another if, then else, then first if closed, then else.

I totally missed that first if.
He man where were you when I needed you :-). Your nickname is probably Mr. timesaver

allahverdi
08-05-2008, 06:36 AM
Change all:

mysql_select_db(MYSQL_DATA);

to:

mysql_select_db(MYSQL_DATA) or die(mysql_error());

I think you have error with connection.

allahverdi
08-05-2008, 06:48 AM
tfit, i'm not mr. timesaver. I'm just intent man

Nah, Just call me Mr.TimeSaver :p

tfit
08-12-2008, 04:25 PM
tfit, i'm not mr. timesaver. I'm just intent man

Nah, Just call me Mr.TimeSaver :p

Mr.TimeSaver it will be :p