R
R
rinaz222020-04-25 16:08:17
PHP
rinaz22, 2020-04-25 16:08:17

How to setup phpMyAdmin autoincrement in Open Server?

Hello! I work with open server and mysql database. I made a base and turned on autoincrement for the id column.
I wanted to write data in this form: '', 'login', 'pass' but the record was not added, the reason is in id when I leave it empty. When I wrote 1 instead of empty quotes, the entry was added. Hosting works.
Here is the PHP code:

mysqli_query($db, "INSERT INTO `users` VALUES('', '$login', '$pass')");

What needs to be configured in Open Server for this code to work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-25
@FanatPHP

Not in Open Server, but in your own code
1. Instead of '', you must write null
2. Never shove variables directly into the request, but pass them separately.
3. In order not to poke your finger into the sky in search of an error, you need to configure error messages in mysqli

$stmt = $db->prepare("INSERT INTO `users` VALUES(null, ?,?)");
$stmt->bid_param("ss", $login, $pass);
$stmt->execute();

How to configure error output and generally connect correctly, see here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question