mysql_connect("localhost","root")
or die("Unable to connect to MySQL server");
$err = mysql_connect("localhost","root");
if ($err != 0) {
Mysql_connect returns a link to a identifier of the conection, also returns
0 when the conection could not be estabished,
When you do:
$err = mysql_connect("localhost","root");
if ($err != 0) {
echo "Error: Unable to connect to MySQL server ".mysql_error();
}
else{
[code]
}
Is the same that this:
$link = mysql_connect("localhost","root") or die("Unable to connect to
MySQL server ".mysql_error());
[code]
The caluse "or die()" after mysql_connect only will be launched if there is
an error, if not, the script continues its execution.
The $err variable has 0 if there is an error on that conditions.
And yes! Basically both are doing the same thing but if the conextion is
succesfully stablised it will have a link identifier of the conection.
Regards!
Edwin.
-----Mensaje original-----
De: fbsd_user [mailto:[EMAIL PROTECTED]
Enviado el: Sábado, 11 de Marzo de 2006 10:56 a.m.
Para: Mysql
Asunto: mysql_commect or die
mysql_connect("localhost","root")
or die("Unable to connect to MySQL server");
$err mysql_connect("localhost","root");
if ($err != 0) {
Under what conditions will the die clause be taken.
What is in $err if there is a error?
Are these 2 statements basically doing the same thing?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]