Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a table: needs help !

Status
Not open for further replies.

lupidol

Programmer
Apr 23, 2008
125
0
0
IL
I everyone,
In an existing database called "book", I'm trying to create a table with the name: "users" but instead of a new table I'm getting a new error.
This is my code:
Code:
<?php
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'test');
DEFINE ('DB_NAME', 'book');
$dbcon = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) 
OR die ('Could not connect to MySQL: ' . mysqli_connect_error () ); 

CREATE TABLE users 
(
user_id MEDIUMINT (6) UNSIGNED
AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname VARCHAR(40) NOT NULL,
email VARCHAR(50) NOT NULL,
pass CHAR(40) NOT NULL,
registration_date DATETIME,
PRIMARY KEY (user_id)
);
mysqli_set_charset($dbcon, 'utf8');
?>
The error message that shows up says:
Parse error: syntax error, unexpected 'users' (T_STRING) in C:\xampp\htdocs\folder \scripts\create_users.php on line 9]
Can I get some assistence with that please?
Thanks
 
Do not post passwords, even if they may be limited to localhost access. The moderators have been alerted and may redact for you.

You need to wrap `users` in backticks.


When in doubt on MySQL matters, test in a MySQL interface like phpmyadmin or Workbench or SQLyog or HeidiSQL or..., outside of the complexity of PHP.
 
Also, the "create table" has to be wrapped in a PHP function to query the MySQL database.
 
Thanks spamjim for all 3 resopnses.
Very negligent of my part [sad]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top