Results 1 to 2 of 2

Thread: Help grabbing multiple post value data

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Help grabbing multiple post value data

    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:

    Warning: reset() [function.reset]: Passed variable is not an array or object in
    write.php on line 64
    pointing at this line:

    reset($id); // Set array pointer to first array element

    I am trying to write 23434,34346,34234 from :
    <input type="hidden" name="copy_list" value="23434,34346,34234">
    and write them to mysql.(Note: number of values posted is not know)
    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>

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Help grabbing multiple post value data

    have you tried using the explode() function?
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width