Mod-Jay Posted September 4, 2010 Share Posted September 4, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/212493-error/ Share on other sites More sharing options...
Joshua F Posted September 4, 2010 Share Posted September 4, 2010 $id=$r["ID"]; $name=$r["name"]; $desc=$r["descr"]; $date=$r["date"]; Those aren't really needed, you can just use a php code to echo the stuff, but you can do it that way I guess. Quote Link to comment https://forums.phpfreaks.com/topic/212493-error/#findComment-1107095 Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Share Posted September 4, 2010 Does connect.php have mysql_select_db in it with the database you're wanting to use? If not, you'll need to put it in there or your current file to tell php which database to use. Quote Link to comment https://forums.phpfreaks.com/topic/212493-error/#findComment-1107096 Share on other sites More sharing options...
wildteen88 Posted September 4, 2010 Share Posted September 4, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/212493-error/#findComment-1107097 Share on other sites More sharing options...
Mod-Jay Posted September 4, 2010 Author Share Posted September 4, 2010 Fixed Quote Link to comment https://forums.phpfreaks.com/topic/212493-error/#findComment-1107102 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.