0

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

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

5
Contributors
6
Replies
8
Views
7 Years
Discussion Span
Last Post by ekseks
0
<?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..

Edited by Ankit_Parmar: n/a

0

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');
?>

Edited by manzarr: n/a

0

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

0

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

0

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 :)

Edited by ekseks: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.