mysql insert problem (newbie)

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

 



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



-- 
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