List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:December 17 2002 12:32pm
Subject:RE: How can I duplicate a mysql template database?
View as plain text  
> 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 

Thread
How can I duplicate a mysql template database?Daevid Vincent17 Dec
  • Re: How can I duplicate a mysql template database?Bill Lovett17 Dec
    • RE: How can I duplicate a mysql template database?Daevid Vincent17 Dec
      • RE: How can I duplicate a mysql template database? [hack]Daevid Vincent17 Dec
        • Re: How can I duplicate a mysql template database? [hack]Joseph Bueno17 Dec
          • RE: How can I duplicate a mysql template database? [hack]Daevid Vincent17 Dec
            • Re: How can I duplicate a mysql template database? [hack]Joseph Bueno17 Dec
      • Re: How can I duplicate a mysql template database?David T-G17 Dec
        • RE: How can I duplicate a mysql template database?Daevid Vincent17 Dec
          • Re: How can I duplicate a mysql template database?Joseph Bueno17 Dec
          • Re: How can I duplicate a mysql template database?David T-G17 Dec