RE: [PHP-DB] Parse error: syntax error, unexpected T_ELSE

[email protected] ("Gary Wardell")
Newsgroups php.db
Message-ID <[email protected]>
Hi,

I suggest you echo $del_str to see exactly what your query is.

There may be something unexpected in $_GET['Id'].

Echo the whole query so you can see everything in context.

Gary

> -----Original Message-----
> From: Javier Viegas [mailto:[email protected]]
> Sent: Tue, April 15, 2008 5:56 PM
> To: [email protected]
> Subject: Re: [PHP-DB] Parse error: syntax error, unexpected T_ELSE
>
>
> Thanks Daniel i ´ve removed the unexpected else secction. Now
> it works but
> it tells me that there might be a syntax error on the query,
> this is good
> news because now i know i´m having connection with the
> database but also
> there must be something wrong with the query.
>
> $del_str = "DELETE FROM libros WHERE bnumero=".$_GET['Id'];
>
> Is this correct, i´ve checked and the correct syntax to use
> would be delete
> from libros where bnumero='something';
> Given 'something' is taken from a variable called Id it seems
> reasonable to
> me the way it is written. Do you see anything wrong?
>
> Thanks again.
>
>
> On Tue, Apr 15, 2008 at 6:03 PM, Daniel Brown
> <[email protected]> wrote:
>
> > On Tue, Apr 15, 2008 at 4:49 PM, Javier Viegas
> <[email protected]>
> > wrote:
> > > Hi, i have this script wich basically connects to a
> database and delete
> > a
> > >  record according to the Id parameter given. The problem
> is that when i
> > test
> > >  it i get this error:
> > >
> > >  *Parse error*: syntax error, unexpected T_ELSE in *
> > >  /var/www/biblio/scripts/delete.php* on line *31
> >
> >     Javier,
> >
> >    This block:
> >
> > } else {
> >     $r_string = '&errorcode=4&';
> >
> > }
> >
> >     .... is incorrect.  You call an else condition on line
> 21, so PHP
> > expects that block to be the last for that if() condition.  Either
> > remove the } else { and $r_string = '&errorcode=4&'; lines
> or rewrite
> > the condition.
> >
> >    And if that's your real database login information, change it and
> > update all of your scripts and systems ASAP.
> >
> >
> > >
> > >  This is the script:
> > >
> > >  *<?php
> > >  /*
> > >    deletescore.php:  deletes record for passed id from
> highscores table
> > and
> > >                      returns status to Flash
> > >  */
> > >  // fill with correct data for your server configuration
> > >  $server = "localhost";
> > >  $username = "root";
> > >  $password = "itsveryeasy";
> > >  $database = "biblioteca";
> > >
> > >  //connect to database added by calm
> > >  mysql_connect($server, $username, $password);
> > >
> > >  if (!mysql_connect($server, $username, $password)) {
> > >    $r_string = '&errorcode=1&';
> > >
> > >  } elseif (!mysql_select_db($database)) {
> > >    $r_string = '&errorcode=2&';
> > >
> > >  } else {
> > >
> > >       $del_str = "DELETE FROM libros WHERE bnumero=".$_GET['Id'];
> > >
> > >       if (!mysql_query ($del_str)) {
> > >          $msg = mysql_error();
> > >          $r_string = '&errorcode=3&msg='.$msg;
> > >       } else {
> > >          $r_string = '&errorcode=0&';
> > >       }
> > >    } else {
> > >       $r_string = '&errorcode=4&';
> > >
> > >  }
> > >
> > >  echo $r_string;
> > >  ?>
> > >
> > >  Wha am i doing wrong??
> > >
> > >  Thanks.
> > >
> > >  Javier
> > >
> >
> >
> >
> > --
> > </Daniel P. Brown>
> > Ask me about:
> > Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
> > and shared hosting starting @ $2.50/mo.
> > Unmanaged, managed, and fully-managed!
> >
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.