EmuX Posted February 3, 2010 Share Posted February 3, 2010 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)) Quote Link to comment https://forums.phpfreaks.com/topic/190750-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
PravinS Posted February 3, 2010 Share Posted February 3, 2010 Please check your mysql queries, also try this $res = mysql_query("SELECT sqlhost,sqluser,sqlpass,chardb FROM realms WHERE entry='.$Realm.'"); and $res = mysql_query("SELECT guid FROM characters WHERE name='.$Name.'"); Quote Link to comment https://forums.phpfreaks.com/topic/190750-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1005919 Share on other sites More sharing options...
EmuX Posted February 3, 2010 Author Share Posted February 3, 2010 Didn't seem to work and I don't know PHP. It is not my script. Quote Link to comment https://forums.phpfreaks.com/topic/190750-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1005922 Share on other sites More sharing options...
PravinS Posted February 3, 2010 Share Posted February 3, 2010 You need to check the queries, echo the queries and execute it in mysql. Quote Link to comment https://forums.phpfreaks.com/topic/190750-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1005924 Share on other sites More sharing options...
EmuX Posted February 3, 2010 Author Share Posted February 3, 2010 Alright I fixed the SQL. I get no errors now, but when I go to select a reward nothing shows but there is a reward in the database. Quote Link to comment https://forums.phpfreaks.com/topic/190750-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1005929 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.