Reputation: 2509
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
Upvotes: 5
Views: 16956
Reputation: 32888
This is a simple connect to the mysql server. After Connecting to the server it selects a DB
<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>
Upvotes: 1
Reputation: 21694
$server = 'localhost';
$user = 'myUser';
$pass = 'myPass';
$dbname = 'MyDatabase';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db($dbname);
Upvotes: 6
Reputation: 1202
The following contains a pretty good example: https://www.php.net/manual/en/mysql.examples-basic.php
Upvotes: 1