No clue what I am doing wrong. I’m receiving the same error now with the following code and the column ‘last_lead_assigned’ is set to DATETIME:
[COLOR=#000000][FONT=Times New Roman]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 ‘13:07:28 WHERE id=3’ at line 1
[/FONT][/COLOR]
<?php
require_once 'admin/includes/config.php';
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$firstname = $_POST['txtFirstName'];
$lastname = $_POST['txtLastName'];
$email = $_POST['EmailName'];
$telephone1 = $_POST['telephone1'];
$telephone2 = $_POST['telephone2'];
$telephone3 = $_POST['telephone3'];
$date = date("m-d-Y H:i:s");
$assigned_lead = date("Y-m-d H:i:s");
$lead_type = 46;
$contracted = "Not Called";
$telephone = $telephone1."-".$telephone2."-".$telephone3;
$con = mysql_connect("localhost",$dbuser,$dbpass); //database connection
$sql = "
SELECT id FROM users
ORDER BY last_lead_assigned
LIMIT 1
";
$findMarketer = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array( $findMarketer ))
{
$marketer = $row['id'];
}
// Select the database
mysql_select_db($dbname,$con);
// Define the query
$query = "INSERT INTO `lead_details` (
lead_type,
first_name,
last_name,
phone,
email,
date_created,
marketer_id,
contracted,
last_inserted
)
VALUES (
'$lead_type',
'$firstname',
'$lastname',
'$telephone',
'$email',
'$date',
'$marketer',
'$contracted',
'$date'
)";
$last_lead = "
UPDATE `users` SET last_lead_assigned=".$assigned_lead."
WHERE id=".$marketer."";
// Go
$result = mysql_query($query) or die(mysql_error());
$lead_lead = mysql_query($last_lead) or die(mysql_error());
if($result && $lead_lead) {
// If lead was added to database, send notification of lead to marketer.
$to = '';
$subject = 'New Lead - AutoForm';
$headers .= "Reply-To: Free Sales System <>\\r\
";
$headers .= "Return-Path: Free Sales System <>\\r\
";
$headers .= "From: Free Sales System <>\\r\
";
$headers .= "Organization: Sender Organization\\r\
";
$headers .= "MIME-Version: 1.0\\r\
";
$headers .= "Content-type: text/plain; charset=iso-8859-1\\r\
";
$headers .= "X-Priority: 3\\r\
";
$headers .= "X-Mailer: PHP". phpversion() ."\\r\
";
/* BCC LIST */
$headers .= 'Bcc: ' . "\\r\
";
/* CONTENT OF MESSAGE */
$body = "Name: ".$_POST["txtFirstName"]." ".$_POST["txtLastName"]."\
";
$body .= "Email: ".$_POST["EmailName"]."\
";
$body .= "Phone: ".$telephone."\
";
mail($to, $subject, $body, $headers) or die ("Failure");
// Redirect to the page, and let lead have access.
header('Location: ./');
// Close the database connection.
mysql_close();
}
else {
echo("Insert Failed");
}
// End Database Insert & Sending of Email
}
?>
[COLOR=#000000][FONT=Times New Roman]
Yet I am receiving a SQL Error? [/FONT][/COLOR]