I need to check if a record exists, and depending on whether the outcome is true or false carry out one or another queries.
Check tblResults to see if there is a record which has $DateLogRef and $MachineRef - if it is true do 'x' - if false do 'y'.
I am going round in circles trying to get the syntax right, I only get error messages saying things like
Parse error: syntax error, unexpected T_STRING, expecting '(' in /readings/process_readings.php on line 177 -which is IF Exists ($DateLogRef, $MachineRef) - , I don't get as far as any other type of error message to say whether the code actually does what I want it to....
Any help in getting the syntax write first of all would be appreciated, plus any general advice on Exists would be fantastic as this is all new to me.
code I have so far
$query = "SELECT `DateLogRef`, `MachineRef` FROM `tblResults` WHERE ClientRef=$ClientRef";
$result94 = mysql_query($query)
or die (mysql_error());
while ($row94 = mysql_fetch_array($result94))
{
$DateLogRef = "row94[0]";
$MachineRef = "row94[1]";
IF Exists ($DateLogRef, $MachineRef)
{ "UPDATE tblResults
SET BC = $BValue, CC = $CValue
WHERE DateLog = $DateLogRef
AND MachineId = $MachineRef
AND ConcesRef = $ConcesRef";
}
ELSE
{
"INSERT INTO tblResults (DateLogRef,MachineRef,ConcesRef,BC,CC,LoadedBy)
VALUES ('$DateLogRef','$MachineId','$ConcesRef','$BC','$CC','$UserId')";
}
} // end while