user725913
user725913

Reputation:

PHP SQL unexpected T_STRING Error

I keep getting the error

Parse error: syntax error, unexpected T_STRING on line #9

This is the line that is attempting to add the column. I have double, and triple checked that the table does indeed exist - and that I am able to access it.

<?php

mysql_connect ("localhost","user","pass") or die ('Error: ' . mysql_error());

echo "connected to database!";

mysql_select_db ("database");

      $query = ALTER TABLE CustomerInformation
 ADD supplier_name varchar2(50);


      $result = mysql_query($query) 
        or die("altering table Customer Information not successful: ".
        mysql_error()); 

?>

Upvotes: 0

Views: 1336

Answers (2)

Shef
Shef

Reputation: 45589

Change:

$query = ALTER TABLE CustomerInformation
 ADD supplier_name varchar2(50);

to

$query = 'ALTER TABLE CustomerInformation ADD supplier_name varchar2(50)';

Upvotes: 1

cusimar9
cusimar9

Reputation: 5259

This is your problem

$query = ALTER TABLE CustomerInformation ADD supplier_name varchar2(50);

should be changed to

$query = 'ALTER TABLE CustomerInformation ADD supplier_name varchar2(50)';

Your $query variable holds a STRING which is passed to mysql_query and used as a command.

Upvotes: 7

Related Questions