Parse Error in PHPLD 2

Discussion in 'Directories' started by jhmattern, Sep 27, 2006.

  1. #1
    I was just trying to insert a fix to get the symbolic categories showing as not blank. I added the code given to the bottom of the fuctions.php file, and got the following error afterwards:

    Parse error: syntax error, unexpected T_DNUMBER in /home/jhm2980/public_html/freedeeplinks/include/functions.php on line 146

    I deleted the code that I had inserted, and the error is still coming up. Here is the code around that line:

    function get_client_ip() {
    	if (isset ($_SERVER['HTTP_X_FORWARDED_FOR']))
    		70.84.62.194Address = $_SERVER['HTTP_X_FORWARDED_FOR'];
    	else
    		70.84.62.194Address = $_SERVER['REMOTE_ADDR'];
    	return 70.84.62.194Address;
    }
    Code (markup):
    This area wasn't touched at all, so I don't know why an error would suddenly be showing. Does anyone know what could be going on?

    Thanks!

    Jenn
     
    jhmattern, Sep 27, 2006 IP
  2. emz

    emz Peon

    Messages:
    364
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I could be wrong but those don't look anything like php variables being defined ... T_DNUMBER means there is a decimal numeric error ("70.84.62.194Address") .. I don't understand the coding exactly. It looks as if "70.84.62.194Address" was supposed to be defined earlier in the script as a constant using define() or something similar but I don't even think those constants can start with a number.
     
    emz, Sep 27, 2006 IP
  3. jhmattern

    jhmattern Illustrious Member

    Messages:
    8,909
    Likes Received:
    794
    Best Answers:
    2
    Trophy Points:
    455
    #3
    I really have no idea. This is the first time I touched this file, and I didn't touch anything that was already there - just added then deleted something at the end that had nothing to do with the area where the error apparently is. I don't know anything really about php. I was just following pretty simple instructions from http://www.phplinkdirectory.com/forum/showthread.php?p=37495

    The problem is that the plan was to work on this site all day, and I can't access anything until I get it fixed. I just don't understand how a problem could be showing up earlier in the code when everything was fine before and it hasn't been changed. :(
     
    jhmattern, Sep 27, 2006 IP
  4. emz

    emz Peon

    Messages:
    364
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi again,

    I think I've figured it out....

    Somehow the PHP variable prefix "$" was replaced by an actual IP address which is causing the T_DNUMBER error and your script to screw up..

    Heres what you should have:

    function get_client_ip() {
    	if (isset ($_SERVER['HTTP_X_FORWARDED_FOR']))
    		$Address = $_SERVER['HTTP_X_FORWARDED_FOR'];
    	else
    		$Address = $_SERVER['REMOTE_ADDR'];
    	return $Address;
    }
    Code (markup):
     
    emz, Sep 27, 2006 IP
  5. jhmattern

    jhmattern Illustrious Member

    Messages:
    8,909
    Likes Received:
    794
    Best Answers:
    2
    Trophy Points:
    455
    #5
    Wonderful. It seems to be working now even with the original fix. :) I have no idea how an ip address got in there - didn't look like a familiar one - but thank you so much. You just salvaged my afternoon. :)
     
    jhmattern, Sep 27, 2006 IP