PHP not passing array? maybe newbie question...

From: Date: Mon, 31 Jul 2000 22:09:54 +0000
Subject: PHP not passing array? maybe newbie question...
Groups: php.general 
Request: Send a blank email to php-general+get-9294@lists.php.net to get a copy of this message
Hi All -- Following a printed example in New Rider's MySQL book, I've newbie-hacked my way to the following script. Unfortunately, it is not working and I can't figure out why. Here's the setup: from an php page displaying DB contents and form blanks, you can insert new values into a field called status. The status field is associated with a unique identifier, 'id'. Here is how the status blank is created: $change_stat = sprintf ("<INPUT TYPE=\"text\" NAME=\"status[%s]\"", $row["id"]); $change_stat .= sprintf (" VALUE=\"%s\" DEFAULT=\"%s\" SIZE=\"5\"><BR>",$row["status"], $row["status"]); I enter the new data and hit the 'submit' button on the html form. In theory (and according to New Riders), PHP stuffs everything into an array, here called $status, and passes it to the next sub. PHP begins inserting the new data into the DB with using a while/each line, but goes belly-up after the first bit of data. PHP complains 'data passed to "each" is not an array or object'. Here is the insertion code: while (list ($id, $nu_status) = each ($status)) { $query = "UPDATE result SET status=\"$nu_status\" WHERE id = $id"; if (!mysql_query ($query)) die ("Sorry, data entry failed for id # $id. Please check your entry"); } What is going wrong? It inserts the first row of data without a hitch, but nothing after... Now, I'm sure I botched this someplace, but I can't peg it down. Hope somebody can help... my third cup coffee didn't. =] I'd be happy to give more details if needed. If this is answered someplace like a FAQ or discussion board, please send me a URL! regards, -pt

« previous php.general (#9294) next »