Guys Check this for me

0 Kumi Festus · July 13, 2014
Which is Correct and which is wrong?
This


<?php 

$host = "localhost";
$user = "username";
$pass = "password";
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

?>


Or

<?php 

$host = "localhost";
$user = "username";
$pass = "password";
mysql_connect("$host","$user","$pass") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

?>




Post a Reply

Replies

Oldest  Newest  Rating
+1 Franz Schmidt · July 13, 2014
They are both correct double quotation marks also accept varriables.

Though this is false:

<?php 
$host = "localhost";
$user = "username";
$pass = "password";
mysql_connect('$host','$user','$pass') or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());
?>

Signl quotation marks don't recognize variables.
  • 1

SQL & Databases

106,999 followers
About

Everything SQL and Databases related in here!

Links
Moderators
Bucky Roberts Administrator