Board index   FAQ   Search  
Register  Login
Board index php forum :: Database phpMyAdmin

phpMyAdmin create table ERROR

How to use phpmyadmin.... phpmyadmin related arguments. Even phpMyAdmin issues

Moderators: macek, egami, gesf

phpMyAdmin create table ERROR

Postby Buglish » Wed Aug 16, 2006 6:53 am

Hi,
I created a database Temp and when I try to input this create table Data (which I got from a website tutorial) I get this message, What is wrong...the Data or my phpmyadmin or mySQL?
----------------------------------
Error

SQL query:

CREATE TABLE 'tutorials'(
'ID'tinyint( 11 ) NOT NULL AUTO_INCREMENT ,
'title'text NOT NULL ,
'avatar'text NOT NULL ,
'date'date NOT NULL default '0000-00-00',
'description'text NOT NULL ,
'user'text NOT NULL ,
'message'text NOT NULL ,
PRIMARY KEY ( 'ID' )
) TYPE = MYISAM AUTO_INCREMENT =1;

MySQL said: Documentation
#1064 - 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 ''tutorials' (
'ID' tinyint(11) NOT NULL auto_increment,
'title' text NOT NULL,' at line 1
---------------------------------------
User avatar
Buglish
New php-forum User
New php-forum User
 
Posts: 26
Joined: Wed Aug 16, 2006 6:45 am
Location: South Africe

Postby Shiv » Wed Aug 16, 2006 7:52 pm

I think you have used single quote (') instead of back tick (`).
Use back tick (`) in Table Name and Field Names.
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Postby Buglish » Wed Aug 16, 2006 11:03 pm

Hi,
NO it still gives the error.
And its not the ` since it was corectly the '
What else could it be?
User avatar
Buglish
New php-forum User
New php-forum User
 
Posts: 26
Joined: Wed Aug 16, 2006 6:45 am
Location: South Africe

Postby Buglish » Wed Aug 16, 2006 11:37 pm

I manualy inserted the table...is this SQL phpmyadmin created the same as the first?
-----------------------------------
CREATE TABLE `tutorials` (
`ID` TINYINT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` TEXT NOT NULL ,
`avatar` TEXT NOT NULL ,
`date` DATE NOT NULL DEFAULT '0000-00-00',
`description` TEXT NOT NULL ,
`user` TEXT NOT NULL ,
`message` TEXT NOT NULL
) ENGINE = MYISAM ;
-----------------------------
User avatar
Buglish
New php-forum User
New php-forum User
 
Posts: 26
Joined: Wed Aug 16, 2006 6:45 am
Location: South Africe

Postby Shiv » Thu Aug 17, 2006 12:04 am

Second one is working.

1.

CREATE TABLE 'tutorials'(
'ID'tinyint( 11 ) NOT NULL AUTO_INCREMENT ,
'title'text NOT NULL ,
'avatar'text NOT NULL ,
'date'date NOT NULL default '0000-00-00',
'description'text NOT NULL ,
'user'text NOT NULL ,
'message'text NOT NULL ,
PRIMARY KEY ( 'ID' )
) TYPE = MYISAM AUTO_INCREMENT =1;

and
2.

CREATE TABLE `tutorials` (
`ID` tinyint(11) NOT NULL auto_increment,
`title` text NOT NULL,
`avatar` text NOT NULL,
`date` date NOT NULL default '0000-00-00',
`description` text NOT NULL,
`user` text NOT NULL,
`message` text NOT NULL,
PRIMARY KEY (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

ARE NOT THE SAME.

For table names and field names USE BACK TICK (`) OR NOTHING.
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Postby Buglish » Thu Aug 17, 2006 12:52 am

Nice its working now...Thank you.
Is it a Database Software thing that MySQL does not use the normal ' ?
Or did the Website hosting the Tutiorial make an error?
Though it is a PHP/MySQL Tutorial System.
http://www.webdesign.org/web/web-progra ... .8180.html
User avatar
Buglish
New php-forum User
New php-forum User
 
Posts: 26
Joined: Wed Aug 16, 2006 6:45 am
Location: South Africe

Postby Shiv » Thu Aug 17, 2006 1:46 am

Yes, I think the example on that link is wrong. It doesnt work.

MySQL doesnt accept single quote (') for table names and field names.
For normal string we use single quote (').

e.g.

SELECT `fname`, `lname` FROM `tblusers` where userid = 'viral'
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Postby gesf » Thu Aug 17, 2006 7:54 am

However, there's no need to use both single quotes (') or back tick (`).
Of course, i'm not talking about fields' values. Single quotes must be added when needed.
Example:
Code: Select all
INSERT INTO table SET id=20, name='john';
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Shiv » Thu Aug 17, 2006 7:45 pm

gesf wrote:However, there's no need to use both single quotes (') or back tick (`).
Of course, i'm not talking about fields' values. Single quotes must be added when needed.
Example:
Code: Select all
INSERT INTO table SET id=20, name='john';



Exactly, gesf is right. I never use back tick (`) for table or field names. It is just for syntax knowledge.
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Re: phpMyAdmin create table ERROR

Postby rolltone » Wed Oct 06, 2010 3:45 am

The Swiss government told the Associated Press Monday morning that it has rejected a request issued by the United States for Roman Polanski to be extradited to the states.
rolltone
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Oct 06, 2010 3:41 am

Re:

Postby phmyway » Thu Mar 10, 2011 1:23 am

gesf wrote:However, there's no need to use both single quotes (') or back tick (`).
Of course, i'm not talking about fields' values. Single quotes must be added when needed.
Example:
Code: Select all
INSERT INTO table SET id=20, name='john';


Yes, I usually use the double quotes at the beginning and at the end. In between there is nothing else as

$schedule = "CREATE TABLE pertile (
exam_year year NOT NULL ,
result decimal(10,0) NOT NULL,
tally_sum int(11) NOT NULL,
running_sum int(11) NOT NULL,
per_value decimal(10,2) NOT NULL
) TYPE=INNODB;
";

$result = mysql_query($schedule)
or die(mysql_error());
phmyway
New php-forum User
New php-forum User
 
Posts: 6
Joined: Mon Feb 28, 2011 11:45 pm


Return to phpMyAdmin

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron