Jump to content

[SOLVED] Syntax errors - completely confused...


S_M_E

Recommended Posts

I know next to nothing about PHP and I have two pages that are giving me fits. They work on newer PHP5 but they display blank, with errors in the log, on PHP4. I assume they've changed the syntax but I'm completely lost.

 

[Wed Nov 19 09:56:20 2008] [error] PHP Parse error:  syntax error, unexpected ',', expecting '(' in /hsphere/local/home/etc/etc.php on line 8

 

Here is line 8:               

                if(mail(MainConfig::$mail, "Contact Us","$_POST[comments]"))

 

Another page has the same error in the log on a different line:

 

                $file = fopen(MainConfig::$filename, "r");

 

If that's not enough information I can include more of the code, I just thought I'd keep this post small, if possible.

 

It appears that it doesn't like "(MainConfig::$etc, " on either line but I have no idea how to fix it so it'll work with older PHP and newer PHP. I'd appreciate any help.

 

TIA...

 

Link to comment
Share on other sites

Actually, the first one is part of a contact form, the second one takes names from a text file and displays them on the page.

 

If you need more of the code because my post didn't make sense:

 

<?php

       

        $email_sent = 0;

       

        if(isset($_POST["contact"])){

                require("./config.php");

               

                if(mail(MainConfig::$mail, "Contact Us","$_POST[comments]"))

                        $email_sent = 1;

        }

 

?>

 

The second one:

 

<?php

                                       

                                        include("./config.php");

                                       

                                        $file = fopen(MainConfig::$filename, "r");

                                       

                                        if($file){

                                               

                                                while($line = fgets($file)){

                                ?>

                                        <h3><?php echo "$line"; ?></h3>

                <?php         

                                                }

                                       

                                        }

                                       

                                ?>

 

Hope that makes more sense but I'm still lost.  :P

Link to comment
Share on other sites

Seems to be some kind of static registry class. I'm not sure PHP4's object model has static classes implemented, but from skimming through manual it doesn't seem so. In such case this code would require some serious work to port it to PHP4

Link to comment
Share on other sites

In such case this code would require some serious work to port it to PHP4

 

That's what I was afraid of. I doubt the hosting company will upgrade to PHP5 anytime soon either...

 

PHP4's end of life support was December '07.  Its object model is poorly implemented and lacking in features of most advanced OOP languages.  It also lacks several new functions and code revisions.  No hosting company should still be using PHP4.  Switch companies or write them a nice big e-mail explaining why they should use PHP5.

Link to comment
Share on other sites

Upgrade your hosting company then. If they still don't have PHP5 they're like in stone age of hosting companies.

 

On the other hand, maybe they do? Better check it. Some hosting companies have actually two versions of PHP running at one time, and to use PHP5 you have to save your files as *.php5

 

On the third hand: I might be wrong.

Link to comment
Share on other sites

Upgrade your hosting company then. If they still don't have PHP5 they're like in stone age of hosting companies.

 

On the other hand, maybe they do? Better check it. Some hosting companies have actually two versions of PHP running at one time, and to use PHP5 you have to save your files as *.php5

 

On the third hand: I might be wrong.

 

You have three hands?  Lucky. :(

Link to comment
Share on other sites

MainConfig: << is this part off a class.......

 

Yes, both pages read from config.php to get the name of the file to read from and to get the email address to use for the contact form:

 

<?php

// SET THE CONTACT US EMAIL IN THIS LINE

MainConfig::set_email("info@some.addy");

//SET THE DISPLAY TXT FILE PATH IN THIS LINE

MainConfig::set_display("text.txt");

 

class MainConfig{

 

static $mail = "";

static $filename = "";

 

static function set_email($email){

self::$mail = $email;

}

 

static function set_display($filename){

self::$filename = $filename;

}

 

}

 

?>

Link to comment
Share on other sites

That class is absolutely useless.  Why not just use a regular variable? o_O

 

I didn't write it, I'm just trying to fix it so it'll work. However, it works fine with PHP5 :D

 

(EDIT)

FYI:

Apache/1.3.39 (Unix) PHP/4.4.7 mod_throttle/3.1.2 FrontPage/5.0.2.2635 mod_psoft_traffic/0.2 mod_ssl/2.8.29 OpenSSL/0.9.7e-p1

 

Link to comment
Share on other sites

That's all of the php, the rest is just html.

 

I talked to the hosting company and they don't want to upgrade to php5 becasue some customers have code they think will break and they are worried that their control panel will break with php5 too. They're looking at either adding php5, as mchl suggesting they could, or moving my site to a different server. Either will work for me, I just want the code to work...

 

Thanks guys...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.