Parse error, unexpected T_STRING, expecting ',' or ';'

Last update on August 9, 2009 02:50 PM by jak58
Published by jad05

Parse error, unexpected T_STRING, expecting ',' or ';'







In PHP, a common problem that may arise while creating a PHP file is the parse error T_String. This happens when a programmer (or a code literate person) inserts an apostrophe in a series of codes already being limited by apostrophes. Having several apostrophes in a same command creates a huge conflict within the PHP document and the program will have huge problems in reading the codes that have been written.

Example 1


<?
echo 'we don't know';
?>

How to solve the problem


The above example can be solved simply by telling the program where to ignore the apostrophe, by inserting a slash before the apostrophe that is not being used as a command. Hence, the code above will be written as:
<?
echo 'we don\t know';
?>

Example 2


The Parse Error can also arise if the programmer has forgotten to insert the ; symbol at the end of the command.
<?
echo 'we \"don't\" know'
?>

Note: PHP is a simple program that asks for much attention. You should not have any problem with it if you pay enough attention to the logical flow of the program.
Best answers for « Parse error, unexpected T_STRING, expecting ',' or ';' » in :
Parse error: syntax error, unexpected $end Show Parse error: syntax error, unexpected $end When you program in PHP,it is most propable that you have encounterd such error: Parse error: syntax error, unexpected $end in Command line code on line 1 What causes this error? In...
Windows Error Codes and How to Fix them ShowWindows Error Codes and How to Fix them Below is a list of the most common error codes that you an face while using Windows and its basic components. Some solutions have been provided for you to try to solve them. You should also note that...
VISTA ERROR: MS-DOS FUNCTION INVALID ShowVISTA ERROR: MS-DOS FUNCTION INVALID Solution When trying to delete a file, Microsoft Vista display the following error message: Copy the file - An unexpected error fails operation. Note that the error code, which can help you...
ORA-00600 internal error code, arguments ShowORA-00600 internal error code, arguments This error code is native to internal exceptions from the Oracle programs. It indicates that the process has encountered an unexpected low. It may be due to timeout A corrupted file crash...
Download Windows Error Message Creator ShowThe chains which alert on viruses do not work any more, then made more extremely. If you want to scare your colleagues or your friends on their computer, the best means is of their envoy a message of error. Windows Error Message Creator is a very...
Error checking ShowError checking Binary encoding is very practical for use in electronic devices such as computers, in which information can be encoded based on whether an electrical signal is present or not. However, this electrical signal may suffer disturbances...