I want to send the data inputted into an html form to my sql database, i.e., create a new row attributing certain values to certain columns. I know there are similar questions, I read the answers but nothing seems to work.
send_post.php
//Connecting to sql db.
$connect = mysqli_connect("my host","my user","my passwrod","my db");
//Sending form data to sql db.
mysqli_query($connect,"INSERT INTO posts (category, title, contents, tags)
VALUES ('$_POST[post_category]', '$_POST[post_title]', '$_POST[post_contents]', '$_POST[post_tags]')";
?>
post.html#form
Category:
Post title:
Post tags (a,b,c...):
Post (use html):
my db "posts" table colums:
pid
title
contents
tags
category
pid has auto_increment on
I have already tried sending values to all colunes, including pid, and in the "right" order.
The mysqli_connect part isn't the issue since I copied it from a different .php file of mine that works.
Server php-sql compatibility isn't the issue either, since I successfully had a different .php file retrieve data from the db (data which was manually inserted).
解决方案
change this
to