WebDeveloperMike Posted March 9, 2012 Report Share Posted March 9, 2012 I built a website at www.mikespot.net/alex/ that uses php and mysql to store and display blog entries. It works 100%. I purchased a new domain (www.ijournalsometimes.com) and added an 'addon domain' to my current web hosting package - so the root folder is for my new site is public_html/ijournalsometimes.com I copy and pasted all of my files from public_html/alex/ to public_html/ijournalsometimes.com... I can connect to the MySQL server and database successfully. I can ADD blog entries successfully (Inserting data into the database)... ..but when i try to select and display data from database...NOTHING. basically, the sites are coded the exact same but are in different locations and now i cant select and display data from the database. here is my php code for the index page: <?php $sql = "SELECT * FROM blog ORDER BY id DESC LIMIT 5"; $get_all = mysql_query($sql); $blog_entry; while($row = mysql_fetch_array($get_all, $con)) { $blog_entry = $blog_entry . "<div class='blog_entry'> <div class='blog_title'>{$row['title']}</div><!-- end title --> <div class='blog_date_time'>{$row['date']} <font style='color:#abf7fb'>/</font> {$row['time']} <font style='color:#abf7fb'>/</font> Posted by: <a href='mailto:schultza6537@my.uwstout.edu'>Alex</a></div><!-- end date time --> <div class='blog_mess'><p>{$row['body']}</p> </div> <!-- end blog body --> <div class='blog_bottom'></div><!-- end blog bottom --> </div><!-- end entry -->"; } ?> <?php here are the links to the 2 sites (same exact code - but one site works and one doesnt) http://www.mikespot.net/alex/ - this displays blog entries correctly http://www.ijournalsometimes.com - this one does not thank you in advance for your help! Mike Quote Link to comment Share on other sites More sharing options...
WebDeveloperMike Posted March 9, 2012 Author Report Share Posted March 9, 2012 At this point, I have my domain (www.ijournalsometimes.com) pointing to http://www.mikespot.net/alex/'>http://www.mikespot.net/alex/ if you type in http://www.mikespot.net/alex/ - the blog works 100%. if you type in www.ijournalsometimes.com - it does not work. ????????????????????????????????????????? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 10, 2012 Report Share Posted March 10, 2012 Do you have some sort of include which actually makes the connection to the database above these lines? <?php $sql = "SELECT * FROM blog ORDER BY id DESC LIMIT 5"; $get_all = mysql_query($sql); $blog_entry; Those lines query the database, but you do have to have some sort of connection first. Quote Link to comment Share on other sites More sharing options...
WebDeveloperMike Posted March 10, 2012 Author Report Share Posted March 10, 2012 (edited) Do you have some sort of include which actually makes the connection to the database above these lines? <?php $sql = "SELECT * FROM blog ORDER BY id DESC LIMIT 5"; $get_all = mysql_query($sql); $blog_entry; Those lines query the database, but you do have to have some sort of connection first. Yes, i use a db_connect.php as a php include file: <?php $con = mysql_connect('localhost','mikesp5_test','reggie88'); if (!$con) { die("Could not connect to MySQL Server" . mysql_error()); } // echo "Successfully connected to MySQL Server!"; $my_db = mysql_select_db("mikesp5_killer"); if (!$my_db) { die("Could not connect to database" . mysql_error()); } // echo "Successfully connected to Database!"; ?> when i remove the comment tags before the echo's they both show up. and i am able to insert data into the database. just not display it for some reason. also, the SQL does actually select items from the database because when I LIMIT 5 and go to www.ijournalsometimes.com i see 5 empty blog entry templates, so its not getting the the actual text from the database... i hope that makes sense. visit ijournalsometimes.com and you will see it there is as many empty blog entry templates as i wish using LIMIT in my SQL code. Thank you Ben for the reply Edited March 10, 2012 by WebDeveloperMike Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 10, 2012 Report Share Posted March 10, 2012 This question may be best discussed with your hosting provider. This isn't something I have run into before, and based on your comments, it sounds like you are making a connection to the database just fine. Quote Link to comment Share on other sites More sharing options...
WebDeveloperMike Posted March 12, 2012 Author Report Share Posted March 12, 2012 I found the problem...and im not sure why it was a problem at all... I had to change this code: while($row = mysql_fetch_array($get_all, $con)) to this code: while($row = mysql_fetch_array($get_all)) So i took out the $con variable which was my connection. not sure why it made a difference? 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.
Note: Your post will require moderator approval before it will be visible.