You are here: Re: PHP, MySQL, $_GET and If statement problem « PHP Programming Language « IT news, forums, messages
Re: PHP, MySQL, $_GET and If statement problem

Posted by ZeldorBlat on 10/28/47 11:55

mpar612@gmail.com wrote:
> Hi everyone,
>
> I am having a issue that I have been working on for the last few days.
> I am using PHP 5, MySQL 4.1 and PEAR.
>
> The following code works by itself between <?php and ?> tags:
>
> $isbn = $_GET['isbn'];
> $sql = "DELETE FROM lounge WHERE isbn = $isbn";
> $db->query($sql);
> print $sql;
>
> Now, if I put it inside of an If statement, it does not work and I get
> a "DB Error: syntax error":
>
> if ($_POST['yes_no'] == 'yes') {
> $isbn = $_GET['isbn'];
> $sql = "DELETE FROM lounge WHERE isbn = $isbn";
> $db->query($sql);
> print $sql;
> } else {
> print "Unable to delete record";
> }
>
> This isbn is stored as an INT in MySQL. Does anyone have any ideas? I
> would really appreciate any feedback that anyone could give.
>
> Thanks!

Requests are generally made with either GET or POST, but not both. So,
if $_POST['yes_no'] == 'yes' I wouldn't expect there to be any $_GET
variables. Hence, your query, if you echo'ed it out would probably
look something like this:

DELETE FROM lounge WHERE isbn =

which, of course, is not valid SQL.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация