Re: mysql insert problem (newbie)
| From: | Jason Wong | Date: | Fri, 16 May 2003 19:32:03 +0000 |
| Subject: | Re: mysql insert problem (newbie) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27833@lists.php.net to get a copy of this message | ||
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.
*/