/    Sign up×
Community /Pin to ProfileBookmark

Creating tables error…

Hi All,

I have this php script running fine but when it comes to creating tables it only creates the first table instead of 4…. why?
am I missing something here????
help is appreciated.-.-.-.-

PHP

[code]
<?php
$link = mysql_connect(‘localhost’, ‘username’, ‘password’);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}

$sql = ‘CREATE DATABASE test2’;
if (mysql_query($sql, $link)) {
echo “Database test2 created successfullyn”;
} else {
echo ‘Error creating database: ‘ . mysql_error() . “n”;
}
// Create tables in test2 database

mysql_select_db(“test2”, $link);

$sql = “CREATE TABLE car (
title varchar(255) NOT NULL,
description varchar(255) NOT NULL,
priority tinyint(2) NOT NULL default ‘0’
) TYPE=InnoDBn”;

mysql_query($sql, $link);
if (mysql_error()) echo __line__.”) Error creating table: “.mysql_error();

//Create links table
$sql = “CREATE TABLE links (
type varchar(20) NOT NULL default ”,
resource varchar(255) NOT NULL,
) TYPE=InnoDBn”;

mysql_query($sql, $link);
if (mysql_error()) echo __line__.”) Error creating table: “.mysql_error();

//Create home table
$sql = “CREATE TABLE home (
name varchar(255) NOT NULL,
title varchar(255) NOT NULL default ”,
description varchar(255) NOT NULL default ”,
) TYPE=InnoDBn”;

mysql_query($sql, $link);
if (mysql_error()) echo __line__.”) Error creating table: “.mysql_error();

//Create people table
$sql = “CREATE TABLE people (
name varchar(20) NOT NULL default ”,
address varchar(255) NOT NULL
resource varchar(255) NOT NULL,

) TYPE=InnoDBn”;

echo “car,home,links, & people tables in the relational database (“.test2.”) have been successfully created!n”;
mysql_query($sql, $link);
if (mysql_error()) echo __line__.”) Error creating table: “.mysql_error();
mysql_close($link);//Close connection
?>
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @kingstone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...