Sudhin
Sudhin

Reputation: 57

what is the correct syntax for MySQL alter table query?

While I try to run the following mysqli call

$strSQL3=mysqli_query($connection," alter table mark_list add column 'mark' int(2) " ) or die(mysqli_error($connection));

returns error

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 `mark int(2)` at line 1

Upvotes: 2

Views: 254

Answers (3)

I'm Geeker
I'm Geeker

Reputation: 4637

Simply you need to remove the quotes near 'mark

$strSQL3=mysqli_query($connection," alter table mark_list add column mark int(2) " ) or die(mysqli_error($connection));

Upvotes: 1

dsharew
dsharew

Reputation: 10665

Try changing 'mark' to mark like this:

    $strSQL3=mysqli_query($connection,
             " alter table mark_list add column mark int(2) " ) 
              or die(mysqli_error($connection));

Upvotes: 2

Mureinik
Mureinik

Reputation: 311163

Single quotes (') denote string literals. Object names (such as columns), are not strings - juts lose the quotes:

$strSQL3 = mysqli_query($connection ,"alter table mark_list add column mark int(2)" ) or die(mysqli_error($connection));

Upvotes: 2

Related Questions