List:General Discussion« Previous MessageNext Message »
From:PJ Date:February 26 2009 6:56pm
Subject:Re: catch the error
View as plain text  
Jerry Schwartz wrote:
>   
>> -----Original Message-----
>> From: PJ [mailto:af.gourmet@stripped]
>> Sent: Thursday, February 26, 2009 12:28 PM
>> To: php-general@stripped; MySql
>> Subject: catch the error
>>
>> What is wrond with this file? same identical insert works from console
>> but not from this file :-(
>>
>> <html>
>> <head>
>>    <title>Untitled</title>
>> </head>
>>
>> <body>
>> <?
>> //include ("lib/db1.php");    // Connect to database
>> mysql_connect('biggie', 'user', 'password', 'test');
>> $sql1 = "INSERT INTO example (name, age) VALUES ('Joe Blow', '69')";
>> $result1 = mysql_query($sql1,$db);
>> if (!$result1) {
>>  echo("<P>Error performing 1st query: " .
>>       mysql_error() . "</P>");
>>  exit();
>> }
>> ?>
>>
>> </body>
>> </html>
>>
>> Seems to be good to print out the error message, but that's all. db not
>> written.
>>
>>     
> [JS] You need
>
>   $db = mysql_connect('biggie', 'user', 'password', 'test');
>
>   
>> --
>>
>> Phil Jourdan --- pj@stripped
>>   http://www.ptahhotep.com
>>   http://www.chiccantine.com
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>> infoshop.com
>>     
>
>
>
>
>
>   
I think the problem here has been that this is such a basic operation
and most of us just are too busy with more complicated stuff...that we
didn't catch it...

<?
//include ("../lib/db1.php");    // Connect to database

$db_host = 'xxxx';
$db_user = 'xxxx';
$db_pass = 'xxxx';
$db_name = 'xxxx';


$db = mysql_connect($db_host, $db_user, $db_pass);   
mysql_select_db($db_name,$db);

$sql1 = "INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75')";
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo("<P>Error performing 3st query: " .
       mysql_error() . "</P>");
 
}
echo $sql1;
echo "<br />";
echo $db_select;
exit();
?>
anyway, I am learning a lot...
thanks, guys... you're all great...
I have lots more coming...  :-D

-- 

Phil Jourdan --- pj@stripped
   http://www.ptahhotep.com
   http://www.chiccantine.com

Thread
catch the errorPJ26 Feb
  • Re: catch the errorDarryle Steplight26 Feb
    • Re: catch the errorPJ26 Feb
      • Re: catch the errorJim Lyons26 Feb
        • Re: catch the errorPJ26 Feb
      • Re: catch the errorDarryle Steplight26 Feb
        • Re: catch the errorPJ26 Feb
  • Re: catch the errorRicardo Dias Marques26 Feb
    • Re: catch the errorPJ26 Feb
      • Re: catch the errorDarryle Steplight26 Feb
  • RE: catch the errorJerry Schwartz26 Feb
    • Re: catch the errorPJ26 Feb
  • Re: catch the error [OFF TOPIC]Claudio Nanni26 Feb