IT.COM

Connect to a mysql Database using php

Spaceship Spaceship
Watch
Impact
20
PHP:
<?

$username = "username";
$password ="password";
$db = "db";

$conn = mysql_connect("localhost", "$username", "$password") or die(mysql_error());

mysql_select_db("$db", $conn) or die (mysql_error());


?>

Once you have php,mysql working you can add this to a php file to use the database

you may also need other tools such as phpmyadmin www.phpmyadmin.net to help generate the mysql queries and make/delete/edit/change databases
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Nice one! That was a definite needed code snippet around here. ... Thanks for sharing. :D
 
0
•••
:)

surprised it wasnt already here
 
0
•••
I am saving this page in my "Cool Sites" guide :D, cool reference if your in a hurry.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back