Syntax Error

[php]<?php

include(“connect.php”);

$content = ‘’;
if(isset($_POST[‘submit’])){
$title = $_POST[“title”];
$name = $_POST[“name”];
$message = $_POST[“content”];
$query = mysql_query(“INSERT INTO ‘Contact’ (id, title, name, content)
VALUES (’’,’$title’,’$name’,’$message’)”);
if($query){
$content = ‘Successfully contacted the Eternal Power Staff!’;
}
else
{
$content = 'For some reason your message was not sent!

’ . mysql_error();
}
}
else
{
$content = ’

Title: 
Name:
Message:
'; }

?>[/php]

Everytime I submit the form, I get an error:

For some reason your message was not sent!

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 ‘‘Contact’ (id, title, name, content) \ VALUES (’’,‘Test Title’,‘Liam Ho’ at line 1

PHP Version: 5.3.5
MySQL Version: 5.5.8
Apache Version: 2.2.17

Hi there,

Try changing the query to:
[php]mysql_query(“INSERT INTO Contact (title, name, content) VALUES (’”.$title."’,’".$name."’,’".$message."’)");[/php]

Oh, and make sure that the table is definitely “Contact” with the capital C.

Tried that, it still producing the same error. It’s annoying as I don’t see anything wrong with the code. :frowning:

[php]
$query = mysql_query("INSERT INTO Contact (title, name, content) VALUES (’$title’, ‘$name’, ‘$message’) "); [/php]

Maybe this?
[php]mysql_query(“INSERT INTO Contact (title, name, content) VALUES (’”.mysql_real_escape_string($title)."’,’".mysql_real_escape_string($name)."’,’".mysql_real_escape_string($message)."’)");[/php]

Nope that’s not working either it’s weird.

Still not working. :confused:

Nevermind fixed it.

Sponsor our Newsletter | Privacy Policy | Terms of Service