raulgonzalez
09-10-2007, 07:10 PM
I can't seem to be able to create multiple tables at the same time. What's wrong with the code below?
It only creates the last table, what should I change? Please Help
<?php
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'root', 'pass')) {
if (!@mysql_select_db ('database')) {
die ('<p>Could select the database because: <b>' . mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
$query = 'create table table1
(bla bla bla
bla bla bla)';
$query = 'create table table2
(bla bla bla
bla bla bla)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>');
}
mysql_close(); // Close the connection.
?>
It only creates the last table, what should I change? Please Help
<?php
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'root', 'pass')) {
if (!@mysql_select_db ('database')) {
die ('<p>Could select the database because: <b>' . mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
$query = 'create table table1
(bla bla bla
bla bla bla)';
$query = 'create table table2
(bla bla bla
bla bla bla)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>');
}
mysql_close(); // Close the connection.
?>
