Making a local connection between a mysql database and php

Audel picture Audel · Feb 25, 2010 · Viewed 16.4k times · Source

I already have the mysql database made, I just need to connect php to mysql locally but I don't know the php commands for that.

cheers

Answer

casraf picture casraf · Feb 25, 2010
$server = 'localhost';
$user = 'myUser';
$pass = 'myPass';
$dbname = 'MyDatabase';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db($dbname);