RE: [PHP-DB] mysql insert problem (newbie)
| From: | Damon Hill | Date: | Fri, 16 May 2003 20:37:50 +0000 |
| Subject: | RE: [PHP-DB] mysql insert problem (newbie) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27832@lists.php.net to get a copy of this message | ||
Jason--
Thanks for the reply.
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.
Thanks again :-)
~damon
-----Original Message-----
From: Jason Wong [mailto:php-db@gremlins.biz]
Sent: Friday, May 16, 2003 11:32 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] mysql insert problem (newbie)
On Friday 16 May 2003 08:09, M Damon Hill wrote:
> mysql_query($query);
echo $query to check it is correct and:
mysql_query($query) or die(mysql_error());
--
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
------------------------------------------
/*
Staff meeting in the conference room in %d minutes.
*/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php