0

I tried lot of thinks to resolve the error in the title.

I don't know why but this code generate an Error 500

$sql = 'INSERT INTO compte (creationdate, password, photo, mail) VALUES (NOW(), "$2y$10$60y2xoq8y1E5wNOmrI.V9umrp4br2cJ3iZS5MVNNXGkFvMq8Pgxmy", "images_utilisateurs/PP.jpg", "blabla@gmail.com")';

        try {
            $mysqli->query($sql);
            $mysqli->commit();
        } catch (Exception $e) {

            $mysqli->rollback();

        }

have no issue to show the data from my database but in insertion, it's impossible. The issus is only in the try catch block

EDIT :

Here my connexion script:

    $mysqli = mysqli_init();
if (!$mysqli) {
    die('mysqli_init failed');
}
if (!$mysqli->real_connect('localhost', 'root', 'root', 'allvisio')) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}

I have no error here in php.ini, I'm using the default value...

Thanks for any support

EDIT 2 : SOLUTION

By hasard (like sometime) I found the solution I'm using function to do my request, so we need to declare global $mysqli; each time a want to request into my database. easy, but not clear.

Thomas Dupont
  • 417
  • 6
  • 20
  • we'll need more information than that. What does the exact error says ? Do you have other queries that work ? Are you connected to you database ? – Unex May 11 '16 at 15:17
  • 1
    Try setting `error_reporting(E_ALL)`, run your script, then check the server logs. – Mr. Llama May 11 '16 at 15:18
  • Any error report more descriptive than _internal server error_? :) – Asur May 11 '16 at 15:19
  • `password` is a [MySQL reserved word](https://dev.mysql.com/doc/refman/5.5/en/keywords.html), so wrap your column names with backticks, like this: `...'INSERT INTO compte (\`creationdate\`, \`password\`, \`photo\`, \`mail\`) VALUES ...` – Rajdeep Paul May 11 '16 at 15:22
  • Hello There are nothing with error_reporting and the request works in phpmyadmin. I edit my connexion script and php mysqli config. – Thomas Dupont May 11 '16 at 15:45

0 Answers0