List:General Discussion« Previous MessageNext Message »
From:Ricardo Dias Marques Date:February 26 2009 6:06pm
Subject:Re: catch the error
View as plain text  
Hi PJ,

On Thu, Feb 26, 2009 at 17:28, PJ <af.gourmet@stripped> wrote:

> What is wrond with this file? same identical insert works from console
> but not from this file :-(
>
> [snip]
>
> <?
> //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();
> }
> ?>

I haven't coded in PHP for a long time, but I think that your problem
is in this line:

$result1 = mysql_query($sql1,$db);

Up to that point, $db (that should point to a database link
identifier) is not defined. You probably want to assign the
"mysql_connect" result to that $db variable.


So, I think that you will solve your problem by changing your
"mysql_connect" line FROM the current form:

mysql_connect('biggie', 'user', 'password', 'test');

.. TO this one:

$db = mysql_connect('biggie', 'user', 'password', 'test');


Am I right?

Cheers,
Ricardo Dias Marques
lists AT ricmarques DOT net
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