menthods to connect a database mysql

<?php
$host="localhost";
$user="root";
$pass="";
$db_name="oma";
$con=mysql_connect($host,$user,$pass) or die(mysql_error());
$db=mysql_select_db($db_name,$con);
?>

What is the way you connect your database..?

thnx

<?php
$username="root";
$password="";
$database="wapwap";

$date="test";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "INSERT INTO date VALUES
('','$date')";

mysql_query($query);

mysql_close();
?>

Code With Simple Query..

i am use this code to connection
<?php
mysql_connect('localhost','root','') or die('Not connected to server');
mysql_select_db(db_name) or die('Not selected database');
?>

Use this.

<?php
$username="root";
$password="";
$database="rawr";

$loop=$_POST['loop'];

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "INSERT INTO datemonga VALUES('','$mydate')";

mysql_query($query);

mysql_close();
?>

:P

can u tell me plz what is the meaning of @ befire function @mysql_select_db.
thnx

well, I'm also new to php but basically what i suppose it means something for the database :))... well it works for me so I guess for you also :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.