且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用php将数据插入到mysql中

更新时间:2023-01-30 22:50:22

尝试执行查询

$mysql="INSERT INTO $tblname(username, messages)
VALUES ('$_POST[username]','$_POST[messages]')";
$return = mysql_query($my_sql);
echo "Message Sent Successfully";

您刚刚忘记执行此插入查询

You just forgotted to execute this insert query

我的建议是不使用mysql_ *函数,因为它们被depricated,使用mysqli_ *函数或PDO语句,并且当您使用post变量时尝试将它们转义为像

And my advice is dont use mysql_* functions as they are depricated,use either mysqli_* functions or PDO Statements,and while you are playing with the post variables try to escape them like

mysql_real_escape_string($_POST['messages']);