Jump to content

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

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.