Home > Technical > Fixing MySQL Error 1064 with PHPList when selecting new criteria

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”


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}

$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


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}
if (substr($values, 0, 1) == ",") {
$values = substr($values, 1);
}

That’s it. This will remove the starting comma (If it exists)

Categories: Technical Tags:
  1. bousquet
    April 6th, 2009 at 10:31 | #1

    thanks a lot. You saved me time with this fix. I’ve version 2.10.9 and the bug is still there.

  2. TC
    April 25th, 2009 at 02:50 | #2

    You rock!

  3. Mohammad Al-Shami
    April 25th, 2009 at 09:46 | #3

    Thanks for the comments guys, glad I helped :)

  4. April 28th, 2009 at 10:33 | #4

    Exactly what I needed, cheers!

  5. NU
    May 8th, 2009 at 15:01 | #5

    Thanks!!!

  6. September 14th, 2009 at 11:42 | #6

    Thanks dude !! this help me a lot!

  7. November 24th, 2009 at 23:03 | #7

    Hi Shami,
    I have a similar problem and the same error message except that it happens when I import, or when I send a test .
    I have crteria added, but I ma not using any of them to select.

    It complains of :
    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 ‘) and phplist_user_user_attribute.attributeid = 15′

    I looked in this table and there is no attributeid number 15 the highes is 11.

    any ideas

    ny suggestions would be really appreciated

    • Mohammad Al-Shami
      December 2nd, 2009 at 08:40 | #8

      Hi EDT.

      Sadly I’ve only installed PHPlist once and didn’t run into your error. I think this question will be answered better in the PHPlist forums/mailing lists.

      Have a great day

  8. kepake
    May 16th, 2010 at 19:01 | #9

    Gracias por la información. Yo tengo PHPLIST 2.10.12. Parece que el error no es nuevo. No entiendo por que no se ha solucionado ya ???

    Lo dicho gracias por la corrección. De verdad que la necesitaba.

    • Mohammad Al-Shami
      June 19th, 2010 at 12:37 | #10

      Sorry I didn’t notice your comment before. Also I don’t speak Spanish. Can you ask your question in English please?

  9. RM
    June 22nd, 2010 at 21:11 | #11

    Hi,

    Many thanks for the fix. I had been searching in phplist’s forums but didn’t find any solution which solved this issue, on 2.10.12.
    Your fix worked for me.

    Did you post at their forum as well?

    Cheers

    • mohshami
      March 22nd, 2011 at 22:07 | #12

      No I didn’t, it didn’t occur to me

  10. zeera
    August 5th, 2010 at 06:05 | #13

    i hve prob ni doing mysql stored procedure…

    create procedure comparedata()
    begin
    declare acolumn1 varchar(100);
    declare acolumn2 varchar(100);
    |
    |
    v
    end;

    the error is :

    #1064 – 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 ” at line 3

    –> can u help me to fix this error?

    • mohshami
      March 22nd, 2011 at 22:06 | #14

      Sadly I haven’t worked on PHPlist for almost a year, the article is most probably outdated now. Sorry

  11. Chetan Bhawsar
    November 10th, 2010 at 12:22 | #15

    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 ‘text/css”> body { font-size : 11px; font-family: Verdana, Arial, Helvetica, s’ at line 1

    Found this issue when click on configure.

    • mohshami
      March 22nd, 2011 at 22:01 | #16

      Sorry for the late reply.

      Well the post itself is very old, and sadly I haven’t used the software in a while, so I haven’t updated it.

  1. No trackbacks yet.