Re: Re: catch the error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux