Page 1 of 1

Getting Error in Query String

Posted: Fri May 12, 2006 12:58 pm
by snowrhythm
i've got a problem with this query string...

Code: Select all

<?php    

$sqlCommand = "INSERT INTO MachineServiceProfiles (MachineServiceProfileID, Model, SerialNumber, DateMade, DateShipped, WarantyExpireDate, LocationID, CompanyID) VALUES ($machineID, '$machineName', '$serialNum', 'Format(#$dateM#, 'Short Date')', Format(#$dateS#, 'Short Date'), Format(#$dateW#, 'Short Date'), $locationID, $companyID)";  

?>
when i go to execute the string i get this syntax error:

"Syntax error (missing operator) in query expression ''Format(#06/25/2003#, 'Short Date')''., SQL state 37000 in SQLExecDirect"

The weird thing about it is that 'Format(#06/25/2003#, 'Short Date')' works perfectly fine somewhere else in the same file, on the same table.
the only difference is that in the other place where it works i'm only change data, and here i'm adding a new row of data.
any ideas as to what the missing operator is?

thanks

Posted: Fri May 12, 2006 1:03 pm
by $phpNut
I think it is trying to literally send 'Format(...)' to the database.

Try:

Code: Select all

<?php   

$sqlCommand = "INSERT INTO MachineServiceProfiles (MachineServiceProfileID, Model, SerialNumber, DateMade, DateShipped, WarantyExpireDate, LocationID, CompanyID) VALUES ($machineID, '$machineName', '$serialNum', " . Format($dateM, 'Short Date') . ", " . Format($dateS, 'Short Date') . ", " . Format($dateW, 'Short Date') . ", $locationID, $companyID)"; 

?>
Might be best to format the dates to a variables and then put the variables in the $sqlCommand string, less messy.

Posted: Sat May 13, 2006 4:21 pm
by snowrhythm
hey thanks...i'm back at work now (on a saturday) and i'll try that. i'll let you know what happens.