query error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

query error

Post by thcc2 »

I have the following statement that give me error

Code: Select all

$sql_text = $sql_text . " LIMIT $start, $maxresult";
    $query = pg_query($dbconn, $sql_text);
it gives me an error of
Warning: pg_query(): Query failed: ERROR: LIMIT #,# syntax is not supported HINT: Use separate LIMIT and OFFSET clauses. in
hope someone can help me.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it just explained what the error means..
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

feyd wrote:it just explained what the error means..
is that anything wrong with my query statement?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Not to be rude, but pay attention to what the error is saying
Warning: pg_query(): Query failed: ERROR: LIMIT #,# syntax is not supported HINT: Use separate LIMIT and OFFSET clauses. in
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

Jcart wrote:Not to be rude, but pay attention to what the error is saying
Warning: pg_query(): Query failed: ERROR: LIMIT #,# syntax is not supported HINT: Use separate LIMIT and OFFSET clauses. in
I think this line of code is invalid in PostgresSQL, can u please tell me what's wrong with the statement, i think it is valid for MySQL only.

Thks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I think this line of code is invalid in PostgresSQL, can u please tell me what's wrong with the statement, i think it is valid for MySQL only.
Bang on. So the next logical step would be to visit postgresql.org's manual and search for Limit Offset, would it not?
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

Jcart wrote:
I think this line of code is invalid in PostgresSQL, can u please tell me what's wrong with the statement, i think it is valid for MySQL only.
Bang on. So the next logical step would be to visit postgresql.org's manual and search for Limit Offset, would it not?
I had changed my code to

Code: Select all

$sql_text = $sql_text . " LIMIT $start " OFFSET "$maxresult";
it gives me an error of
Parse error: parse error, unexpected T_STRING
I don't know what's wrong with it?
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

i dont use postgre sql but my guess is

Code: Select all

$sql_text = $sql_text . " LIMIT $start OFFSET $maxresult";
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

mickd wrote:i dont use postgre sql but my guess is

Code: Select all

$sql_text = $sql_text . " LIMIT $start OFFSET $maxresult";
Thks you are right.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

thcc2 wrote:

Code: Select all

$sql_text = $sql_text . " LIMIT $start " OFFSET "$maxresult";
Parse error: parse error, unexpected T_STRING
That's not a SQL problem but a PHP problem. Everything (and more) that you need to know about strings is at http://www.php.net/string.
thcc2
Forum Commoner
Posts: 33
Joined: Thu Jan 05, 2006 9:37 pm
Location: Singapore

Post by thcc2 »

timvw wrote:
thcc2 wrote:

Code: Select all

$sql_text = $sql_text . " LIMIT $start " OFFSET "$maxresult";
Parse error: parse error, unexpected T_STRING
That's not a SQL problem but a PHP problem. Everything (and more) that you need to know about strings is at http://www.php.net/string.
Thks for ur reply.
Post Reply