...

View Full Version : what does this mean?



runeveryday
09-11-2009, 08:49 AM
function mysql_fatal_error($msg)
{
$msg2 - mysql_error();
echo <<< _END
We are sorry, but it was not possible to complete
the requested task. The error message we got was:
<p>$msg: $msg2</p>
Please click the back button on your browser
and try again. If you are still having problems,
please <a href="mailto:admin@server.com">email
our administrator</a>. Thank you.
_END;
}

i konw this is more user-friendly error messages on a production
server.but i don't know the line "$msg2 - mysql_error();"meaning?who can explain it for me.thank you!

Phil Jackson
09-11-2009, 09:03 AM
$msg2 and $msg will be two separate pieces of data sent along with a form or process previous to that script, in case there is an error.

mysql_error() is sent back from the server, as in a global carrier of mySQL errors.

runeveryday
09-11-2009, 10:09 AM
if the connection is fail,what is the result and the value of the variable $msg2 ,$msg ?if i use the parameter $msg . and how to use the function ? is the following right?


<?php
$db_server=mysql_connect($db_hostname,$db_username,$db_password);
if(!$db_server)
function mysql_fatal_error($msg)

digitalzombie
05-03-2010, 07:09 PM
$msg2 - mysql_error();

lol dude it's a typo. You're using the animal guide book right?

You can debug it too. I'll take it step by step after ward.

It's suppose to be;


$msg2 = mysql_error();

Debug:

echo <<< _END
We are sorry, but it was not possible to complete
the requested task. The error message we got was:
<p>$msg: $msg2</p>
Please click the back button on your browser
and try again. If you are still having problems,
please <a href="mailto:admin@server.com">email
our administrator</a>. Thank you.
_END;


If you read the message you can see there's 2 variables in there and the bold variable is the hint that it suppose to be an assignment operator.


I know this is an old thread but I was looking to see how to use this function. I sort of got it but now I need to suppress the warning.

Anyway here's how you suppose to use it:



<?php
//Example 10-2. Connecting to a MySQL database
require_once 'bad_login.php';
$db_server = @mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die(mysql_fatal_error("Unable to connect to MySQL: " ));
function mysql_fatal_error($msg)
{
$msg2 = mysql_error();
echo <<< _END
We are sorry, but it was not possible to complete
the requested task. The error message we got was:
<p>$msg: $msg2</p>
Please click the back button on your browser
and try again. If you are still having problems,
please <a href="mailto:admin@server.com">email
our administrator</a>. Thank you.
_END;
}
?>


The
@ suppresses the mysql function warning.


Here's the errata pages for the book:
http://oreilly.com/catalog/errata.csp?isbn=9780596157142



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum