sql >> Database >  >> RDS >> Mysql

alle $_POST-gegevens in mysql invoegen met behulp van PHP?

Mijn functie hiervoor:

function i($table, $array) {
  $query = "INSERT INTO ".$table;
  $fis = array(); 
  $vas = array();
  foreach($array as $field=>$val) {
    $fis[] = "`$field`"; //you must verify keys of array outside of function;
                         //unknown keys will cause mysql errors;
                         //there is also sql injection risc;
    $vas[] = "'".mysql_real_escape_string($val)."'";
  }
  $query .= " (".implode(", ", $fis).") VALUES (".implode(", ", $vas).")";
  if (mysql_query($query))
    return mysql_insert_id();
  else return false;
}


  1. Hoe maak je een PL/SQL-functie in Oracle Database?

  2. Slechte tekens bij het afdrukken van tekst uit utf8_unicode_ci Mysql-tabel

  3. Gem. inconsistentie float

  4. SQLskills Wait Types Library toont nu SentryOne-gegevens