corrupshun Posted November 26, 2009 Share Posted November 26, 2009 "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in B:\wamp\www\sql\select.php on line 17" this is the starting code I have to making a game sever: What does this error mean and what can i do to fix it? <?php $id = $_GET['gameid']; //Username and password to connect $con = mysql_connect("localhost","root",""); //check if connection was successful if(!$con) { echo "Could not connect"; } else { echo "Connected to database"; } echo "<br />"; mysql_select_db("Corrupshun", $con); $query = mysql_query("SELECT 'Title', 'Path' FROM 'Games' WHERE 'id' = $id"); $row = mysql_fetch_array($query); echo $row['title']; echo '<br />'.$row['path']; //while($row = mysql_fetch_array($result)) { //echo $row['ID'] . " " . $row['Title'] . " " . $row['Path']; //echo "<br />"; //} ?> -Thank you very much! Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/ Share on other sites More sharing options...
corrupshun Posted November 26, 2009 Author Share Posted November 26, 2009 oh and I used GET in the url such as game.php?gameid=1 Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966059 Share on other sites More sharing options...
MisterWebz Posted November 26, 2009 Share Posted November 26, 2009 Try this: <?php mysql_select_db("Corrupshun", $con); $query = mysql_query("SELECT 'Title', 'Path' FROM 'Games' WHERE 'id' = $id"); while($row = mysql_fetch_array($query)){ echo $row['title']; echo '<br />'.$row['path']; } ?> Copy the above code and replace it with the same part in your code. Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966062 Share on other sites More sharing options...
rajivgonsalves Posted November 26, 2009 Share Posted November 26, 2009 this $query = mysql_query("SELECT 'Title', 'Path' FROM 'Games' WHERE 'id' = $id"); should be $query = mysql_query("SELECT `Title`, `Path` FROM `Games` WHERE `id` = $id") or die(mysql_error()); your column names should be in ` not ' (single quotes) Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966063 Share on other sites More sharing options...
MisterWebz Posted November 26, 2009 Share Posted November 26, 2009 this $query = mysql_query("SELECT 'Title', 'Path' FROM 'Games' WHERE 'id' = $id"); should be $query = mysql_query("SELECT `Title`, `Path` FROM `Games` WHERE `id` = $id") or die(mysql_error()); your column names should be in ` not ' (single quotes) I thought quotes weren't necessary when sending a query? <?php $query = mysql_query("SELECT Title, Path FROM Games WHERE id = '$id'") or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966065 Share on other sites More sharing options...
corrupshun Posted November 26, 2009 Author Share Posted November 26, 2009 wait so what's the difference between ' and ` it worked.. but how do i type it ACTUALLY** I still have an error.. Notice: Undefined index: title in B:\wamp\www\sql\select.php on line 18 Notice: Undefined index: path in B:\wamp\www\sql\select.php on line 19 What? Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966067 Share on other sites More sharing options...
rajivgonsalves Posted November 26, 2009 Share Posted November 26, 2009 ` - is backticks its on the keyboard before 1, mostly used for enclosing table names and column names ' - single quote if you enclose anything in this is considered a string. Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966068 Share on other sites More sharing options...
MisterWebz Posted November 26, 2009 Share Posted November 26, 2009 wait so what's the difference between ' and ` it worked.. but how do i type it ACTUALLY** I still have an error.. Notice: Undefined index: title in B:\wamp\www\sql\select.php on line 18 Notice: Undefined index: path in B:\wamp\www\sql\select.php on line 19 What? Could you post your updated code again? I'm not sure what you've changed. Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966069 Share on other sites More sharing options...
corrupshun Posted November 26, 2009 Author Share Posted November 26, 2009 Nevermind, fixed it problem was that $row['path']; should have been $row['Path']; capital letters Link to comment https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/#findComment-966070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.