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

  • Home
  • SEARCH
  • 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 8846947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:06:45+00:00 2026-06-14T12:06:45+00:00

to clarify my database is called database and my table is called table (this

  • 0

to clarify my database is called database and my table is called table (this was for testing).

  class Database 
{ 
 public $server = "localhost";
 public $database = "database"; 
 public $user = "root"; 
 public $password = ""; 
 public $row;
 public $result;



 //call connection method upon constructing 
 public function __construct(){
  $this->createConnection(); 
 }

 //connection to the database
 public function createConnection() 
    { 
     $this->dbLocalhost = mysql_connect($this->server, $this->user, $this->password)
                or die("could not connect:".mysql_error());

        mysql_select_db($this->database)
        or die("Could not find the database: ".mysql_error());
 } 

 //execute query string 
 public function query($queryString) 
    {

        echo "<table border='1' cellpadding='10'>";
        echo "<tr> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th></th> <th></th></tr>";
        $this->result = mysql_query($queryString)
        or die($queryString."<br/><br/>".mysql_error());

        while($this->row = mysql_fetch_array($this->result)) {

                echo "<tr>";
                echo '<td>' . $this->row['id'] . '</td>';
                echo '<td>' . $this->row['firstname'] . '</td>';
                echo '<td>' . $this->row['lastname'] . '</td>';
                echo '<td><a href="edit.php?id=' . $this->row['id'] . '">Edit</a></td>';
                echo '<td><a href="delete.php?id=' . $this->row['id'] . '">Delete</a></td>';
                echo "</tr>"; 

        } 

        echo "</table>";
    } 

and then i have php file which calls the functions.

<?php

include('database.php');
$db = new Database();
$sql = "SELECT * 
    FROM table"; 
$db->query($sql);

?>

This is the error a receive:

SELECT * FROM table

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 ‘table’ at line 2

Thanks.

  • 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-14T12:06:45+00:00Added an answer on June 14, 2026 at 12:06 pm

    table is a reserved word in MySQL, so you must escape it. You can do that by putting `s around it.

    For example:

    SELECT * FROM `table`
    

    As you can see on my link, there are several tricky reserved words that can cause a lot of headache. Some say you should always use ` characters when you write table and field names.

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

Sidebar

Related Questions

Let's say my SQL database contains a table called 'Customer'. This Customer has an
In my ASP.NET MVC2 application, I have a ViewModel class called UserCreateViewModel. In this
<?php mysql_connect(localhost, user, password) or die(mysql_error()); mysql_select_db(jmvarela_jacket) or die(mysql_error()); $query = 'SELECT * FROM
To clarify before I begin, this is NOT homework but rather I am studying
To clarify: I'm building a Logger class that allows me to easily log messages:
To clarify - there will be up to 4 distinct players in the table,
I would like to clarify this issue. I had installed Cocos2d 1.01 rc on
Could you please clarify this part of Apple's documentation: Transitioning to ARC Release Notes
H2 database has a command called SCRIPT to backup content and/or structure. It can
Can I somehow use a specific database given a specific condition? To clarify I

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.