Go Back   iGuides Webmasters and Business Talk > Web Site Development > Programming Discussion
Register FAQ Rules Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)   Report Post  
Old 10-17-2007, 06:43 PM
iGuides Addict
 
Join Date: Oct 2007
Posts: 83
al-zabir is on a distinguished road
iTrader: (1)
Default Establishing connection with MySQL with PHP

Establishing connection with MySQL with PHP:
==================================
To use MySQL database with your PHP scripting, you must need to establish a connection with database. There are several ways to do it. But, I am explaining here the most simpliest way of connecting with db. Let's assume the filename connect.php

connect.php

Quote:
<?
$dbhost = "localhost";
$dbname = "your_db_name_here";
$dbuser = "db_user_name_here";
$dbpass = "db_password_here";

$con=mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
$db=mysql_select_db($dbname) or die("Could not select db: ".mysql_error());

?>
  • first of all, declare all the variables dbhost,dbname and dbpass. Basically, in local pc, dbhost is always localhost
  • Here mysql_connect() function will create a connection with db
  • and mysql_select_db() function will select the db for connection


Note: For further dealing with db in PHP ( insert, update, delete ), you just have to include the file "connect.php".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)   Report Post  
Old 10-17-2007, 07:01 PM
iGuides's Avatar
Administrator
 
Join Date: Sep 2007
Posts: 1,145
iGuides is on a distinguished road
iTrader: (6)
Default

Thanks for the detailed guide, it will really help gaining more knowledge in programming field.
__________________
"Enhance Online Business with iGuides Webmasters and Business Talk"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)   Report Post  
Old 10-18-2007, 07:18 AM
iGuides Addict
 
Join Date: Oct 2007
Posts: 83
al-zabir is on a distinguished road
iTrader: (1)
Default

Thank you for your feedback admin. I will try to carry on
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)   Report Post  
Old 10-18-2007, 07:37 AM
deluxdon's Avatar
King of the Jungle
 
Join Date: Oct 2007
Location: www.travelwitheaseblog.com
Posts: 1,387
deluxdon will become famous soon enough
iTrader: (4)
Default

Thanks for sharing this info though i am still learing about php thingy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)   Report Post  
Old 10-20-2007, 04:15 AM
Zafar Ahmed's Avatar
Administrator
 
Join Date: Sep 2007
Posts: 1,254
Zafar Ahmed will become famous soon enough
iTrader: (2)
Send a message via MSN to Zafar Ahmed
Default

I am always willing to learn about databases, thank you for the information. However, you have not mentioned anything about Apache.
__________________
SEO Services & eMarketing Consultant
Online Workforce Training
"Enhance Online Business with iGuides Webmasters and Business Talk"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)   Report Post  
Old 10-20-2007, 08:10 AM
iGuides Addict
 
Join Date: Oct 2007
Posts: 83
al-zabir is on a distinguished road
iTrader: (1)
Default

Quote:
Originally Posted by Zafar Ahmed View Post
I am always willing to learn about databases, thank you for the information. However, you have not mentioned anything about Apache.
Apache is a web server which is designed to run server-side language like PHP, ASP ( Apache2 is needed ), ASP.NET ( Apache2 is needed ) with mySQL, pgSQL databases. To run Apache with PHP and mySQL. You have to install Apache, PHP and MySQL individually and then configure it. But, I will not go for that way. Because, now there are so many software bundle that installs all the three things ( Apache, PHP and MySQL ) at the same time and there is no need to configure it anymore. Following are some such bundles that you can download for free. Just Download and install it.

Apache2Triad
Apache2Triad Net

XAMPP
apache friends - xampp

PHP Triad
SourceForge.net: PHP Triad for Windows


Thanks to all
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)   Report Post  
Old 10-21-2007, 11:20 PM
Zafar Ahmed's Avatar
Administrator
 
Join Date: Sep 2007
Posts: 1,254
Zafar Ahmed will become famous soon enough
iTrader: (2)
Send a message via MSN to Zafar Ahmed
Default

Quote:
Originally Posted by al-zabir View Post
Apache is a web server which is designed to run server-side language like PHP, ASP ( Apache2 is needed ), ASP.NET ( Apache2 is needed ) with mySQL, pgSQL databases. To run Apache with PHP and mySQL. You have to install Apache, PHP and MySQL individually and then configure it. But, I will not go for that way. Because, now there are so many software bundle that installs all the three things ( Apache, PHP and MySQL ) at the same time and there is no need to configure it anymore. Following are some such bundles that you can download for free. Just Download and install it.

Apache2Triad
Apache2Triad Net

XAMPP
apache friends - xampp

PHP Triad
SourceForge.net: PHP Triad for Windows


Thanks to all
Do you have these softwares which installs Apache, PHP and MySQL at the same time and I don't have to configure them out. The download links you gave me seems like its a link to each Individuals.
__________________
SEO Services & eMarketing Consultant
Online Workforce Training
"Enhance Online Business with iGuides Webmasters and Business Talk"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)   Report Post  
Old 10-22-2007, 06:29 AM
iGuides Addict
 
Join Date: Oct 2007
Posts: 83
al-zabir is on a distinguished road
iTrader: (1)
Default

No, Those are not links to each individuals. All of the above three softwares will install Apache, PHP and MySQL at the same time and you don't have to configure them out. Just choose any one of them and feel free to download and install. i will recommend the first one.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:54 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0

Ad Management by RedTyger