Fixing MySQL Error 1064 With PHPList When Selecting New Criteria
I’m currently experimenting with PHPlist to use for our corporate newsletters. During the tests I got the following error.
Database error 1064 while doing query 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 ‘1)’ at line 3
Tracking this problem down I found the following code segment in “admin/send_core.php”
1if (is_array($_POST["criteria_values"])) {
2$values = join(", ",$_POST["criteria_values"]);
3} else {
4$values = $_POST["criteria_values"];
5}
$values in this segment will always start with a comma. We just need to add a substr statement to fix that. Just change it to
1if (is_array($_POST["criteria_values"])) {
2$values = join(", ",$_POST["criteria_values"]);
3} else {
4$values = $_POST["criteria_values"];
5}
6if (substr($values, 0, 1) == ",") {
7$values = substr($values, 1);
8}
That’s it. This will remove the starting comma (If it exists)