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 8996681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:47:14+00:00 2026-06-15T23:47:14+00:00

I am beginner with PHP. I faced that problem when I start my first

  • 0

I am beginner with PHP. I faced that problem when I start my first SQL queries:

Database query On Pages failed : 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 ‘[‘id’]}’ at line 1

There is my SELECT command :

$page_set = mysql_query(
    "SELECT * FROM pages WHERE subject_id  = {[$subject'id']}", $connection
);

I checked all my database tables and everything is correct. This query works :

$page_set = mysql_query("SELECT * FROM pages" ,$connection)
  • 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-15T23:47:15+00:00Added an answer on June 15, 2026 at 11:47 pm

    Going forward, construct your query string in a separate variable like this:

    $sql = "SELECT * FROM pages WHERE subject_id  = {[$subject'id']}";
    

    Then run the query like this:

    $res = mysql_query($sql);
    

    If you do that you can see the fully resolved query string with something like this:

    if (!$res) die("FAIL: $sql BECAUSE: " . mysql_error());
    

    You must test the results value from mysql_query() — it is not a black box; it can and will fail for reasons outside of your control. When the failure occurs, you want to recognize it and handle the error conditions.

    Siedbar note: the mysql extension is now deprecated by PHP, so you might want to choose PDO or MySQLi for your current / future work.

    And if you’re new to PHP, this is a really great book to help you get started:
    http://www.sitepoint.com/books/phpmysql5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am a beginner in PHP.I have this query in my code. $qsq =
Total beginner with PHP: I have an form based on table data that the
I'm still beginner in PHP. I have a small problem, I would to multiply
I'm an beginner in php/msql, and need help to solve this problem: I have
I am a beginner in PHP and SQL. Maybe this is a silly question,
I am a PHP beginner. I have developed a social networking website similar to
I am a beginner in Android. I have developed a application that will send
I am beginner in PHP and i read in manual that $_REQUEST is a
I am beginner php Programmer, i am creating a shopping cart application, I have
Over the last year I have moved from a beginner PHP developer to a

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.