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 Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/ 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`") Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717493 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. Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717494 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 Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717495 Share on other sites More sharing options...
Mchl Posted December 17, 2008 Share Posted December 17, 2008 mysql_select_db Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717497 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? Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717498 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'? Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717503 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] Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717507 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. Link to comment https://forums.phpfreaks.com/topic/137323-simple-mysql-question/#findComment-717510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.