/    Sign up×
Community /Pin to ProfileBookmark

create table help

Hi

Im playing around with creating a table and I’m getting this error

Parse error: syntax error, unexpected T_STRING in C:xampphtdocsfiniancialharmonifunctionsadd.liability.php on line 9

this is line 9 “create TABLE $id (“

[code=php]
<?php
session_start();

include(“../connections/liability.connect.php”);

$id = $_SESSION[‘id’];
$id = 1;

create TABLE $id (

ln_Id int NOT NULL AUTO_INCREMENT,
starting_balance varchar(255),
current_balance varchar(255),
start_date date,
balance_date date,
payment varchar(255),
payment_frequency varchar(255),
interest_compound varchar(255),
interest_rate varchar(255),
status varchar (255),
add_date date,
last_update date,

)

?>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@YelgnidrocJan 12.2010 — [CODE]<?php
session_start();

include("../connections/liability.connect.php");

$id = $_SESSION['id']; // Why have this line and the line below????
$id = 1; // This supercedes the line above

$query = "create TABLE $id (

ln_Id int NOT NULL AUTO_INCREMENT,
starting_balance varchar(255),
current_balance varchar(255),
start_date date,
balance_date date,
payment varchar(255),
payment_frequency varchar(255),
interest_compound varchar(255),
interest_rate varchar(255),
status varchar (255),
add_date date,
last_update date
)";

mysql_query($query);

?> [/CODE]


NB You have balances etc. set to varchar, float maybe better
Copy linkTweet thisAlerts:
@kprocauthorJan 12.2010 — thank you for the reply

im getting this error message

SQL Error: create TABLE 1 ( ln_Id int NOT NULL AUTO_INCREMENT, starting_balance varchar(255), current_balance varchar(255), start_date date, balance_date date, payment varchar(255), payment_frequency varchar(255), interest_compound varchar(255), interest_rate varchar(255), status varchar (255), add_date date, last_update date )

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 '1 ( ln_Id int NOT NULL AUTO_INCREMENT, starting_balance varchar(255), curre' at line 1

Question: can I name a table a number value
Copy linkTweet thisAlerts:
@NogDogJan 12.2010 — An identifier in MySQL which consists only of digits must be quoted.
[code=php]
$sql = "CREATE TABLE $id . . . ";
[/code]

(Not that I think a table named "1" is such a great idea, mind you.)
×

Success!

Help @kproc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...