problem for inserting forms text values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kindermaxiz@yahoo.com

    problem for inserting forms text values

    hey all:
    I do a loop that creates text forms on the fly kinda like this:

    for (i,i<=$x,i++)(
    echo "<input type=text name=$forname> <br>"
    $values .= "$forname,"

    )

    echo "<input form type=submit name="submit">"

    then

    if ($submit)
    //to get rid of the last comma:
    $myvalues= str_replace($va lues,-1)
    //i use a function to get the $namesofcolumns but im in a netcafe
    right now so...
    mysql_query(ins ert into blabla ($namesofcolumn s) values ($myvalues);

    the problem is that the insert works but only null values get
    inserted, how can I do that?

    thanx in advance
  • kingofkolt

    #2
    Re: problem for inserting forms text values

    <kindermaxiz@ya hoo.com> wrote in message
    news:39615087.0 408261928.346ac e59@posting.goo gle.com...[color=blue]
    > hey all:
    > I do a loop that creates text forms on the fly kinda like this:
    >
    > for (i,i<=$x,i++)(
    > echo "<input type=text name=$forname> <br>"
    > $values .= "$forname,"
    >
    > )
    >
    > echo "<input form type=submit name="submit">"
    >
    > then
    >
    > if ($submit)
    > //to get rid of the last comma:
    > $myvalues= str_replace($va lues,-1)
    > //i use a function to get the $namesofcolumns but im in a netcafe
    > right now so...
    > mysql_query(ins ert into blabla ($namesofcolumn s) values ($myvalues);
    >
    > the problem is that the insert works but only null values get
    > inserted, how can I do that?
    >
    > thanx in advance[/color]

    I didn't see enough of your code to know for sure that this is the case, but
    I'm guessing you're working on the assumption that register_global s in
    php.ini is set to On. The best policy to go by is to use $_POST['somevar']
    instead of $somevar, as that will be more reliable. For example, your line
    "if ($submit)" should be "if ($_POST['submit'])". Or actually, "if
    (isset($_POST['submit']))" for good measure...

    - JP


    Comment

    • kindermaxiz@yahoo.com

      #3
      Re: problem for inserting forms text values

      ok this is my code, when I try to insert the values I get 1,2,3,4 etc
      instead of what is entered in the form, can u tell me where is my
      mistake please and how to solve the whole thing pease?

      gracias


      if ($material_to_b e_added==$j)
      {
      $resultprod = $sqlquery ("describe $tabname");
      echo "<form method=\"post\" action=$php_sel f>";
      while($row = $sqlfetcharray( $resultprod)) {
      $col_name = $row['Field'];
      $null_value = $row['Null'];
      $translated_col name = 'translation_'. $col_name ;
      $dispayed_colna me = ${$translated_c olname};

      if ($col_name=='id ' || $null_value=='Y ES')
      echo "";
      else {echo "<br>$dispayed_ colname:<BR><IN PUT TYPE=\"TEXT\"
      NAME=\"$k\" SIZE=\"40\">";
      $col_to_insert .= "$col_name, ";
      $cols_to_insert = substr_replace( $col_to_insert, '',-1);
      $val_to_insert .= "$k,";
      $vals_to_insert = substr_replace( $val_to_insert, '',-1);
      $k = $k +1;
      }
      }
      echo "<p><input type=\"submit\" name=\"submit\" value=\"$submit \">
      </form><p> $cols_to_insert <p> $vals_to_insert ";
      if ($submit) {
      $result=$sqlque ry("INSERT INTO $tabname($cols_ to_insert)".
      "VALUES ($vals_to_inser t)");
      }
      }


      "kingofkolt " <jessepNOSPAM@c omcast.net> wrote in message news:<ppyXc.322 092$%_6.188275@ attbi_s01>...[color=blue]
      > <kindermaxiz@ya hoo.com> wrote in message
      > news:39615087.0 408261928.346ac e59@posting.goo gle.com...[color=green]
      > > hey all:
      > > I do a loop that creates text forms on the fly kinda like this:
      > >
      > > for (i,i<=$x,i++)(
      > > echo "<input type=text name=$forname> <br>"
      > > $values .= "$forname,"
      > >
      > > )
      > >
      > > echo "<input form type=submit name="submit">"
      > >
      > > then
      > >
      > > if ($submit)
      > > //to get rid of the last comma:
      > > $myvalues= str_replace($va lues,-1)
      > > //i use a function to get the $namesofcolumns but im in a netcafe
      > > right now so...
      > > mysql_query(ins ert into blabla ($namesofcolumn s) values ($myvalues);
      > >
      > > the problem is that the insert works but only null values get
      > > inserted, how can I do that?
      > >
      > > thanx in advance[/color]
      >
      > I didn't see enough of your code to know for sure that this is the case, but
      > I'm guessing you're working on the assumption that register_global s in
      > php.ini is set to On. The best policy to go by is to use $_POST['somevar']
      > instead of $somevar, as that will be more reliable. For example, your line
      > "if ($submit)" should be "if ($_POST['submit'])". Or actually, "if
      > (isset($_POST['submit']))" for good measure...
      >
      > - JP[/color]

      Comment

      Working...