List:General Discussion« Previous MessageNext Message »
From:David T-G Date:December 17 2002 10:41am
Subject:Re: How can I duplicate a mysql template database?
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daevid --

...and then Daevid Vincent said...
% 
% Thanks for the reply Bill, however this did not solve the problem. I
% still receive the same error with your method as well.
% 
% 1064: You have an error in your SQL syntax near ';
% CREATE TABLE Departments (
%   DeptID int(10) unsigned NOT NULL auto_increment,' at line 4

You mentioned a

  echo "<PRE>".$sql."</PRE><P>";

in your first post; what do you see?


% 
% > Are you first creating a new database first with mysql_create_db() 
% > before trying to run your schema? What error message do you get? The 
% > code you've posted is only creating a table.
% 
% Yes. I am:
% 
% $V2DB = "V2_SL".$CompanyID;
% $result = mysql_create_db($V2DB, $linkI);
% mysql_select_db ($V2DB, $linkI) or die ("Could not select ".$V2DB."
% Database");

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.

By the way, I see you quoting around your variables like

  print "This is " . $var . " here" ;

and should note that that's way much extra work.  I just tested (to be
sure ;-) and

  $v = "variable" ;
  print "print : this includes $v right here<br>\n" ;
  echo "echo : this includes $v right here<br>\n" ;
  print "print : this quotes " . $v . " for me<br>\n" ;
  echo "echo : this quotes " . $v . " for me<br>\n" ;
  die ("die : This is $v for you<br>\n") ;

happily gives me

  print : this includes variable right here
  echo : this includes variable right here
  print : this quotes variable for me
  echo : this quotes variable for me
  die : This is variable for you

as it oughta.  But I digress...


% 
...
% > heredoc syntax, 
% > which would let you do something like
% > 
% > $sql = <<<SQL
...
% 
% Thanks for that tip, however it fails the same as opening the file and
% same as "$sql .="

How does it fail?  Give us more detail.


% 
% > (hopefully $linkI is your mysql connection) This way you 
% > don't have to bother with all that quoting.
% 
% Yes, $linkI is my connection identifier.
% 
% 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.

Show us what you get when you print your $sql statement so that we can
debug actual practice rather than theory ;-)


HTH & HAND

mysql query,
:-D
- -- 
David T-G                      * There is too much animal courage in 
(play) davidtg@stripped * society and not sufficient moral courage.
(work) davidtgwork@stripped  -- Mary Baker Eddy, "Science and Health"
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE9/v9fGb7uCXufRwARApqsAJ0dKO9KUBgdxGUUZALfyCYtXnZeXACgntaM
Go7VwkhEHVLAoqFUWLjayK4=
=l7G9
-----END PGP SIGNATURE-----
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