Hi I’m pretty new to all this. I’m trying to create a form to link back to my database but at the moment I keep getting an error about a “Fatal error: Uncaught exception ‘com_exception’ with message 'Source: Microsoft JET Database Engine Description: Syntax error (missing operator) in query expression” around where my Update and Insert SQL statements are.
I’m pretty sure this means I’ve just messed up some of the quotes but I cant seem to work it out, so any help would be appreciated.
Of the 5 Access columns ‘Cust_No’ is an ‘auto number’ field, and all the rest are text.
Here’s the relevant code:
[php]
if ($errorcode==0)
{
if (strlen($Cust_No)>0)
{
$conn=new COM(“ADODB.Connection”) or exit(“Cannot start ADO.”);
$conn->Open(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=”. realpath(“amazonia280.mdb”));
if ($Cust_No=="(System Specified)")
{
$rd=new COM(“ADODB.Recordset”);
$rs->open(“Select Max(Cust_No) as pid From Customer”,$conn);
if ($rs->EOF)
$Customer=“1”;
else if (strlen($rs->Fields[“pid”]->value)>0)
{
$intpart=intval(substr($rs->Fields["pid"]->value,1));
$intpart++;
$Cust_No="".$intpart;
while (strlen($Cust_No)<2)
$Cust_No="0".$Cust_No;
$Cust_No="p".$Cust_No;
}
else
$Cust_No="1";
$rs->close();
$conn->execute ("Insert Into Customer (Cust_No,Cust_Name,Address,email,telno) ".
"Values ($Cust_No,".
"$Cust_Name,".
"$Address,".
"$email,".
"$telno)");
}
else
{
$conn->execute ("Update Customer ".
"Set Cust_Name=".$Cust_Name.",".
"Address=".$Address.",".
"email=".$email.",".
"telno=".$telno." ".
"Where Cust_No=".$Cust_No."");
}
$conn->close();
echo "Saved Customer $Cust_No";
$Cust_No="";
$Cust_Name="";
$Address="";
$email="";
$telno="";
}
}
}
[/php]
Thanks