I have an error in your SQL syntax;

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanehenery
    New Member
    • Feb 2010
    • 24

    I have an error in your SQL syntax;

    Hi

    I am getting this error #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 '$result="CREAT E TABLE 'course`(
    `cname` varchar(50) NOT NULL default,
    `cid` in' at line 1
    when I am adding my code to the data base
    I dont understand the error that well and cant find any problem to my code can you pleas help is is my server ore my actual code

    Code:
    $result="CREATE TABLE 'course`(
    `cname` varchar(50) NOT NULL default,
    `cid` int(6) NOT NULL auto_increment,
    PRIMARY KEY (`cid`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
    
    
    $sno="CREATE TABLE `course_student`(
    `sno` int(6) NOT NULL default '0',
    `cid` int(6) NOT NULL default '0',
    `year` int(4) NOT NULL default '0'
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1";
    Thanks
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Course table is surrounded by a comma and a back-tick. Start and end characters must be the same, can't combine different characters.

    Code:
    turn this 
    
    CREATE TABLE 'course`(
    
    into 
    
    CREATE TABLE `course`(
    Dan

    Comment

    • shanehenery
      New Member
      • Feb 2010
      • 24

      #3
      Hi

      I have changed that and made it all the same

      Code:
       $result="CREATE TABLE `course`(
      `cname` varchar(50) NOT NULL default,
      `cid` int(6) NOT NULL auto_increment,
      PRIMARY KEY (`cid`)
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
      but I am still getting the same error

      Comment

      • usmanhalalit
        New Member
        • May 2010
        • 4

        #4
        Try this

        Code:
        $result="CREATE TABLE `course`(
        `cname` varchar(50) NOT NULL default '',
        `cid` int(6) NOT NULL auto_increment,
        PRIMARY KEY (`cid`)
        )  ENGINE = MYISAM CHARACTER SET latin1";

        Comment

        Working...