Re: mysql insert problem (newbie)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux