Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Błąd w "throw new" po wgraniu na nowy serwer.
Forum PHP.pl > Forum > PHP
luktoja
Witam.

Ostatnio niestety musiałem przenieść jeden z serwisów na inny serwer. Bazy danych są zainstalowane, serwis także.
Teoretycznie wszystko powinno być w porządku, ale wyskakuje mi błąd:


"Parse error: syntax error, unexpected T_NEW in
/home/serwis.pl/libs/adodb/adodb-exceptions.inc.php
on line 78"

O co chodzi?? Poniżej wklejam kod pliku "adodb-exceptions.inc.php". Zwróćcie uwagę na to, że Autor pisze coś takiego:
"
Exception-handling code using PHP5 exceptions (try-catch-throw)." Czy wersja PHP na nowym serwerze ma jakiś związek z tym błędem? Uprzejmie proszę o pomoc - nie mam pojęcia jak rozwiązać ten problem.

  1. <?php
  2. /**
  3.  * @version V4.90 8 June 2006  (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
  4.  * Released under both BSD license and Lesser GPL library license.
  5.  * Whenever there is any discrepancy between the two licenses,
  6.  * the BSD license will take precedence.
  7.  *
  8.  * Set tabs to 4 for best viewing.
  9.  *
  10.  * Latest version is available at <a href=\"http://php.weblogs.com\" target=\"_blank\">http://php.weblogs.com</a>
  11.  *
  12.  * Exception-handling code using PHP5 exceptions (try-catch-throw).
  13.  */
  14.  
  15.  
  16. if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
  17. define('ADODB_ERROR_HANDLER','adodb_throw');
  18.  
  19. class ADODB_Exception extends Exception {
  20. var $dbms;
  21. var $fn;
  22. var $sql = '';
  23. var $params = '';
  24. var $host = '';
  25. var $database = '';
  26.    
  27.    function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
  28.    {
  29.        switch($fn) {
  30.        case 'EXECUTE':
  31.            $this->sql = $p1;
  32.            $this->params = $p2;
  33.            $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
  34.            break;
  35.    
  36.        case 'PCONNECT':
  37.        case 'CONNECT':
  38.            $user = $thisConnection->user;
  39.            $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
  40.            break;
  41.        default:
  42.            $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
  43.            break;
  44.        }
  45.    
  46.        $this->dbms = $dbms;
  47.        if ($thisConnection) {
  48.            $this->host = $thisConnection->host;
  49.            $this->database = $thisConnection->database;
  50.        }
  51.        $this->fn = $fn;
  52.        $this->msg = $errmsg;
  53.                
  54.        if (!is_numeric($errno)) $errno = -1;
  55.        parent::__construct($s,$errno);
  56.    }
  57. }
  58.  
  59. /**
  60. * Default Error Handler. This will be called with the following params
  61. *
  62. * @param $dbms        the RDBMS you are connecting to
  63. * @param $fn        the name of the calling function (in uppercase)
  64. * @param $errno        the native error number from the database
  65. * @param $errmsg    the native error msg from the database
  66. * @param $p1        $fn specific parameter - see below
  67. * @param $P2        $fn specific parameter - see below
  68. */
  69.  
  70. function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
  71. {
  72. global $ADODB_EXCEPTION;
  73.    
  74.    if (error_reporting() == 0) return; // obey @ protocol
  75.    if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
  76.    else $errfn = 'ADODB_EXCEPTION';
  77.    throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
  78.  
  79. }
  80.  
  81.  
  82. ?>
wrzasq
Jasne, że ma, przecież inaczej by tego nikt tam nie pisał. Wyjątki zostały wprowadzaone w PHP5.

phpinfo(); -> PHP Version -> pewnie jest <5.0
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.