Browser specific mysql error?

Discussion in 'MySQL' started by JohnUK, May 23, 2009.

  1. #1
    Hi guys!

    I know this shouldnt happen but ive got a mysql error but only in google chrome and I presume safari. Its strange because the page shows correctly in all browsers despite the error :s

    here is the 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 '(email, password, first, sur, contact) VALUES ('','d41d8cd98f00b204e9800998ecf84' at line 1

    email should have a value going into it as well. This error is only seen in the source on chrome but not in the ie ff source. And the values go into the table as well.

    Any ideas how to fix this? Ive echoed the email address to screen and it is their.

    insert code:

    mysql_query("INSERT INTO $_POST[table] (email, password, first, sur, contact) VALUES ('$_POST','".md5($_POST['pass'])."','$_POST[first]','$_POST[sur]','$_POST[contact]')")or die(mysql_error());

    Any help?

    Cheers,

    J
     
    JohnUK, May 23, 2009 IP
  2. bl4ckwolf

    bl4ckwolf Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    You miss some single quote ( ' ) when using $_POST[table]. It should be $_POST['table']. the same apply to the others variable.
     
    bl4ckwolf, May 23, 2009 IP
  3. JohnUK

    JohnUK Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it works the same with or without. either way the data does get inserted. I initially had the (') in with the same effect.

    Any other suggestions?
     
    JohnUK, May 23, 2009 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    bl4ckwolf has given a good suggestion. That is the correct way doing it. Anyways, value for email is not being passed on submit button. Are you using some kind of javascript or something like that?
     
    mwasif, May 25, 2009 IP
  5. JohnUK

    JohnUK Peon

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There is unrelated javascript on the page. The value is there for ie but not chrome but both browsers echo the email account to the screen.
     
    JohnUK, May 25, 2009 IP
  6. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Can you please put the echo statement before firing the sql query ... and paste it here the result of echo statement
     
    nirajkum, May 26, 2009 IP