Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-21-2005, 07:35 AM Create Table Advice
Novice Talker

Posts: 8
Trades: 0
This code does not create a table but it connects to the database, is there something wrong with the syntax i dont see it

<?
$username="username";
$password="password";
$database="database";
$hostname="hostname";

$connection = mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="CREATE TABLE laptop (
id int(11) NOT NULL auto_increment,
date DATE NOT NULL,
time TIME NOT NULL,
subject VARCHAR(10) NOT NULL,
headline VARCHAR(50) NOT NULL,
leader VARCHAR(200) NOT NULL,
content VARCHAR (3000) NOT NULL,
PRIMARY KEY (id))";
mysql_close();
echo "Database created";
?>
dodgyknacker is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-21-2005, 08:35 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
You are assiging the SQL statement to $query, but your never executing the statement on the server.

Right before mysql_close(), add this:
PHP Code:
$result mysql_query($query);
if (!
$result) {
   die(
'Error: ' mysql_error());

Anacrusis is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Create Table Advice
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22480 seconds with 12 queries