mysql insert problem (newbie)

From: Date: Fri, 16 May 2003 00:09:24 +0000
Subject: mysql insert problem (newbie)
Groups: php.db 
Request: Send a blank email to php-db+get-27789@lists.php.net to get a copy of this message
good day... I am a newbie to PHP and MySQL in general so this is probably a relatively easy problem to solve. Here is the code I am trying to execute: function store_data($value, $data, $week) { global $user; mysql_pconnect("localhost", "damon", "damon") or die("Could not connect: " . mysql_error()); $query = "INSERT INTO results (results_id, winner_picked, games_id, week_number, user_id) VALUES('0', '$value', '1', '$week', '$user')"; mysql_query($query); printf ("Records inserted: %d\n", mysql_affected_rows()); } array_walk($picks, 'store_data', $week); I have an array of values, $picks, that I am iterating over and I want to insert each value as a row into the table results. However, every time I try the insert, nothing happens in the database, and the print out is as follows: Records inserted: -1 I know this is something very easy, so any suggestions are greatly appreciated. Thanks in advance. Damon Hill

« previous php.db (#27789) next »