Reply to Re: [PHP] Should this not return true?!?!

Your name:

Reply:


Posted by "Richard Lynch" on 05/21/05 03:45

On Fri, May 20, 2005 1:53 pm, Dustin Krysak said:
> Hi there (newbie here) - I have the following snippet of code......
>
> $sexId = $_POST['sex'];
> $fName = $_POST['fName'];
> $lName = $_POST['lName'];
>
> if ($status = $db->query("INSERT INTO names (nameId, sexId, fName,
> lName) VALUES ('', $sexId, '$fName', '$lName')")) {
> print "Your data was added to the database successfully!";
> } else {
> print "Your data could not be added to the database!";
> }
>
> Assuming my query was successful, should it not return true and print
> the success message?

How would we know? :-)

Of the 10,000 PHP Database Abstraction classes out there, you haven't told
us which one you are using.

So there is *NO* *WAY* to tell what the query() method returns, is there?

Actually, you don't even tell us which DATABASE you are using, so while I
say MySQL below, I mean "whatever database you are using"

When it *DOES* fail, why don't you log the error message MySQL provides?
error_log(@mysql_error());

Only, most likely, the database abstraction layer you haven't told us
about has some fancy method to get that information.

> For some reason it is doing just the opposite. The data is added, but
> it displays the error instead.

Then, most likely, the particular database abstraction layer you have
chosen doesn't work the same way as mysql_query(). So you have to adjust
your code to work with the API of that database abstraction layer, which
we can't possibly begin to tell you how to do, since we don't know what
database abstraction software you are using.

> Am I misunderstanding something?

Definitely how to ask a good question :-)

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original 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

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