Hi all,
Where am I going wrong here? I'm getting a syntax error...

Database ERROR1: 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 '' at line 1

<?php
require_once('Connections/connect.php');
# this is processed when the form is submitted 
# back on to this page (POST METHOD) 
    if ($_SERVER['REQUEST_METHOD'] == "POST")  
    { 
        # escape data and set variables 
        $org = addslashes($_POST["org"]); 
        $type = addslashes($_POST["type"]); 
        $addr1 = addslashes($_POST["addr1"]);
		$addr2 = addslashes($_POST["addr2"]);
		$addr3 = addslashes($_POST["addr3"]);
		$addr4 = addslashes($_POST["addr4"]);
		$addr5 = addslashes($_POST["addr5"]);
		$pcode = addslashes($_POST["pcode"]); 
        $telno = addslashes($_POST["telno"]); 
        $fax = addslashes($_POST["fax"]);
		$web = addslashes($_POST["web"]);
		$notes = addslashes($_POST["notes"]);
		$name = addslashes($_POST["name"]);
		$title = addslashes($_POST["title"]);
		$ext = addslashes($_POST["ext"]); 
        $email = addslashes($_POST["email"]); 
        				
		# setup SQL statement 
$sql  = "INSERT INTO `wkho_users`.`directory` (id, organisation, type, addr1, addr2, addr3, addr4, addr5, pcode, phone, fax, gen_email, other, person, position, ext, pers_email) VALUES ('','$org','$type','$addr1','$addr2','$addr3','$addr4','$addr5','$pcode','$telno','$fax','$web','$notes','$name','$title','$ext','$email'"; 

        #execute SQL statement 
        $result = mysql_query($sql); 

        # check for error 
        if (mysql_error()) { print "Database ERROR1: " . mysql_error(); } 
		
		//message for user
		echo "The details have been posted";
}
?>

It's quite a long sql statement, which makes it that bit more opaque to debug, but seems to be okay?

$sql = "INSERT INTO `wkho_users`.`directory` (id, organisation, type, addr1, addr2, addr3, addr4, addr5, pcode, phone, fax, gen_email, other, person, position, ext, pers_email) VALUES ('','$org','$type', '$addr1','$addr2','$addr3','$addr4','$addr5','$pcode','$telno','$fax','$web','$notes', '$name','$title','$ext','$email'";

Missing ) in the end.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.