0

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()); 

?>

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

3 Comments

should actually be 'ALTER TABLE CustomerInformation ADD supplier_name varchar2(50)';
!!! Awesome! Thank you so much! How can I be sure when I need to use " ' " vs quotations in PHP?
You always use quotes to enclose string values. Only functions / variables / constants / reserved words are not.
1

Change:

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

to

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.