Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:04:13+00:00 2026-06-11T06:04:13+00:00

This won’t work and i’m getting an error from the ORDER BY param for

  • 0

This won’t work and i’m getting an error from the ORDER BY param for some reason?

if($selected_radio == 'city')
{
    $query = "SELECT name FROM City WHERE name LIKE $1 LIMIT $2 OFFSET $3 ORDER BY name ASC";
    $result = pg_prepare($conn, "findCity", $query);
    $result = pg_execute($conn, "findCity", array($text, $limit, $offset));

    while($row = pg_fetch_assoc($result))
    {
        echo "<tr>";
        echo "<td>" . $i . "</td>";
        echo "<td>" . $row['name'] . "</td>";
        echo "</tr>";
        $i += 1;
    }
}

Sorry about the way it looks I’m fairly new to this site and not sure how to correctly post code :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:04:14+00:00Added an answer on June 11, 2026 at 6:04 am

    You’ve got your clauses in the wrong order – ORDER BY goes before LIMIT and OFFSET.

    From the docs:

    SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
         * | expression [ AS output_name ] [, ...]
         [ FROM from_item [, ...] ]
         [ WHERE condition ]
         [ GROUP BY expression [, ...] ]
         [ HAVING condition [, ...] ]
         [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
         [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
         [ LIMIT { count | ALL } ]
         [ OFFSET start ]
         [ FOR { UPDATE | SHARE } [ OF table_name [, ...] ] [ NOWAIT ] [...] ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This won't work in Kohana 3.2 for some reason: $this->request->headers['Content-Type'] = 'text/xml'; Has this
Any idea why this won't work? I m getting tags a user has set
This will work. SelectCommand=SELECT [CompanyName], [Country] FROM [Customers] WHERE ([Country] = ?)> <SelectParameters> <asp:Parameter
Any ideas on why this won't work. I am using the tutorial from CSS-Tricks
I have no idea why this won't work. function query($sql) { $this->result = @mysql_query($sql,
I'm not sure why this won't work: SELECT u.id, u.tag, u.unit_type, Count(p.id) AS num_points
This won't work: <select size=2> <option>Mars</option> <option>Earth</option> <option>Jupiter</option> </select> http://jsfiddle.net/uteb6/ It's not possible to
I know this won't work. I tried it in various forms and failed all
I can't see why this won't work. I am performing lstrip() on the string
I can't figure out why this won't work, I've tried it 100 ways. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.