Link to home
Start Free TrialLog in
Avatar of mhoggatt1
mhoggatt1

asked on

MySQL table question

I am getting an error on my table code. What am I doing wrong ?

$query = "
CREATE TABLE john (
  ID int(11) NOT NULL auto_increment,
  chapter tinyint(3) NOT NULL,
  start_verse tinynt(3) NOT NULL,
  end_verse tinyint(3) NOT NULL,
  sermon_title text NOT NULL,
  PRIMARY KEY  (ID))";

mysql_query($query, $mysql_access) or die("Sql error : " . mysql_error());
Thanks,
Michael
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Michael,

Although it would be easiest for us if you could show us the exact error that is outputted by the mysql_error() command, there are several things you can check.

1) Have you made a valid connection to a mysql server using mysql_connect()? ie,
<?php
  $connection = mysql_connect('localhost', 'username', 'password') or die('Could not connect to the database');
?> (You have to replace localhost/username/password with appropriate values.

2) Have you selected a database as to where the table should be created in?
<?php
 mysql_select_db('databasename', $connection); //the code above should also be in this file
?>

3) Are you sure that there is no table called "john" in the mysql database?

There might also be some problem on the "not null" phrases, but best would be if you could provide us with the error message.

Kind regards

-r-
ASKER CERTIFIED SOLUTION
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mhoggatt1
mhoggatt1

ASKER

Hi snoyes,
   Thanks for your help. I knew it had to be something I was overlooking.