html通过php获取mysql数据,通过PHP发送html格式数据到sql数据库(使用mysqli)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值