#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0

    thanks to Shiju for this code, inserting array from form into database. But it give an 'no such index in string error'. I tried $bands[]=HTTP_POST_VARS[band]; and all it does is insert the last value of the array

    Garrick

    $bands=$HTTP_POST_VARS[band];
    $days=$HTTP_POST_VARS[day];


    for($a=0;$a<count($bands);$a++){

    $query="INSERT INTO tbl set day='$days[$a]',band='$bands[$a]'";

    mysql_query($query,$connection);


    }

  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    HTTP_POST_VARS[band] and [day] are not arrays so $bands and $days will not be arrays. Count will work (returns 1 for non-arrays) but you can't refer to them with an index.

Similar Threads

  1. Problems inserting a dropdownlist value into a database
    By ml3bf in forum .Net Development
    Replies: 0
    Last Post: February 16th, 2004, 04:51 AM
  2. Inserting checkbox values from an array into MySQL
    By outlyr242 in forum PHP Development
    Replies: 1
    Last Post: February 9th, 2004, 04:28 PM
  3. Writing array of random numbers to a database
    By Beda in forum ASP Programming
    Replies: 2
    Last Post: February 2nd, 2004, 03:34 PM
  4. Inserting text into a database
    By icecubes7 in forum PHP Development
    Replies: 3
    Last Post: January 15th, 2004, 02:05 PM
  5. Inserting each word in a string into the database
    By BenS in forum PHP Development
    Replies: 2
    Last Post: January 1st, 2004, 01:56 PM

IMN logo majestic logo threadwatch logo seochat tools logo