这是我的 php:
<?php
require included.php; //which contains the function getpost($post_id)
//once I use the getpost() function below to return a string which is the post
//content, then I can not insert this new row to database.if I change it something
//like $post_content='this is the post content' , it would insert a row to database
$post_content=getpost($post_id);
if($insert=mysql_query("INSERT INTO `join` VALUES('','username','$post_content')"))
{
echo 'ok';
}
else{
echo 'error';
}
?>
这里是included.php中的函数getpost($post_id)
:
function getpost($post_id){
$select_post=mysql_query("SELECT `post_text` FROM `user_post` WHERE `id`='$post_id' ");
return mysql_result($select_post,0,'post_text');
}
这些数据将作为数据发送回 jquery AJAX 请求,如果我回显 $post_content = get_post($post_id)
,我可以提醒正确的内容,使用起来似乎有问题获取帖子内容的函数,然后无法将其插入数据库。
最佳答案
打字错误 -
...INSERT INTO `join` VALUERS('','usern...
^
关于php - 无法向数据库插入新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21646875/