> -----Original Message-----
> From: Scott Taylor [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 22, 2001 6:46 PM
> To: [EMAIL PROTECTED]
> Subject: Debug help
> 
> 
> Hi all,
> I snatched this guest book off some script site 

Be careful. A lot of that stuff on "script sites" is pure crapola.

> and it's 
> either gone now, 
> or I misplaced the bookmark, but anyhow, perhaps someone can 
> help me with 
> the syntax.  Something I changed at 3AM one morning now it 
> doesn't work 
> right

Use RCS, CVS, or something. Make backups.

> , I know the MySQL parameters are fine, it's something I 
> accidently 
> deleted in here.
> $success returns this value: DBI::st=HASH(0x81a8280) at the line 
> if($success != 1) ...

Well, $success is the return from prepare(), which is a statement
handle. Why would you compare a statement handle to a 1?

> can anyone point out my obvious mistake?

Calling the handle "$success" implies that you mean for this
variable to be the result of the execute() method.

Read the DBI docs to see what prepare() and execute() return.

Note that the return of prepare() is not checked. You might
want to do that, otherwise the execute() call will barf ungracefully.

> 
> sub insert_entry {
>      my ($dbh, $success, $name, $email, $website, $comments,$time);
> 
>      $dbh = DBI->connect("DBI:mysql:database=$serverDb;
>                           
> host=$serverName;port=$serverPort",$serverUser,$serverPass);
>      $name = param("name");
>      $email = param("email");
>      $website = param("website");
>      $comments = param("comments");
>      $time = time;
>      $SQL = "INSERT INTO $serverTabl(name,email,website,comments,time)
>                VALUES(?, ?, ?, ?, ?)", undef, $name, 
> $email,$website,$comments,$time;
>      $success = $dbh->prepare($SQL);
>      $success->execute;
>      $dbh->disconnect;
>      if($success != 1) {
>           return "$success Sorry, the database was unable to 
> add your entry.
>                    Please try again later."
>      } else {
>      return;
>      }
> }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to