IT.COM

Php with Mysql connection

Spaceship Spaceship
Watch
Hi,
I am looking for connection of PHP with mysql.
can any body send me coding of simple connection.
How to connect mysql.

Thanks...
 
Last edited by a moderator:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
3
•••
Before you can access data in a database, you must create a connection to the database.
In PHP, this is done with the mysql_connect () function.
Syntax:
<?php
$con = mysql_connect(""localhost"",""peter"",""abc123"");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// some code
?>?>
 
0
•••
PHP:
$dbname 	= '';
$dbuser 	= '';
$dbpass 	= '';
$dbhost 	= 'localhost';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or exit(mysql_error());
mysql_select_db($dbname, $conn) or exit(mysql_error());
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back