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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:25:20+00:00 2026-05-13T09:25:20+00:00

First, I’m just starting to learn MySQL with PHP. My query copy/paste directly from

  • 0

First, I’m just starting to learn MySQL with PHP.

My query copy/paste directly from my IDE:

$query = "CREATE TABLE IF NOT EXISTS $table_messages (
                id       int(11)        unsigned  NOT NULL  auto_increment,
                show     tinyint(1)     unsigned  NOT NULL  default '0',
                to       varchar(255)             NOT NULL  default '',
                from     varchar(255)             NOT NULL  default '',
                type     varchar(255)             NOT NULL  default '',
                message  varchar(255)             NOT NULL  default '',
                PRIMARY KEY(id)
             ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";

$result = mysql_query( $query, $link ) OR exit ( mysql_error() );

Results in this error:

You have an error in your SQL syntax;
near ‘show tinyint(1) unsigned NOT
NULL default ‘0’ , to varchar(255) N’
at line 4

… so I add one character to show (e.g. showz) and get this error:

You have an error in your SQL syntax;
near ‘to varchar(255) NOT NULL
default ” , from varchar(255) NOT
NUL’ at line 5

… so I add one character to to (e.g. toz) and get this error:

You have an error in your SQL syntax;
near ‘from varchar(255) NOT NULL
default ” , type varchar(255) NOT NU’
at line 6

… so I add one character to from (e.g. fromz) and IT WORKS!?

What is going on? Lol

If this question is too blatantly obvious, I’ll remove it if the community thinks it would be prudent, but in the meantime I’m stumped.

BTW, I’ve messed with spacing, case and other things without any success.

  • 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-13T09:25:21+00:00Added an answer on May 13, 2026 at 9:25 am

    SHOW, TO and FROM are reserved MySQL keywords. You must quote them with backticks to make them work as column names:

    $query = "CREATE TABLE IF NOT EXISTS $table_messages (
        `id` int(11) unsigned NOT NULL auto_increment,
        `show` tinyint(1) unsigned NOT NULL default '0' ,
        `to` varchar(255) NOT NULL default '' ,
        `from` varchar(255) NOT NULL default '' ,
        `type` varchar(255) NOT NULL default '' ,
        `message` varchar(255) NOT NULL default '' ,
        PRIMARY KEY(id)
    ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    

    It’s usually good practice (though unneeded) to quote every column name this way to prevent accidental collisions with keywords as there are hundreds of them. For a full list, see http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html.

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

Sidebar

Related Questions

First, let's get the security considerations out of the way. I'm using simple authentication
First off, I am using Windows XP. I have multiple hard drives and it
First off, I understand the reasons why an interface or abstract class (in the
First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.
First of all, I know how to build a Java application. But I have
First off, there's a bit of background to this issue available on my blog:
First off: I'm using a rather obscure implementation of javascript embedded as a scripting
First let me say that I really feel directionless on this question. I am
First off, I'm working on an app that's written such that some of your
First of all, I don't need a textual comparison so Beyond Compare doesn't do

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.