Jump to content

Help With Old PHP Code


amin1982

Recommended Posts

Hey Guys,

 

Some help needed please! I'm currently maintaining a website for a client however the site was written a while ago and is in PHP3 I believe. I have recently moved the site on my server which uses PHP 5. The site works ok however one feature on the site is having a back end which allows the user to login and add news, update, delete data... basically a custom content management system.

 

The only problem however is when we click on submit to update a page or news item the page goes white and nothing is saved.

 

The error logs show just one error which is:

 

[Wed Jul 25 14:56:00 2007] [error] [client 81.201.136.69] PHP Warning: Invalid argument supplied for foreach() in /home/bbwebmaster/public_html/administer/list.php on line 248, referer:

 

The code which this is talking about is:

 

if ($addentry)
$qry = "insert into ".$page." set ";

$first = "yes";
foreach ($HTTP_POST_VARS as $postvar_key => //**LINE 248**//
$postvar_value) {
if (($postvar_key != 'Submit_x') && ($postvar_key != 'Submit_y')) {
if ($first == "no")
$qry .= ",";
$qry .= $postvar_key."='".$postvar_value."'";
$first = "no";
}
}

 

 

I'm hoping that if I can fix this then the script will work... either that or downgrade my server to PHP3 OR 4 which I dont wish to do.

 

If you can suggest anything please let me know.

 

Thanks

Link to comment
Share on other sites

i assume it's because the $HTTP_POST_VARS variable isn't created anymore.  replace it with $_POST (its replacement) and you should see the error disappear.  keep in mind you'll need to do this site-wide, with all the superglobal arrays.

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.