Using PHP to connect to Mysql Database at software development blogs

Making Business SUCCESSFUL Every Day

start now

single page

Using PHP to connect to Mysql Database

The below code connects to a mysql database.

<?php

//All the below variables are related to your mysql database
$username = “your_name”;
$password = “your_password”;
$hostname = “localhost”; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die(“Unable to connect to MySQL Database”);
echo “Connected to MySQL Database<br>”;

//select a database to work with
$selected = mysql_select_db(“DatabaseName”,$dbhandle)
  or die(“Could not select DatabaseName “);

//execute the SQL query and return records
$result = mysql_query(“SELECT id, model,year FROM cars”);

//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
   echo “ID:”.$row{‘id’}.” Name:”.$row{‘model’}.”Year: “. //display the results
   $row{‘year’}.”<br>”;
}
//close the connection
mysql_close($dbhandle);
?>

Don’t forget to create your mysql database and table.

  1. This site looks good as it will save me a load of time crawling around for Outsourcers. here I post once and then wait for the bids.

  2. To build credibility simply be proof of your own hype and give people value over and over again. Help others to achieve what they want to, and you become credible in their eyes.

  3. That is some inspirational stuff. Never knew that opinions could be this varied. Thanks for all the enthusiasm to offer such helpful information here.

  4. Will bookmark your site just becuase you have some good stuff here.

  5. Ecommerce says:

    Hi there I like your post

  6. Guide Guy says:

    I am brand-new to blogging and actually enjoyed your site. I am going to bookmark your blog and keep checking you out. Thanks for sharing your web site.

  7. I just couldnt leave your website before telling you that we really enjoyed the quality information you offer to your visitors… Will be back soon to check up on new posts

  8. Hey very nice blog!!

  9. Santa says:

    I can see that you are an expert in this area. I am starting a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.

  10. Hi there, I found your blog via Google while searching for first aid for a heart attack and your post looks very interesting for me.

  11. Troy Mallar says:

    Come on dude, these facts* and proof* i mean who is posting* lol :P

  12. Keep the good information comming, we need more authors like you!

  13. Deemoz says:

    I just stumbled upon your blog and I want to invite you to submit your blog link on my free directory. It will help you boost your page rank, search engine rankngs and eventually visitors.

  14. Tyrell Folts says:

    Hi good weblog,
    If you wish to generate extra readers you can try a Press Release my site presents free press release distribution and I might be very happy to assist with any pointers you would possibly need. We distribute information to 1000’s of web sites every day so a launch might be very useful to your sites ranking. Different free press release websites include Prlog.org, Pressport.co.uk, Freepressindex.com

    Thanks
    http://www.bwrnews.co.uk

  15. Hi I found your site by mistake when i was searching yahoo for this acne issue, I must say your site is really helpful I also love the design, its amazing!. I don’t have the time at the moment to fully read your site but I have bookmarked it and also add your RSS feeds. I will be back in a day or two. thanks for a great site.

  16. I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.

  17. thankyou lots, I must comment that your website is amazing!

  18. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.

  19. Thank you for another informative blog. Where else could I get that kind of info written in such a perfect way? I have a project that I am just now working on, and I have been on the look out for such information.

  20. i know i’m a little off topic, but i just wanted to say i love the layout of your blog. i’m new to the blogegine platform, so any suggestions on getting my blog looking nice would be appreciated.

  21. tifacil says:

    Good afternoon, thanks for the post? Is your site a free theme or paid? I am intrigued by your blog. Is it possible to include this article on one of my blogs?, i will of course link to this page. regards

  22. I’ve just started off a blog, the knowledge you give on this site has aided me extremely. Thank you for all your time & work.

Leave a Reply