Hi all. I am using the following php code to grab passed data of post request(<input type="hidden" name="copy_list" value="23434,34346,34234">) and write each value in to mysql db but i keep getting the following error:
pointing at this line:Warning: reset() [function.reset]: Passed variable is not an array or object in
write.php on line 64
reset($id); // Set array pointer to first array element
I am trying to write 23434,34346,34234 from :
and write them to mysql.(Note: number of values posted is not know)<input type="hidden" name="copy_list" value="23434,34346,34234">
I be happy if some one help me grab these data correctly and write them to mysql.Thanks
PHP Code:$id = array();
$amountselected = 0;
$id = $_POST['copy_list'];
echo "$id";
if(!$id == 0)
{
// Find out how many items were selected and protect against no selection
If (is_array($id)) {
$amountselected = count($id);
} Else {
$amountselected = 0;
}
echo "Number value passed:";
echo $amountselected;
echo "<br>";
reset($id); // Set array pointer to first array element
foreach ($id as $addrecid) {
// Build SQL Insert query
$insert = "INSERT INTO test ( SELECT * FROM $s WHERE friendID = '$addrecid')";
echo $insert;
//echo $addrecid;
//echo "<br>";
$addsuccess = mysql_db_query ($dbname, $insert);
If ($addsuccess) {
$howmanynew++;
}
}
If ($amountselected == $howmanynew)
{
?>
<div class="confirmBox">
The selected videos have been copied.
</div>
<?
}
}HTML Code:<form action="./write.php" method=post > <input name="go" type="hidden" value="yes"> <input type="hidden" name="copy_list" value="23434,34346,34234"> <tr> <td width="20%">PlayLists Name: </td> <td width="50%"><input type="text" name="ListName" size="20"> Max 100 Character</td> </tr> <tr> <td colspan=2> <p align="center"><input type="submit" value="Create This PlayList" name="B1"> </td> </tr> </form>


Reply With Quote