Jump to content

Parse error: syntax error, unexpected T_IF


ladygreen

Recommended Posts

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! 

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.