Jump to content

This is really frustrating...PHP/MySQL


Recommended Posts

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:




$sql = "SELECT * FROM blog ORDER BY id DESC LIMIT 5";

$get_all = mysql_query($sql);




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>


<!-- end blog body -->

<div class='blog_bottom'></div><!-- end blog bottom -->

</div><!-- end entry -->";







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! :)



Link to comment
Share on other sites

Do you have some sort of include which actually makes the connection to the database above these lines?



$sql = "SELECT * FROM blog ORDER BY id DESC LIMIT 5";
$get_all = mysql_query($sql);

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:




$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 by WebDeveloperMike
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...