Connect to MySQL through PHP
|
02-11-2012, 07:41 PM
Post: #1
|
|||
|
|||
Connect to MySQL through PHP
Interacting with MySQL makes PHP a far more powerful tool. In this tutorial we will go through some of the most common ways PHP interacts with MySQL. To follow along with what we are doing, you will need to create a database table by executing this command:
Code: CREATE TABLE friends (name VARCHAR(30), fav_color VARCHAR(30), fav_food VARCHAR(30), pet VARCHAR(30)); INSERT INTO friends VALUES ( "Rose", "Pink", "Tacos", "Cat" ), ( "Bradley", "Blue", "Potatoes", "Frog" ), ( "Marie", "Black", "Popcorn", "Dog" ), ( "Ann", "Orange", "Soup", "Cat" ) This will create a table for us to work with, that has friends' names, favorite colors, favorite foods, and pets. The first thing we need to do in our PHP file is connect to the database. We do that using this code: Code: <?php // Connects to your Database mysql_connect("your. hostaddress. com", "username", "password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error()); ?> Of course you will replace server, username, password, and Database_Name with the information relevant to your site. If you are unsure what these values are, contact your hosting provider. website design perth| website design and development perth|website design development perth |
|||
08-29-2012, 12:16 AM
Post: #2
|
|||
|
|||
RE: Connect to MySQL through PHP
this is very helpful post u have cool share
android update| iphone updates| samsung android phones| |
|||
05-23-2013, 08:20 PM
Post: #3
|
|||
|
|||
RE: Connect to MySQL through PHP
Thanks for sharing informative post. It's really helpful for us when i connect mysql through php.
Quality software development in milton Keynes from Sabizuk |
|||
05-20-2016, 08:44 PM
Post: #4
|
|||
|
|||
RE: Connect to MySQL through PHP
Nice post. Thanks for share
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)