...

View Full Version : if Statement causing an error



ScottInTexas
07-31-2007, 11:42 PM
I get this error

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

which points to the if statement shown in the code below. I copied the lines below also. I am getting this straight from a book so I don't see what is wrong with it. I have tried commenting out other lines thinking it may actually be somewhere else that throws the error, but no good.


if (isset($_POST['submit'])) {
//from has been submitted
if(ini_get('magic_quotes_gpc')) { //see if magic quotes are turned on
$pattern=stripslashes($_POST['pattern']);
$string=stripslashes($_POST['string']);
}else{
$pattern=$_POST['pattern'];
$string=$_POST['string'];
}
$pattern=trim('$pattern');
$string=trim('string');
}else{ //form has not been submitted
$pattern='';
$string='';
}

CFMaBiSmAd
08-01-2007, 12:43 AM
That particular piece of code by it self does not generate an error. Post at least 20 lines of code prior to that. Also, use the php code tags (the little folded corner paper icon with "php" on it) around the code in your post to get the highlighting to help find things like mis-matched quotes. Posting the line number part of the error message and indicating which line in the posted code that refers to would also help.

ScottInTexas
08-01-2007, 01:23 AM
NEVER MIND! It was there and I couldn't see it. Literally! My contacts suck. Instead of a tilde in the error handling I had a single quote `


error_reporting(E_ALL & `E_NOTICE);


This line was just prior to the if.

None of this matters now except as an example of stupid errors.
New rule. Forget the contacts use cheesy reading glasses when working on my computer.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum