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
https://forums.phpfreaks.com/topic/183047-ive-run-into-another-error/
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.

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)

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());
?>

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.