Expand|Select|Wrap|Line Numbers
- $facility = $_REQUEST['fac_id'];
- if ($facility != '') {
- echo "Facility: ".$facility." ";
- $where .= ' AND fac_id='.$facility.'';
- }
SELECT fac_id, room_descr, person_type, severity FROM incidents WHERE 1=1 AND fac_id=000852 ORDER BY fac_id, room_descr, person_type, severity.
But when the field is character, this same code does not work:
Expand|Select|Wrap|Line Numbers
- $persontype = $_REQUEST['person_type'];
- if ($persontype != '') {
- echo "Persontype: ".$persontype. " ";
- $where .= ' AND person_type ='.$persontype.'';
- }
SELECT fac_id, room_descr, person_type, severity FROM incidents WHERE 1=1 AND person_type =Outpatient ORDER BY fac_id, room_descr, person_type, severity
And gives the error:
Error: Unknown column 'Outpatient' in 'where clause'.
If I copy the SQL produced and add quotes around Outpatient it runs fine in phpmyadmin.
How do I add single quotes to the person_type field?
TIA,
jej1216