Gu3rr1lla Posted July 12, 2010 Share Posted July 12, 2010 Hey im new to PHP and trying to build a small fantasy football app. I am getting this error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Users\Jonny\Desktop\projects\xampp\htdocs\phpprojects\elitefifa\home.php on line 23 here is the relevant code: <?php /**Start session */ session_start(); if (!array_key_exists("user", $_SESSION)) { header('Location: index.php'); exit; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php require_once("Includes/db.php"); $teamID = FifaDB::getInstance()->get_team_id_by_name($_SESSION["user"]); echo $teamID; $result = FifaDB::getInstance()->get_team_name_by_team_id($teamID); //line 23 below while($row = mysql_fetch_array($result)){ $teamName = $row["name"]; echo $teamName; } ?> </body> </html> public function get_team_id_by_name($name){ $name = mysql_real_escape_string($name); $result = mysql_query("SELECT team_id FROM user WHERE name = '" . $name . "'"); if(mysql_num_rows($result)>0) return mysql_result($result, 0); else return null; } public function get_team_name_by_team_id($teamID){ return mysql_query("SELECY * FROM team WHERE id = " . $teamID); } Thank you any help, it'll be much appreciated Link to comment https://forums.phpfreaks.com/topic/207498-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean/ Share on other sites More sharing options...
Mchl Posted July 12, 2010 Share Posted July 12, 2010 This error usually indicates that your query failed (and thus mysql_query returned false). To see what was the error use mysql_error (hint: it's a typo). Link to comment https://forums.phpfreaks.com/topic/207498-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean/#findComment-1084816 Share on other sites More sharing options...
Gu3rr1lla Posted July 12, 2010 Author Share Posted July 12, 2010 This error usually indicates that your query failed (and thus mysql_query returned false). To see what was the error use mysql_error (hint: it's a typo). aaaaaahhhhhhhhhh! you're a legend thanks! Link to comment https://forums.phpfreaks.com/topic/207498-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean/#findComment-1084827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.