views:

73

answers:

4

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

A: 

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

Dominik
A: 

Search for some tutorials on the subject. Here is one:

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/connect-to-mysql-database.aspx

ar
+1  A: 
$server = 'localhost';
$user = 'myUser';
$pass = 'myPass';
$dbname = 'MyDatabase';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db($dbname);
henasraf
yes, I understand that, what i can't find are the localhost and user names. when i log into mysql it just asks me for the password
Audel
Your server installation or docs should tell you that -- the host is most likely `localhost`, though not 100% of the times; as for the username, if you haven't defined it, try `root` or something global you use around your server,
henasraf
A: 

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";
?>
streetparade