Whey does this evaluate to true?
\'; }else{
Give this a try: $val2==='error123'
$val2==='error123'
That will evaluate the value and the type of the variable. More here:
http://us.php.net/manual/en/language.operators.comparison.php