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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:21+00:00 2026-05-26T18:38:21+00:00

This problem has got me stumped for a few days now. I have a

  • 0

This problem has got me stumped for a few days now.

I have a MySQL table that looks like this:

+--------+------------+------------+-----------+-----------+-----------+
|   id   |   to       |  from      |question   | answer    |  time     |
+--------+------------+------------+-----------+-----------+-----------+
|        |            |            |           |           |           |
| type:  |type:       |type:       |type:      |type:      | type:     |
| int(11)|varchar(26) |varchar(26) |tinyint(3) |tinyint(3) | bigint(20)|
|        |            |            |           |           |           |
|        |            |            |           |           |           |

I am trying to run a simple SELECT but I receive an error. This is the code I am using to run the query:

$to = mysql_real_escape_string($_POST['to']);
$query = "SELECT to FROM table_name WHERE to = '$to'";
$result = mysql_query("$query") or die(mysql_error() ."|". mysql_errno());

When I try to run this, this is what I am returned with:

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 ‘to FROM table_name WHERE to = ‘userOne” at line 1 | 1064

The 1064 at the end is the MySQL error number that is error is associated with. Error 1064 is some sort of parse error (Source: http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html#error_er_parse_error) But I am not sure what is causing this error.
Also note the error is saying there is an error on line 1 but this line is actually line 68 in my code. I am able to run queries similar to SELECT * FROM other_table where name = "$name" on other tables in my database.

Any ideas why this query wont run properly?

  • 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-05-26T18:38:21+00:00Added an answer on May 26, 2026 at 6:38 pm

    The error is raised because the word to is reserved in mysql as you can read here: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

    Thus, you should change this line:

    $query = "SELECT to FROM table_name WHERE to = '$to'";
    

    into this:

    $query = "SELECT `to` FROM table_name WHERE `to` = '$to'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem has been kicking my butt for a few days now. I have
I've got a simple problem that really has me stumped. I have a master
Has anyone else run into this problem before? I've got a method that calls
This problem has bugged me so many times and i have now decided to
I have encountered a problem in my program that has me somewhat stumped. I
I've got a problem with ODBC that has me stumped, and I can't find
Ok, this has got to be a super simple problem. I just can't seem
Alright, this one (3a; sample problem with provided answer) has got me scratching my
This problem has been bugging me for a while. I have to load a
I am having a bug that has got me stumped. I created a label

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.