要求任何带有函数的php文件生成500内部服务器错误

要求任何带有函数的php文件生成500内部服务器错误

问题描述:

I have a problem with require_once './DBFunctions.php'; rather server generate this error once I require any file with function even before call that function, btw my code is working correctly locally (i.e., this error only when I test scripts on server) .

My question is there any error with function keyword in php version 5.2.5 ?(I use mysql library instead of mysqli cause it's not supported on my server ).

This is my code ,

index.php

<?php  require_once "./DBfun.php" ?>
<!-- html goes here -->

DBfun.php

 <?php require_once './DBConfig.php';

 function sanitize(&$data) {
return htmlentities(strip_tags(mysql_real_escape_string($data)));}

function isExist($username) {
    $username = sanitize($username);
   $query = "SELECT * FROM `USERS` WHERE `USERNAME` ='$username' AND `STATUS`=1";
$result = mysql_query($query);
$row_cnt = mysql_num_rows($result);
$r = ($row_cnt == 1) ? "1 row matched (User Exist)" : " No matched found (User does 't      exist)";
$log = "Query: " . $query . PHP_EOL . "Result: " . $r . PHP_EOL;
//file_put_contents(LOG_FILE, $log, FILE_APPEND | LOCK_EX);
// destruct($result);
return ($row_cnt == 1) ? TRUE : FALSE;}
 ?>

I tested everything DB connection, queries (retrive data & display it), ajax requests, require files even nested requires etc.. without functions, & it worked for me, the error appear when I use (uncomment) any function =(

The error I get :

 GET http://192.168.0.36/ProjectName/index.php 500 (Internal Server Error) 

You can check if the file exists before you require .. however i'm sure this is not the problem.

<?php

    $file = './path/to/file.php';

    if (is_file($file))
    {
        require_once($file);
    }

?>

Thanks all for help The Problem was in the version of php on the Server Where pre-defined function array_map which I used in my script