Jump to content

ERROR


Mod-Jay

Recommended Posts

Error:

Fatal error: Query Error: No database selected in /home/a5640714/public_html/school/aa/pages/news.php on line 38

 

Code:

	                <?php
include '../inc/connect.php';
		$result = mysql_query("SELECT * FROM blog ORDER BY id ASC") or trigger_error('Query Error: ' . mysql_error(), E_USER_ERROR);
		//the while loop
		while($r=mysql_fetch_array($result))
		{
$id=$r["ID"];
$name=$r["name"];
$desc=$r["descr"];
$date=$r["date"];
echo "
<tr>
<td>
News Name: $name
</td>
<td>
News Desc: $desc
</td>
<td>
Date Posted: $date
</td>
<td>
<a href='news.php?action=edit&id=$id'>Edit</a>
</td>
<td>
<a href='news.php?action=delete&id=$id'>Delete $name</a>
</td>
</tr>
";
}
?>

Line 38:

			$result = mysql_query("SELECT * FROM blog ORDER BY id ASC") or trigger_error('Query Error: ' . mysql_error(), E_USER_ERROR);

Link to comment
https://forums.phpfreaks.com/topic/212493-error/
Share on other sites

What is in inc/connect.php?

 

You need to be connected to mysql and have a database selected before you can start quering tables. You do not appear to have a database selected. That is why you are getting this error:

Fatal error: Query Error: No database selected in /home/a5640714/public_html/school/aa/pages/news.php on line 38
Link to comment
https://forums.phpfreaks.com/topic/212493-error/#findComment-1107097
Share on other sites

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.