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! Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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) Quote Link to comment 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()); ?> Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.