Adding County / Any List Option SQL Error

Situation
When adding a county or any list for a patient, I get an SQL error.

OpenEMR Version
I’m using OpenEMR version 7.0.1

Browser:
I’m using: Doesn’t matter but Firefox/Chrome.

Operating System
I’m using: Windows 11

Search
Did you search the forum for similar questions? Yes. Not found.

Logs
Did you check the logs?
Yes

Was there anything pertinent in them?
Yes

Please paste them here (surround with three backticks (```) for readability.

SQL Statement failed on preparation: SELECT * FROM list_options WHERE list_id= ?AND option_id = ?AND activity = 1'
Query Error

ERROR: query failed: SELECT * FROM list_options WHERE list_id= ?AND option_id = ?AND activity = 1

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?AND option_id = ?AND activity = 1' at line 1

C:\laragon\webroots\current\openemr-7.0.1\library\ajax\addlistitem.php at 54:sqlQuery

You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All

$exists_id = sqlQuery("SELECT * FROM list_options WHERE " .
    " list_id= ? " .
    "AND option_id = ? " . "AND activity = 1", array($list_id, $option_id));
if ($exists_id) {
    echo json_encode(array("error" => xl('Record already exist') ));
    exit;
}

library/ajax/addlistitem.php

Line 52-58

To be perfectly honest, this particular issue or error is understandable but very concerning…considering I am evaluating the application for an organisation which has real HIPAA and privacy concerns.

Hi David Lloyd,
Actually its fatal error. no Space in line number 52.

before code:
$exists_id = sqlQuery(“SELECT * FROM list_options WHERE " .
" list_id= ?” .
“AND option_id = ?” . “AND activity = 1”, array($list_id, $option_id));

After code:
$exists_id = sqlQuery("SELECT * FROM list_options WHERE " .
" list_id= ? AND option_id = ? AND activity = 1", array($list_id, $option_id));

I attached picture and addlistitem.php file
for your reference


addlistitem.php (3.1 KB)

Thanks,
Param,
help@capminds.com

1 Like