B
B
Bobur Bakhritdinov2015-12-02 16:32:19
linux
Bobur Bakhritdinov, 2015-12-02 16:32:19

Bugs in PHP code?

Mistake #1 -

Fatal error: Cannot redeclare get_date_time() (previously declared in /var/www/clients/client1/web1/web/kinopoiskgrabber.php:19) in /var/www/clients/client1/web1/web/system/functions/functions .php on line 302

Script:
// Returns the current time in GMT in MySQL compatible format.
function get_date_time($timestamp = 0) {
  if ($timestamp)
    return date("Y-m-d H:i:s", $timestamp);
  else
    return date("Y-m-d H:i:s");
}

And here is the function itself for determining the time. When centos was standing, this script worked fine, but now it gives an error. I think problems with mysql or php settings.
//Определяем время
function get_date_time($timestamp = 0) {
  if ($timestamp)
    return date("Y-m-d H:i:s", $timestamp);
  else
    return date("Y-m-d H:i:s");
}

Mistake #2 -
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in

Safe_mode disabled
open_basedir commented out.
OS: ubuntu server 12.04 amd64
PHP: 5.3.10
ispconfig 3 installed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2015-12-02
@bakhritdinov_b

Mistake #1
Cause:
Function declared twice (or more)
Solution:

if (!function_exists('get_date_time')) {
    function get_date_time($timestamp = 0) {
      if ($timestamp)
        return date("Y-m-d H:i:s", $timestamp);
      else
        return date("Y-m-d H:i:s");
    }
}

Error #2
Cause:
php.ini
Solution:
php.net/manual/en/function.curl-setopt.php#95027

D
Dmitry Belyaev, 2015-12-02
@bingo347

By the 1st mistake, the get_date_time function has already been declared earlier. There can be several options here:
- The function declares some extension to php - the solution is either to find and disable this extension or rename this function
- The file with the function is connected several times

R
Robot, 2015-12-02
@iam_not_a_robot

Fatal error: Cannot redeclare get_date_time() (previously declared in

Because in the script you do not need to declare a function, but only call it:
The result of its work will be in the $a variable, and pass the $b variable to it for work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question