PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 30th, 2001, 05:27 AM
dube dube is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Johannesburg, South Africa
Posts: 6 dube User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Creating Table in PostgreSQL using PHP

I get a "parser: parse error at "(" on line... .... /path/to/script.php.

on the following code:

$db=pg_pconnect("dbname=my_db_name user=user_name") or die(pg_errormessage($db));
$sql="CREATE TABLE users (
id varchar(5),
name varchar(20),
middle varchar(20),
last varchar(20),
address varchar(50),
expir date,
pass varchar(20),
PRIMARY KEY(id)
)";
pg_exec($db, $sql) or die(pg_errormessage());

The error is on the LAST line of code above.

This is driving me NUTS as I don't see any obvious error in the code. Please help.

Last edited by dube : July 30th, 2001 at 05:30 AM.

Reply With Quote
  #2  
Old July 30th, 2001, 09:30 AM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,172 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 29
I haven't used Postgresql much, but in other databases you have to explicitly declare all parts of the Primay Key to be NOT NULL. But it would seem to me that if this was the problem you would be getting a different type of error message. ????

I don't see an obvious error in the code either.

Reply With Quote
  #3  
Old July 30th, 2001, 02:23 PM
dube dube is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Johannesburg, South Africa
Posts: 6 dube User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks dcaillouet, but I have already tried ...(id varchar(5) NOT NULL, ...)"; still didn't work!!

Reply With Quote
  #4  
Old July 30th, 2001, 02:35 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,172 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 29
Should this line

pg_exec($db, $sql) or die(pg_errormessage());

be like the line earlier in the code?

pg_exec($db, $sql) or die(pg_errormessage($db));

Reply With Quote
  #5  
Old July 31st, 2001, 01:33 PM
pippo's Avatar
pippo pippo is offline
A PAtCHy sErver
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Italy
Posts: 408 pippo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 27 sec
Reputation Power: 12
I think it must be something like:

$link = pg_exec($db, $sql)
or die(pg_errormessage());

Reply With Quote
  #6  
Old August 4th, 2001, 09:14 AM
dube dube is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Johannesburg, South Africa
Posts: 6 dube User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I finally got my PHP script(s) to work(creating tables). I found out when I declare NOT NULL it must be before the default value (if any)

i.e. ident vachar(5) NOT NULL DEFAULT 0,

and not:

ident varchar(5) DEFAULT '0' NOT NULL,

the default value must be without quotes.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Creating Table in PostgreSQL using PHP

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap