blufish Posted December 17, 2008 Share Posted December 17, 2008 I know you are all really good at MySQL so can you tell me why this is not working? <?php $database_connect = mysql_connect("sql204.byethost7.com","--","--"); if (!$database_connect) { die('Error Connecting to Database: ' . mysql_error()); } else { echo "Succesfully Connected to Database!"; } $page_query = mysql_query("SELECT * FROM page_info"); while($page_values = mysql_fetch_array($page_query)) { echo $page_values['page_title'] . " " . $page_values['page_name']; echo "<br />"; } mysql_close($database_connect); ?> I'm sures its a simple question, but could you please explain what I have to do to fix this because I am new to MySQL. Thanks, Mark Swingle Quote Link to comment Share on other sites More sharing options...
dmccabe Posted December 17, 2008 Share Posted December 17, 2008 Are you getting any errors? Try this $page_query = mysql_query("SELECT * FROM `page_info`") Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 17, 2008 Share Posted December 17, 2008 'is not working' is not enough information. Change $page_query = mysql_query("SELECT * FROM page_info"); to $page_query = mysql_query("SELECT * FROM page_info") or die(mysql_error()); This will show information about any mysql errors you might have. Quote Link to comment Share on other sites More sharing options...
blufish Posted December 17, 2008 Author Share Posted December 17, 2008 It says Succesfully Connected to Database!No database selected Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 17, 2008 Share Posted December 17, 2008 mysql_select_db Quote Link to comment Share on other sites More sharing options...
blufish Posted December 17, 2008 Author Share Posted December 17, 2008 Okay, I am currently using this code: <?php $database_connect = mysql_connect ("sql204.byethost7.com","--3","--"); if (!$database_connect) { die('Error Connecting to Database: ' . mysql_error()); } else { echo "Succesfully Connected to Database!"; } $select_database = mysql_select_db("b7_2627673_pages", $database_connect); if (!select_database) { die ("Error Selecting Database: " . mysql_error()); } else { echo "Database Succesfully Selected!"; } $page_query = mysql_query("SELECT * FROM page_info") or die (mysql_error()); while($page_values = mysql_fetch_array($page_query)) { echo $page_values['page_title'] . " " . $page_values['page_name']; echo "<br />"; } mysql_close($database_connect); ?> And Getting This Response: Succesfully Connected to Database!Database Succesfully Selected! <br /> <br /> I Should Be Getting This Response: Succesfully Connected to Database!Database Succesfully Selected! Page 1 pg1.htm<br /> Page 2 pg2.htm<br /> Any Ideas? Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 17, 2008 Share Posted December 17, 2008 Is there data in your table? Are table field called 'page_title' and 'page_name'? Quote Link to comment Share on other sites More sharing options...
blufish Posted December 17, 2008 Author Share Posted December 17, 2008 PHPMyAdmin says there is... I have attached a picture if you want to see... [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
blufish Posted December 17, 2008 Author Share Posted December 17, 2008 I accidently named them wrong... I have renamed them and they work. Thank you everyone who has helped me. Quote Link to comment 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.