我想将输入的数据以html格式发送到我的sql数据库,即创建一个新的行,将某些值赋予某些列。我知道有类似的问题,我读了答案,但似乎没有任何工作。通过PHP发送html格式数据到sql数据库(使用mysqli)
send_post.php
<?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 onSubmit="send_post.php" method="post">
<h3>Category:</h3>
<input type="text" name="post_category">
<h3>Post title:</h3>
<input type="text" name="post_title">
<h3>Post tags (a,b,c...):</h3>
<input type="text" name="post_tags">
<h3>Post (use html):</h3>
<textarea rows="20" cols="50" name="post_contents"></textarea>
<input type="submit">
</form>
我的数据库 “的帖子” 表colums:
pid
title
contents
tags
category
pid
有auto_increment
上
我已经尝试将值发送到所有分支,包括pid
,并按“正确”顺序发送。
mysqli_connect
部分不是问题,因为我从我的另一个.php文件复制它的作品。
服务器php-sql的兼容性也不是问题,因为我成功地有一个不同的.php文件从数据库中检索数据(手动插入的数据)。
当你说什么都没有工作,什么是不工作?你得到一个错误,数据库中的错误数据等? – 2013-03-11 05:03:16
我的意思是没有任何解决方案提供的答案来自不同的问题。我没有收到错误输出。 – Alex 2013-03-11 05:08:57