0

i got this unexpected error after site builder set up. Since I'm not familiar with CSS or PHP scripts, I'm not able to see the error which should be on line 8 and line 19 (according to the 500 error code).

There was no closing line (?>) at the end of the script, which is now added by me. Can you plese help me to fix other errors? thank you in advance for your help

<?php
/**
 * @see       https://github.com/zendframework/zend-diactoros for the canonical source repository
 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
 * @license   https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
 */

declare(strict_types=1); // Error highlighted issue with this line.

namespace Zend\Diactoros;

/**
 * Create an uploaded file instance from an array of values.
 *
 * @param array $spec A single $_FILES entry.
 * @throws Exception\InvalidArgumentException if one or more of the tmp_name,
 *     size, or error keys are missing from $spec.
 */
function createUploadedFile(array $spec) : UploadedFile // Error highlighted issue with this line.
{
    if (! isset($spec['tmp_name'])
        || ! isset($spec['size'])
        || ! isset($spec['error'])
    ) {
        throw new Exception\InvalidArgumentException(sprintf(
            '$spec provided to %s MUST contain each of the keys "tmp_name",'
            . ' "size", and "error"; one or more were missing',
            __FUNCTION__
        ));
    }

    return new UploadedFile(
        $spec['tmp_name'],
        $spec['size'],
        $spec['error'],
        isset($spec['name']) ? $spec['name'] : null,
        isset($spec['type']) ? $spec['type'] : null
    );
}
?>
Mark
  • 1,852
  • 3
  • 18
  • 31
efemeris
  • 1
  • 1
  • 3
    What errors you receiving? The `?>` is not always necessary, so isn't an actual error. And what version of PHP are you running? Return type declarations, such as `function createUploadedFile(array $spec) : UploadedFile`, is only available in PHP7 – aynber Aug 02 '19 at 14:35
  • Add this to the top of your script, after the – Mark Aug 02 '19 at 14:38
  • hi, thank you for your replies. i have purchased a hosting plan that offers free RVsitebuilder7. The error occured right after the RV set up, so i'm not able to edit or repair the website until i fix the issue in the File Manager rvsitebuildercmssrc/functions/create_uploaded_file.php – efemeris Aug 02 '19 at 14:44
  • 1
    But what is the issue? Without the exact error messages you're receiving, we can't tell you what's wrong. – aynber Aug 02 '19 at 14:47
  • i'm getting a 500 error message. you can see it here https://www.eligodesign.com/ – efemeris Aug 02 '19 at 14:48
  • 1
    Your hosting provider probably gives you access to the error logs. Can you check them and edit the question with the errors you find there? – Caconde Aug 02 '19 at 14:48
  • 1
    A 500 error is a generic error message and covers pretty much every single thing that can go wrong with a script. Check your server error logs to find out the exact error message. – aynber Aug 02 '19 at 14:50
  • the error logs folder is empty. see here https://imgur.com/a/NbvTmqD – efemeris Aug 02 '19 at 14:58
  • i have found only this here https://imgur.com/rIcB1Wm – efemeris Aug 02 '19 at 15:01
  • Possible duplicate of [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – aynber Aug 02 '19 at 15:06
  • i have found an error log file in the public_html folder http://www.mediafire.com/file/c0i8km65pnaekzu/error_log/file – efemeris Aug 02 '19 at 15:15
  • @anyber i'm trying to find that out. – efemeris Aug 02 '19 at 15:17
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Dharman Aug 02 '19 at 15:23
  • @Dharman thank you for the link. I'll have go through all links before I can figure out where the problem is. since i have zero knowledge i really doubt that I can find and fix errors without help – efemeris Aug 02 '19 at 15:32
  • my php folder is empty, so i cannot find any .ini file. another question someone suggested File Zilla. Is anyone familiar with this editor? – efemeris Aug 02 '19 at 15:51
  • @efemeris filezilla is an ftp client, you can use it to get files from the server to your computer and vice-versa – Stratadox Aug 02 '19 at 18:47
  • Which php version are you using? The `declare(strict_types=1);` thing only works on 7 and up, I believe. Try removing that line. (removing it is harmless) – Stratadox Aug 02 '19 at 18:49

1 Answers1

0

Given the errors are about the only lines that consist of php7+ only code, the problem is likely an outdated version of php.

There are two solutions: the better solution is to upgrade your php version to 7.2; ask your hosting provider if they're able to accommodate you in that regard.

Your other option is probably faster: simply remove the php7 code. The problem is about these parts:

declare(strict_types=1);

And

(...) : UploadedFile

Both of these can be removed without consequence.

In short: Remove line 8, and replace line 19 with:

function createUploadedFile(array $spec)

Edit:

To do it really well, you might consider adding this:

 * @return UploadedFile

Right between the lines with @param and @throws. It's the php5.x alternative for : UploadedFile.

PS: The ?> thing is supposed to be missing. Having it still works in most cases, but taking it out again is the better way.

Stratadox
  • 1,291
  • 8
  • 21
  • thank you very much for your answer and instructions. i have contacted my hosting provider. they have told me that they are right now doing updates on the RVsitebuilder7. I gues it is PHP version 7. i will try to change the script according to your instruction and let you know if it works or not. – efemeris Aug 03 '19 at 13:03
  • hello, have tried to change the script. it just wont work. i have to wait till my host has finished with RVsitebuilder updates. thank you anyway for taking your time to help me out :) – efemeris Aug 03 '19 at 13:52
  • Looks like this site builder requires php 7.1 or higher - which kind of makes sense since that's the minimal supported version right now. In the script you've showed I see no other php7 specific code, but it's very likely these mismatches occur elsewhere too. You could take them all out, but upgrading the php version is definitely your best bet. – Stratadox Aug 04 '19 at 11:25