MySQL Forums
Forum List  »  PHP

Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\database\tables.php on line 6
Posted by: Pavan Upadhyay
Date: February 22, 2008 01:37AM

Hi i have getting the subjected problem the code here creates a database named sample_db and two tables in it but i am unable to do that i am getting the problem
Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\database\tables.php on line 6
can ny one resolve it plz.
here is the script

<?php
include "./common_db.inc";

$dbname = "sample_db";
$user_tablename = 'user'
$user_table_def = "usernumber MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT,";
$user_table_def .= "userid VARCHAR(8) BINARY NOT NULL,";
$user_table_def .= "userpassword VARCHAR(20) BINARY NOTNULL,";
$user_table_def .= "username VARCHAR(30) NOTNULL,";
$user_table_def .= "userposition VARCHAR(50) NOT NULL,";
$user_table_def .= "usermail VARCHAR(50) NOTNULL,";
$user_table_def .= "userprofile TEXT NOT NULL,";
$user_table_def .= "PRIMARY KEY (userid) ,";
$user_table_def .= "UNIQUE usernumber (usernumber)";

$access_log_tablename = "access_log";
$access_log_table_def = "page VARCHAR(250) NOT NULL,";
$access_log_table_def .= "userid VARCHAR(15) BINARY NOTNULL,";
$access_log_table_def .= "visitcount MEDIUMINT(5) DEFAULT '0' NOT NULL,";
$access_log_table_def .= "accessdate TIMESTAMP(14) ,KEY page (page),";

$link_id = db_connect();
if(!$link_id) die(sql_error());

if (!mysql_query("create database $dbname")) die(sql_error());

echo "successfully created the $dbname database.<br>";

if(!mysql_select_db($dbname)) die(sql_error());

if(!mysql_query("create table $user_tablename ($user_table_def)")) die(sql_error());

if(!mysql_query("create table $access_log_tablename ($access_log_table_def)")) die(sql_error());

echo "Successfully created the $user_tablename and $access_log_tablename tables.";
?>

Options: ReplyQuote


Subject
Written By
Posted
Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\database\tables.php on line 6
February 22, 2008 01:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.