Jump to content

I've run into another error.


corrupshun

Recommended Posts

"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
Share on other sites

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
Share on other sites

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
Share on other sites

wait so what's the difference between '  and `

it worked..

but how do i type it :P

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.