ladygreen Posted September 15, 2012 Share Posted September 15, 2012 Hi.. Im new here, but read your forum alot! I am having a PHP issue and getting an error. Here is the script: function check_referer($referers) { global $errors; if (count($referers)) { if (getenv('HTTP_REFERER')) { $temp = explode('/', getenv('HTTP_REFERER')); $found = false; while (list(,$stored_referer) = each($referers)) { preg_match if (preg_match('^' . $stored_referer . '$', $temp[2])) $found = true; } The RED line is the issue. Driving me crazy! Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/ Share on other sites More sharing options...
jcbones Posted September 15, 2012 Share Posted September 15, 2012 preg_match /*<-if that is really in your script, you need to remove it... */ if (preg_match('^' . $stored_referer . '$', $temp[2])) $found = true; Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378061 Share on other sites More sharing options...
Jessica Posted September 15, 2012 Share Posted September 15, 2012 Well, you have preg_match then if... Also if you read the forum a lot you should know to use code tags. Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378062 Share on other sites More sharing options...
ladygreen Posted September 15, 2012 Author Share Posted September 15, 2012 I have had the same script running on a website for several years. All of a sudden one day.... I started getting errors on it. They are below: Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 94 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 94 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 94 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 130 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 130 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 130 Deprecated: Function eregi() is deprecated in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 130 Warning: Cannot modify header information - headers already sent by (output started at /home/content/r/e/l/relfingrp/html/scripts/formmail.php:94) in /home/content/r/e/l/relfingrp/html/scripts/formmail.php on line 500 I asked a friend for help, and he put in the preg_match code.... then the only error I got was the one I started this post with. This error is causing the forms not to work They do not send the form to the email. Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378073 Share on other sites More sharing options...
Christian F. Posted September 15, 2012 Share Posted September 15, 2012 The reason is explained in the sticky "ereg and "deprecated" error", which you can find in the "PHP regex" section. Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378128 Share on other sites More sharing options...
ladygreen Posted September 16, 2012 Author Share Posted September 16, 2012 Can anyone see anything wrong with this line? <code> preg_match if (preg_match("~ '^' . $stored_referer . '$', $temp[2])~i"); </code> Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378439 Share on other sites More sharing options...
Pikachu2000 Posted September 16, 2012 Share Posted September 16, 2012 Well, you have preg_match then if... Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378440 Share on other sites More sharing options...
jazzman1 Posted September 16, 2012 Share Posted September 16, 2012 Can anyone see anything wrong with this line? <code> preg_match if (preg_match("~ '^' . $stored_referer . '$', $temp[2])~i"); </code> Take a look at examples: http://php.net/manual/en/function.preg-match.php Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1378441 Share on other sites More sharing options...
jcbones Posted September 18, 2012 Share Posted September 18, 2012 Good grief, I gave the answer in the first reply. Maybe it needs a repeat, and/or clarification. preg_match /*<===== if that is really in your script, you need to remove it...*/ if (preg_match('^' . $stored_referer . '$', $temp[2])) $found = true; Read the comment, look at where it is pointing. If that "preg_match" really resides as the first line of your IF clause, then remove it, it is invalid syntax as it is a function call without arguments. Quote Link to comment https://forums.phpfreaks.com/topic/268397-parse-error-syntax-error-unexpected-t_if/#findComment-1379090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.