-3

I'm trying to uploade and use an old script i made way back, but it gives me an error:

PHP Warning: get_included_files() expects exactly 0 parameters, 1 given in

session_start();
ob_start();


get_required_files('config.php');
get_required_files('funksjoner.php');
Xp0sed
  • 1
  • 1
  • 1

1 Answers1

2

get_required_files (alias of get_included_files()) does not accept any parameters. It will return an array with all the included files (include, include_once, require and require_once).

A working example (from the reference of get_included_files()):

<?php
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';

// Get all included files
$included_files = get_included_files();

// Loop the files and show the filenames
foreach ($included_files as $filename) {
    echo "$filename\n";
}
?>

If you want to include a file, just use "include":

<?php
include 'config.php';
include 'funksjoner.php';
?>
Frank M
  • 170
  • 3
  • 14
  • Ah okey. But when I changed it I got a lof of other errors PHP Fatal error: Call to undefined function mysql_connect() in /home/nordipgg/public_html/funksjoner.php on line 20 PHP Notice: Undefined index: loggedinid in /home/nordipgg/public_html/config.php on line 10 PHP Notice: Undefined index: loggedinusr in /home/nordipgg/public_html/config.php on line 11 PHP Fatal error: Call to undefined function mysql_connect() in /home/nordipgg/public_html/funksjoner.php on line 20 – Xp0sed Nov 29 '16 at 21:53
  • Could you post some of the errors? Most of the errors caused by PHP can be fixed with searching on Stackoverflow. – Frank M Nov 29 '16 at 21:54
  • 1
    First error: mysql is deprecated. Use [mysqli](http://php.net/manual/en/mysqli.query.php) instead. – Frank M Nov 29 '16 at 21:59
  • All "undefined infex" errors means that the variable doesn't exists (isn't initialized). You can check if a variable exists with the following code: `if(isset($variable)){ // Do something }` – Frank M Nov 29 '16 at 22:01
  • I changed to mysqli and now it tells me it can't access database, hm wierd. However I don't understand how loggedinusr and loggedinid dosn't exist when it's a simpel session code in config you can see right under here. This is not newest php versions, but worked like hell for some years ago – Xp0sed Nov 29 '16 at 22:13
  • That is (maybe) because you didn't change the `mysql_select_db` function? Please check [this reference](http://php.net/manual/en/mysqli.select-db.php) how to do that. If that session is not set, you will get a notice that the index is undefined. Check if the session exists with `if(isset($_SESSION['loggedinid'])){ // It exists! } else{ // Doesn't exist! }` Or, if you want, you can give a default value to that session with this code: `$id = isset($_SESSION['']) ? $_SESSION['loggedinid'] : "Default value";` – Frank M Nov 29 '16 at 22:19
  • Correction: `$id = isset($_SESSION['loggedinid']) ? $_SESSION['loggedinid'] : "Default value";` – Frank M Nov 29 '16 at 22:23
  • Thanks a lof for all the tips Frank! I seems to have fixed those problems now, or you fixed it are more correctly. Now I got a new error, ofc. Error: PHP Fatal error: Cannot redeclare redirect() (previously declared. Code: `function redirect($url, $wait){ header("Refresh: $wait; url=$url"); }` – Xp0sed Nov 29 '16 at 23:21
  • It means you've already created a function with the name "redirect". Check [this thread](http://stackoverflow.com/questions/708140/php-fatal-error-cannot-redeclare-class) for more information. – Frank M Nov 30 '16 at 09:21