Other people i'v googled with this MySQL error have had restricted words, but I cant see any in mine.
I'm having trouble storing an css div in a variable and inserting it into a table as a field.
I'm very confused because the 2 <br/>
's work perfect, but then it breaks when I try a 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' is a css div( #rptext{stuff;} )
This is the error:
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