This topic is locked
[SOLVED]

 BeforeDelete, WHERE AND

8/19/2013 1:42:39 PM
PHPRunner General questions
J
jonas author

Hi
Can someone tell me why this works perfect:

$strSQLSave = "DELETE FROM _Ferill where StudentID=".$deleted_values["StudentID"];
BUT the line below is not doing its job and deleting all records from all courses of the student, just as the line above.

$strSQLSave = "DELETE FROM _Ferill where StudentID=".$deleted_values["StudentID"] AND "CourseID=" .$deleted_values["CourseID"];
Regards

Jonas

C
cgphp 8/19/2013

Try this version:

$strSQLSave = "DELETE FROM _Ferill where StudentID=".$deleted_values["StudentID"]." AND CourseID=".$deleted_values["CourseID"];
J
jonas author 8/19/2013

Thank you Cristian
This seems be correct, but now I get the php error:
Error type 256

Error description Unknown column 'O1' in 'where clause'
Jonas

Sergey Kornilov admin 8/20/2013

If StudentID or CourseID are text fields you need to wrap text values by single quotes.
Example:

$strSQLSave = "DELETE FROM _Ferill where StudentID='".$deleted_values["StudentID"]."' AND CourseID='".$deleted_values["CourseID"]."'";
J
jonas author 8/20/2013

Thank you so much - everything is working fine now.
Jonas