Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Tentando postar apenas uma única coluna no banco de dados


Tente usar variáveis ​​de ligação e instruções preparadas:
<?php
$mysqli = new mysqli("localhost", "user", "pass", "db");

/* check connection */
if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
}

if (isset($_POST['scriptname'])) {
  $scriptname = $_POST['scriptname'];

  $stmt = $mysqli->prepare("INSERT INTO appslist(listall) VALUES (?)");
  $stmt->bind_param('s', $scriptname);

  /* execute prepared statement */
  $stmt->execute();

  printf("%d Row inserted.\n", $stmt->affected_rows);

  /* close statement and connection */
  $stmt->close();
 }
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
   Script Name: <input type="text" name="scriptname">
   <input type="submit">
</form>

Saída:
1 Row inserted.

http://php.net/manual/en/mysqli.quickstart .prepared-statements.php