Can someone spot the mistake:
mysqli_query($connection, "INSERT INTO comments (event_id, fulltext, date_posted) VALUES (5, 'Hallo', 430234)");
The connection is established, but it just doesn't insert a new row.
include("../../connect.php");
$event_id = intval($_GET["event_id"]);
$fulltext = $_GET["fulltext"];
$date = intval($_GET["date"]);
mysqli_query($connection, "INSERT INTO comments ('event_id', 'fulltext', 'date_posted') VALUES (5, 'Hallo', 430234)");
echo "INSERT INTO comments (event_id, fulltext, date_posted) VALUES (5, 'Hallo', 430234)";
mysqli_close($connection);
When inserting a single row into the MySQL table, the syntax is as follows: INSERT INTO table_name(column_1,column_2,column_3) VALUES (value_1,value_2,value_3); In the INSERT INTO query, you should specify the following information: table_name : A MySQL table to which you want to add a new row.
Inserting Multiple Rows into a Table. One can also insert multiple rows into a table with a single insert query at once. To do this, include multiple lists of column values within the INSERT INTO statement, where column values for each row must be enclosed within parentheses and separated by a comma.
Using the PHP MySQL to MySQLi Migration PackagePHP MySQL to MySQLi is package that emulates the mysql extension functions using the mysqli extension. It uses these replacement code solutions and can act as a stop-gap while you work on migrating your code.
To insert a row into a table, you need to specify three things: First, the table, which you want to insert a new row, in the INSERT INTO clause. Second, a comma-separated list of columns in the table surrounded by parentheses. Third, a comma-separated list of values surrounded by parentheses in the VALUES clause.
FULLTEXT is reserved word in mysql you can't use it as column name use below query with `
around column name
mysqli_query($connection, "INSERT INTO comments
(`event_id`, `fulltext`, `date_posted`) VALUES (5, 'Hallo', 430234)");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With