My php code to creating sql table from localhost is successful but after uploading the file to the server, table is not created. Help!?

Code:

$sql = "CREATE TABLE $classestable (         Classname VARCHAR(50) NOT NULL,        Option VARCHAR(50) NOT NULL,        Level VARCHAR(50) NOT NULL,        Status  VARCHAR(50) NOT NULL,        Year  VARCHAR(50) NOT NULL,        Teacher VARCHAR(50) NOT NULL,        Password VARCHAR(50) NOT NULL,        Fullname VARCHAR(50) NOT NULL,        Date VARCHAR(50) NOT NULL,        Listname VARCHAR(50) NOT NULL,        Subjectname1 VARCHAR(50) NOT NULL,        Subjectname2 VARCHAR(50) NOT NULL,        Subjectname11 VARCHAR(50) NOT NULL,        Subjectname22 VARCHAR(50) NOT NULL,        Subjectname111 VARCHAR(50) NOT NULL,        Subjectname222 VARCHAR(50) NOT NULL,        Term1name VARCHAR(50) NOT NULL,        Term2name VARCHAR(50) NOT NULL,        Term3name VARCHAR(50) NOT NULL,        Yearname VARCHAR(50) NOT NULL,        Term1name2 VARCHAR(50) NOT NULL,        Term2name2 VARCHAR(50) NOT NULL,        Term3name2 VARCHAR(50) NOT NULL,        Yearname2 VARCHAR(50) NOT NULL,        Photoname VARCHAR(50) NOT NULL,        Folder VARCHAR(50) NOT NULL        )";if ($con->query($sql) === TRUE) {} else {    echo "Error creating classes table.";}

where $classestable is a defined variable

From server this code is not successful but on my Computer from localhost the code is successful.

Anyone can help?

2 Answers

Relevance
  • Chris
    Lv 7
    1 month ago

    Turn on error reporting and you should get an error message telling you what the issue is.

    If I had to guess, the most likely reason is not this query but the database connection to the mysql server. You did remember to change the details to those of the online server, right? (hostname, username, password, db) Also, did you create a db? Because in order to create a table, you need to create and select a db first.

    • NYANJA1 month agoReport

      The problem is that there are some table that are created successful but on of them is not created successful. i don't see any mistake in that code. Also error reporting is on but nothing i getting as error

    • Commenter avatarLogin to reply the answers
  • P
    Lv 7
    1 month ago

    Hard to say without more detail, however I would make sure you are transferring it to the server using ASCII FTP protocol and not binary as things default to.  If that doesn't work it's better to ask in a PHP forum.  

    • NYANJA1 month agoReport

      Can I get a link for PHP forum?

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.