Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

- - - - -

Inserting tables probelmo


  • Please log in to reply
32 replies to this topic

#1 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 26 February 2009 - 12:09 PM

I have this:


$sql = "

CREATE TABLE IF NOT EXISTS `admin` (
`uname` varchar(50) NOT NULL,
`pword` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`last_login` varchar(50) NOT NULL,
`siteurl` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `banners` (
`size` varchar(20) NOT NULL,
`banner_id` int(15) NOT NULL,
`gourl` varchar(100) NOT NULL,
`user_id` varchar(100) NOT NULL,
`name` varchar(50) NOT NULL,
`banner_code` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
";
$query = mysql_query($sql);


But it gives me this error:

Can not insert tables to database: 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 '; CREATE TABLE IF NOT EXISTS `banners` ( `size` varchar(20) NOT ' at line 7


Maybe someone can help me..
  • 0

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 26 February 2009 - 12:46 PM

I just ran the SQL in my local MySQL database and it worked fine. I'm not sure what the problem is here. What version of MySQL are you using? Try executing each "CREATE" statement one at a time. Do you get the same error when you run it directly in MySQL console or PHPMyAdmin?
  • 0

#3 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 26 February 2009 - 12:54 PM

I made like you told me:


$query_1 = mysql_query($sql_1);
$query_2 = mysql_query($sql_2);
$query_3 = mysql_query($sql_3);
$query_4 = mysql_query($sql_4);
$query_5 = mysql_query($sql_5);
$query_6 = mysql_query($sql_6);
$query_7 = mysql_query($sql_7);
$query_8 = mysql_query($sql_8);


And it worked.. yay
  • 0

#4 Brandon W

Brandon W

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2092 posts
  • Location:Ipswich, Australia
  • Programming Language:C, Java
  • Learning:Java, C++, JavaScript

Posted 26 February 2009 - 01:34 PM

Hmmmm. What would of made the difference?
  • 0
I've returned...

#5 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 26 February 2009 - 01:39 PM

I have no idea.. so weird
  • 0

#6 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 26 February 2009 - 02:37 PM

I believe there is a limit within the mysql module that you can only execute one query at a time. this would execute two queries.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#7 Brandon W

Brandon W

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2092 posts
  • Location:Ipswich, Australia
  • Programming Language:C, Java
  • Learning:Java, C++, JavaScript

Posted 27 February 2009 - 01:35 AM

Hmmm. Well I am guessing it depends on how he was doing it. Where you doing it through phpMyAdmin?
  • 0
I've returned...

#8 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 27 February 2009 - 02:57 AM

Hmmm. Well I am guessing it depends on how he was doing it. Where you doing it through phpMyAdmin?


Well, he had the queries within php code, so I believe he was doing it through php.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#9 Brandon W

Brandon W

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2092 posts
  • Location:Ipswich, Australia
  • Programming Language:C, Java
  • Learning:Java, C++, JavaScript

Posted 27 February 2009 - 03:51 AM

Yer, I was thinking of that. Let's wait for his reply.
  • 0
I've returned...

#10 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 28 February 2009 - 05:08 AM

Well.. I took this SQL code from phpMyAdmin.. So it must work.. but well.. I don't know
  • 0

#11 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 28 February 2009 - 09:48 AM

As I said before; I believe that the php interface to mysql only supports one query at a time. I have the feeling that phpMyAdmin not use the same interface to support the server functions fully, or have created an workaround for it.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#12 Brandon W

Brandon W

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2092 posts
  • Location:Ipswich, Australia
  • Programming Language:C, Java
  • Learning:Java, C++, JavaScript

Posted 28 February 2009 - 03:05 PM

I always create my tables and data in phpMyAdmin then I just export the queries.
  • 0
I've returned...




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download