Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a local connection between a mysql database and php

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

like image 632
Audel Avatar asked Feb 25 '10 14:02

Audel


2 Answers

$server = 'localhost';
$user = 'myUser';
$pass = 'myPass';
$dbname = 'MyDatabase';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db($dbname);
like image 56
casraf Avatar answered Nov 20 '22 03:11

casraf


The following contains a pretty good example: http://ca3.php.net/manual/en/mysql.examples-basic.php

like image 1
Dominik Avatar answered Nov 20 '22 03:11

Dominik