You cannot execute several SQL statements within a single query.
You are trying to reinvent 'mysql' client batch processing; if you want
to do that, you have to write an SQL parser in PHP that split
your input in independant SQL statements and execute them one by one :(


Daevid Vincent wrote:
>>You mentioned a
>>  echo "<PRE>".$sql."</PRE><P>";
>>in your first post; what do you see?
> 
> 
> I see exactly what I expected to see. Basically the contents of a db.sql
> file read in that looks like this roughly:
> 
> CREATE TABLE table1 (
>    blah int(10),
>    foo char(5)
> );
> 
> CREATE TABLE table2 (
>    blee int(10),
>    fee char(5)
> );
> 
> Etc.. Everything looks exactly like the .sql file does and the .sql file
> works perfectly if I redirect it in via the command line or even via an
> system() call.
> 
> 
>>That's good, and we'll assume for the moment that your script doesn't
>>error through to die but instead makes a successful connection.
> 
> 
> Yes. All that stuff works great.
> 
> 
>>By the way, I see you quoting around your variables like
>>  print "This is " . $var . " here" ;
> 
> 
> Yes, its' for readability in HomeSite. It color codes things, and that's
> a nice way to see it proper.
> 
> 
>>How does it fail?  Give us more detail.
> 
> 
> With the error I posted earlier:
> 
> 
>>1064: You have an error in your SQL syntax near ';
>>CREATE TABLE Departments (
>>  DeptID int(10) unsigned NOT NULL auto_increment,' at line 4
> 
> 
> It's always on the second table. Order is irrelevant.
> Notice the ";" that it chokes on. That only happens when I separate the
> CREATE commands of course. But there is no other way to deliminate them.
> 
> 
>>% I just have an awful feeling that PHP/mySQL won't let me 
>>stack commands
>>% like that because if I just do one table, like this: 
>>% 
>>% $sql = <<<SQL
>>% CREATE TABLE Schedule (
>>...
>>% SQL;
>>% 
>>% It "works". However I'm dreading doing this one table at a 
>>time. Grr.
>>
>>No, that doesn't make sense.  It shouldn't matter how you create and
>>populate the variable, as long as the end result content is the same.
>>Since it works when you lay it out manually, it seems very 
>>probable that your filling it out in steps has some problems.
> 
> 
> I think I'm right ;-)
> 
> Try if for yourself and see what I mean. Just try to create a db and two
> tables and you'll see it choke.
> 
> d 
> 
> 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to