Problem with inserting values from html form into mysql table - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: Problem with inserting values from html form into mysql table

  1. #16
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,414
    I still don't understand what this:
    PHP Code:
    $query mysqli_query($connect"SELECT filename,dato,size,spoken,speaker,dialect,project,gender FROM pdb ORDER BY id LIMIT 1") or die (mysqli_connect_error()); 
    $fetch_data mysqli_fetch_array($queryMYSQLI_ASSOC); 

    foreach(
    $fetch_data as $value) { 
      
    $values $_REQUEST[$value]; 

    is supposed to be doing. Can you explain?

    Also, you have done nothing (as far as I can see) to prevent SQL injection and/or SQL errors in regards to sanitizing user-supplied data.

  2. #17
    Senior Member
    Join Date
    Dec 2004
    Posts
    230
    I'll try to explain.

    It should get the column names from my mysql table and echo this as description for the input values. I use $_REQUEST to make the input values globally accessable to the rest of the script. Meaning accessable to the last part of the script (else part).

    The point is to take the user input values and put these into the corresponing mysql table fields. But I don't know if Im doing this correctly.
    It seems to work.

  3. #18
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,414
    That's definitely not what that code snippet is doing at all.

    What it's actually doing is retrieving the first row in the result set of that SELECT query and attempting to use the values of each of the columns as indexes to the $_REQUEST array. So, for example, if you had a row in the DB that looked like:

    Code:
    ('my_file.jpg', 'dato_value_here', 12345, 'spoken_value_here', 'speaker_value_here', ...)
    then you're trying to access the array elements $_REQUEST['my_file.jpg'], $_REQUEST['dato_value_here'], $_REQUEST[12345], etc.

    Not only does that not make any sense, but what you're doing with those nonsensical values doesn't make sense either. This loop:
    PHP Code:
    foreach($fetch_data as $value) { 
      
    $values $_REQUEST[$value]; 

    is constantly overwriting the previous value of the variable $values before you ever do anything with it. Thus, $values will only contain data corresponding to the last value in the $fetch_data array (which means you might as well get rid of the pointless loop and just skip straight to using only that last value).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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