Jump to content


Photo

nOOb alert! WHY oh WHY is this giving me an error?


  • Please log in to reply
3 replies to this topic

#1 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 21 July 2006 - 10:49 PM

Simple. Trying to create a table. Looked at this code 'til i'm ready to puke. Compared with other ones i've done that work fine. Perhaps another set of eyes can set me straight.

<?php 
include 'config.php';
// Make connect to DB first
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die("Where is the dang database");

// Now we create the tables and rows
mysql_query("CREATE TABLE members(
business VARCHAR(255) NOT NULL, 
name VARCHAR(30) NOT NULL PRIMARY KEY, 
title VARCHAR(30) NOT NULL, 
phone VARCHAR(30) NOT NULL, 
email VARCHAR(30) NOT NULL, 
url VARCHAR(30) NOT NULL, 
details VARCHAR(30) NOT NULL, 
category VARCHAR(30) NOT NULL") or die(mysql_error());

echo "Table Was Created Successfully!";

 ?>

Error I get:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9



Hellllllllllllllllllp meeeeeeeeeeeeeeeeeeeeee.......  :P

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 21 July 2006 - 10:52 PM

<?php 
include 'config.php';
// Make connect to DB first
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die("Where is the dang database");

// Now we create the tables and rows
mysql_query("CREATE TABLE members(
business VARCHAR(255) NOT NULL, 
name VARCHAR(30) NOT NULL PRIMARY KEY, 
title VARCHAR(30) NOT NULL, 
phone VARCHAR(30) NOT NULL, 
email VARCHAR(30) NOT NULL, 
url VARCHAR(30) NOT NULL, 
details VARCHAR(30) NOT NULL, 
category VARCHAR(30) NOT NULL)") or die(mysql_error());

echo "Table Was Created Successfully!";

 ?>


#3 KittyKate

KittyKate
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 21 July 2006 - 10:52 PM

Prismatic beat me to it, but if you can't find the difference....

You are missing a closing bracket at the red spot:

category VARCHAR(30) NOT NULL)") or die(mysql_error());
PHP Version 4.3.2
MySQL version unknown (greater or equal to 3.23)

#4 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 21 July 2006 - 11:52 PM

Well son-of-a-biscuit-maker. Thanks for being the other set of 'eyes'!  ::)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users