Re: $query help :(
| From: | Jason Wong | Date: | Thu, 09 Jan 2003 04:20:31 +0000 |
| Subject: | Re: $query help :( | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130864@lists.php.net to get a copy of this message | ||
On Thursday 09 January 2003 08:07, - \[ Paul Ferrie \] - wrote:
> Hi again guys i have run into another problem :(
>
> i am trying to build a user poll (flash+php+mysql)
> I have the interface all sorted but i have a problem with my add new poll
> php file.
> When i hit the update poll button in flash it seem that everthing has work
> and it' send back a msg saying all went well :). but when i check with
> phpmyadmin i see that the $query has been successfully added but the
> "question","opt1","opt2","opt3" fields are blank no
> data added. the only
> fields to be added were the auto_id and date stamp
> below is a sample code of the php file and after that you will see the code
> on the button.
> // Build query to insert new poll
> $query = "INSERT INTO polls (question, option1, option2, option3,
> posted) VALUES ('$quest1', '$opt1', '$opt2', '$opt3',
> $posted)";
>
> // Execute query
> $result = @mysql_query($query);
Before you have your code working 100% correctly you shouldn't be doing
anything that hinders debugging. If you didn't already know, prepending an
'@' on a function call disables any error reporting for that particular call.
> // If query failed...
> if (!$result) {
> // Display error
> print "&result=Could not insert poll";
> } else {
> print "&result=poll created";
> }
>
Those are friendly error messages that are useful _after_ your code is
working. When developing you should always use mysql_error() to see the real
error message.
> I have tried everything i can think of but i cab't seem to get it working.
> Can anyone see anything i am missing?
Always add error checking to your code.
Always have error reporting ON.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
I am having FUN... I wonder if it's NET FUN or GROSS FUN?
*/