Return statement created by mysqli_stmt_bind_param

I am using mysqli_stmt_bind_param () to create an INSERT statement. For some reason, I am getting an error. I used mysqli_error () to see the error message, but this is not particularly useful.

Is there a way to see which request is actually being executed?

received error:

You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to 'desc, date, expdate, mintix, maxtix, contactname, contactemail, contactphone). VALUES (?' on line 1

+3
source share
2 answers

, mysqli_prepare(), .
, , , ( , .. PHP ).
MySQL, .

edit: , desc - .
( ) . http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

$q = '
  INSERT INTO
    `event`
    (
      `cityid`, `name`, `desc`, `date`,
      `expdate`, `mintix`, `maxtix`,
      `contactname`, `contactemail`, `contactphone`
    )
  VALUES
    (
      ?,?,?,?,
      ?,?,?,
      ?,?,?
    )
';

if ( false===($stmt=mysqli_prepare($dblink, $q)) ) {
  /* 
    in production-code you might not want to reveal
    the error string to each and every user
    ...but for this example and for debugging purposes:
  */
  die('mysqli_prepare failed: '.htmlspecialchars(mysqli_error($dblink)));
}

$rc = mysqli_stmt_bind_param(
  $stmt,
  "issssiisss",
  $city,$name,$desc,$date,
  $expdate,$mintix,$maxtix,
  $contactname,$contactemail,$contactphone
);
if ( false===$rc ) {
  die('mysqli_stmt_bind_param failed: '.htmlspecialchars(mysqli_stmt_error($stmt)));
}


if ( false===mysqli_stmt_execute($stmt) ) {
  die('mysqli_stmt_execute failed: '.htmlspecialchars(mysqli_stmt_error($stmt)));
}

mysqli_stmt_close($stmt);
+2

( !), , , mysqli_report, , .

+2

Source: https://habr.com/ru/post/1738823/


All Articles