Table not created...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
max0005
Forum Newbie
Posts: 2
Joined: Wed May 06, 2009 10:51 am

Table not created...

Post by max0005 »

Hello... i'm working on a script which creates a mysql database, and inside it a table with rows... the problem is the table isn't created while the database is... this is the script:

Code: Select all

<html>
<head>
</head>
<body>
<?php
$connection = mysql_connect ("localhost", "root");
 
 
if (!$connection)
{
die ('Could not connect: ' . mysql_error());
}
 
if (mysql_query("CREATE DATABASE pepr",$connection))
{
print "Database create!";
}
else
{
print "Couldn't create database: " . mysql_error();
}
mysql_select_db("pepr",$connection);
$table = "CREATE TABLE users
(name varchar(15), 
password varchar (30),
email varchar(30),
level varchar (2),
pending varchar (15),
banned varchar (15),
age varchar (15),
location varchar (30),
Age int
)";
mysql_query($table,$connection);
mysql_close($connection);
?>
</body>
</html>
what's wrong? :dubious:
Last edited by Benjamin on Wed May 06, 2009 12:09 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Table not created...

Post by Christopher »

Did you check for an error message after the query?
(#10850)
Post Reply