Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts

    cant find my mysql line error

    Hi im looking for my error but i cant find it.

    mysql 5.5.32 version

    this is the message im getting

    '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 'INSERT INTO `mca_admins` (`id` , `username` , `password` , `email` , `super` , `' at line 13' during the following query:

    INSERT INTO `mca_admins` (`id` , `username` , `password` , `email` , `super` , `date` , `time` , `primary` ) VALUES ('1', 'admin', 'a062322cd3a14f8f7a2e046a28685cc1', 'myemail@hotmail.com', '1', NOW(), NOW(), '1')
    and this is the query i produce.. and it does work if i copy and paste it to the myPHPAdmin sql nothing wrong with it there, so i cant find the hangup!!

    PHP Code:
    CREATE TABLE IF NOT EXISTS `mca_admins` (
      `
    idint(11NOT NULL AUTO_INCREMENT,
      `
    usernamevarchar(50NOT NULL,
      `
    passwordvarchar(32NOT NULL,
      `
    emailvarchar(100NOT NULL,
      `
    superenum('0','1'NOT NULL DEFAULT '0',
      `
    datedate NOT NULL DEFAULT '0000-00-00',
      `
    timetime NOT NULL DEFAULT '00:00:00',
      `
    primaryenum('0','1'NOT NULL DEFAULT '0',
      
    PRIMARY KEY (`id`)
    ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;

    INSERT INTO `mca_admins` (`id` , `username` , `password` , `email` , `super` , `date` , `time` , `primary` )
    VALUES ('1''admin''a062322cd3a14f8f7a2e046a28685cc1''myemail@hotmail.com''1'NOW(), NOW(), '1'); 

    i also tried removing the tilde around the db name and no difference INSERT INTO mca_admins (`id` ,
    Last edited by durangod; 09-21-2013 at 05:30 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,494 Times in 4,458 Posts
    What happens if you do that as two separate queries from php? The fact it says error is on line 13 tells me you are doing it in one query and maybe php library is the problem.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    durangod (09-21-2013)

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    Nice call on that one...

    Since i am exploding on ; i did figure out that i had to readd the ; on the end of the statement inside my statement loop before i sent it off to the server.

    But doing this once statement at a time was the trick. Which i find strange that it does not like the two statements together. But it is at least creating the tables now.

    Thanks Old Pedant EXCELLENT CALL!

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,494 Times in 4,458 Posts
    Well, I know that mysql_query is *NOT* capable of more than one MySQL query at a time. I don't know about mysqli library or PDO.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •