Re: Re: catch the error
| From: | Andrew Ballard | Date: | Thu, 26 Feb 2009 18:29:00 +0000 |
| Subject: | Re: Re: catch the error | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288849@lists.php.net to get a copy of this message | ||
What does this output?
<?
//include ("../lib/db1.php"); // Connect to database
$db_host = 'biggie';
$db_user = 'root';
$db_pass = 'gugus@#$';
$db_name = 'biblane';
$db_connect = mysql_connect($db_host, $db_user, $db_pass);
if (!is_resource($db_connect)) {
echo '<p>$db_connect is not a valid resource: ' . mysql_error() .
'</p>';
exit();
}
if (!mysql_select_db($db_name, $db_connect)) {
echo "<p>Unable to select $db_name: " . mysql_error() . '</p>';
exit();
}
$sql1 = "INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75')";
$result1 = mysql_query($sql1,$db);
if (!is_resource($result1)) {
echo "<p>Error performing 1st query: " . mysql_error() . "</p>";
exit();
} else {
echo '<p>' . mysql_affected_rows() . 'row(s) affected by last
statement</p>';
exit();
}
?>
Andrew