Assigning Form Data To Different User ID Each Time?

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



require_once 'admin/includes/config.php';

    $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
            // Define the query
            $query = "INSERT INTO `lead_details` (
            VALUES (
            $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.
            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]

I’m not sure it’ll make all that much difference, but you could try altering your UPDATE statement to this:

$last_lead = "UPDATE `users` SET last_lead_assigned = NOW() WHERE id = ".$marketer;

(NOW() is a MySQL function that outputs the current datetime.)

Yeah I ended up saying screw it and just went with now() a while ago and it works perfectly. The system and lead distribution is working just as I wanted it. Thanks to everyone for helping me brainstorm and solve this puzzle of mine. Exactly why I love communities like this!