我用这个 MySQL 错误搜索过的其他人有限制词,但我看不到任何词。
我无法将 css div 存储在变量中并将其作为字段插入表中。
我很困惑,因为 2<br/>
的工作很完美,但是当我尝试使用 div 时它会中断。
userrepost.php
/* Connect and Query database "accounts", then close connection */
$connection=mysql_connect("localhost","root","");
if (!$connection)
{
die('Cannot connect to MySQL. Error: ' . mysql_error());
}
$check_database = mysql_select_db("accounts", $connection);
if (!$check_database)
{
die('Cannot connect to database. Error: ' . mysql_error());
}
/* Escape all POST variables */
$query=mysql_query("SELECT * FROM posts WHERE id='$_GET[postid]'");
$result = mysql_fetch_row($query);
$escaped_repostinfo=$_POST['repostinfo'];
$final_repostinfo=$escaped_repostinfo."<br/><br/><div id='rptext'>".$result[0]." ".$result[1]."</div>";
echo $final_repostinfo;
$date = new DateTime('Canada/Saskatchewan');
$date->setTimezone(new DateTimeZone('Canada/Saskatchewan'));
$date_string=$date->format('d/m/Y H:i:s');
/* Query database to save user's post */
/* If field "repostid==0", then the post is not a repost; if the field "repostid>0", then the post is a repost with the field "repostid" linking to the id of the post to be reposted */
$result = mysql_query("INSERT INTO posts (user, content, repostid, date) VALUES ('$_SESSION[username]', '$final_repostinfo', '$_GET[postid]', '$date_string')");
if (!$result)
{
die('Cannot query. Error: ' . mysql_error());
}
/* Close Connection */
mysql_close($connection);
'rptext' 是一个 CSS div(#rptext{stuff;})
这是错误:
Cannot query. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rptext'>shawn619 dfsd', '51', '09/11/2013 15:27:11')' at line 1