Solved: MySQL Help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

lumentec

Thread Starter
Joined
Mar 23, 2008
Messages
103
All I want to do is create a table called "turns" with columns.. "username", and "turns". I already have a database set up via CPanel... but somehow, I managed to mess it up. Some help please?

HTML:
<?php
$con = mysql_connect("localhost","game","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


mysql_select_db("game", $con);
$sql = "CREATE TABLE turns 
(
username varchar(16),
turns varchar(4),
)";
mysql_query($sql,$con);

mysql_close($con);
?>
 
Joined
Oct 25, 2007
Messages
551
This is the SQL I got using PHPMyAdmin to create the table:
Code:
CREATE TABLE `turns` (
`username` VARCHAR( 16 ) NOT NULL ,
`turns` VARCHAR( 4 ) NOT NULL
) ENGINE = MYISAM ;
The rest of your PHP looks fine so maybe it's something to do with the NOT NULL or engine (I'm not an expert on MySQL so I couldn't say). Also do you know when it fails? Is it failing to connect or to execute the query? I'd add
PHP:
if (!mysql_query($sql, $con)) {
die("Could not execute query");
}
to debug it.

HTH
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top