Re: mysql insert problem (newbie)
| From: | Becoming Digital | Date: | Sat, 17 May 2003 00:09:31 +0000 |
| Subject: | Re: mysql insert problem (newbie) | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27838@lists.php.net to get a copy of this message | ||
> You should *always* incorporate error checking into your code. It will
> save you a lot of grief in the long run.
This is all-too true with a language as loosely-typed as PHP. A lack of error
checking at this early stage could lead to huge problems on larger projects.
Edward Dudlik
Becoming Digital
www.becomingdigital.com
----- Original Message -----
From: "Jason Wong" <php-db@gremlins.biz>
To: <php-db@lists.php.net>
Sent: Friday, 16 May, 2003 15:32
Subject: Re: [PHP-DB] mysql insert problem (newbie)
On Saturday 17 May 2003 04:37, Damon Hill wrote:
> I actually found my problem a couple of minutes ago.
>
> In this function
>
> function store_data($value, $data, $week)
> {
> global $user;
> global $db_connection;
> $query = "INSERT INTO results (results_id, winner_picked,
> games_id,
> week_number, user_id)
> VALUES('0', '$value', '1', '$week',
> '$user')";
> mysql_query($query, $db_connection);
> return mysql_affected_rows();
> }
>
> I had to add the "global $db_connection" because the $db_connection is
> outside the scope of the function and thus it was not making a
> connection to the database. Once this was changed, all works well.
My reply wasn't to solve your problem, it was to help debug what the problem
is. You should *always* incorporate error checking into your code. It will
save you a lot of grief in the long run.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
Westheimer's Discovery:
A couple of months in the laboratory can frequently save a
couple of hours in the library.
*/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php