php -vの実行結果
$ php -v PHP 5.4.45 (cli) (built: Sep 11 2015 21:23:18) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
employerlist.php
<?php //設定ファイル読み込み require_once("./database_config.php"); session_save_path('/home/a_yonamine/session/'); session_start(); $login_name=$_SESSION["employer_name"]; $login_id=$_SESSION["employer_id"]; // データベースに接続 $link=mysqli_connect(DB_SERVER, DB_ACCOUNT_ID, DB_ACCOUNT_PW, DB_NAME); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } // 抽出する際のエンコードを設定 mysqli_set_charset($link,"utf8"); // Query // 従業員リストを抽出 $query='select employer_master.user_id,employer_master.name,department_master.department_name from employer_master,department_master where employer_master.department_id=department_master.department_id order by employer_master.id'; // 後ほどhtmlファイルで置き換えするための変数の初期化 $employer_line=""; //Execute if ($result = mysqli_query($link, $query)) { // if no one matched, move login $i=0; while ($row = mysqli_fetch_row($result)) { $employer_account_id[$i] = $row[0]; $employer_name[$i] = $row[1]; $employer_department[$i] = $row[2]; // 一覧用の値をセット $employer_line.="<tr><td>".$employer_account_id[$i]."</td><td>".$employer_name[$i]."</td><td>".$employer_department[$i]."</td><td><a href='./employerdetail.php?ei=".$employer_account_id[$i]."'>詳細画面へ</a></td></tr>\n"; $i++; } /* 結果セットを開放します */ mysqli_free_result($result); } mysqli_close($link); // ファイル内容を変数に取り込む $fp=fopen('./employerlist.html','r'); // ファイルの最後まで処理を行う while(!feof($fp)) { // 1行ずつファイルを読み込み変数にセット $line=fgets($fp); // データベースからセットする項目について置き換え(動的部分) // ログイン名 $line1=str_replace("<###LOGINNAME###>",$login_name,$line); // 従業員リスト $lines=str_replace("<###EMPLOYERLIST###>",$employer_line,$line1); echo $lines; } fclose($fp); exit(); ?>
php.iniのsessionの部分
[Session] session.save_handler = files session.use_only_cookies = 1 ; Name of the session (used as cookie name). ; http://php.net/session.name session.name = PHPSESSID ; Initialize session on request startup. ; http://php.net/session.auto-start session.auto_start = 0 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. ; http://php.net/session.cookie-lifetime session.cookie_lifetime = 0 ; The path for which the cookie is valid. ; http://php.net/session.cookie-path session.cookie_path = / ; The domain for which the cookie is valid. ; http://php.net/session.cookie-domain session.cookie_domain = ; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript. ; http://php.net/session.cookie-httponly session.cookie_httponly = ; Handler used to serialize data. php is the standard serializer of PHP. ; http://php.net/session.serialize-handler session.serialize_handler = php ; Default Value: 1 ; Development Value: 1 ; Production Value: 1 ; http://php.net/session.gc-probability session.gc_probability = 1 ; Default Value: 100 ; Development Value: 1000 ; Production Value: 1000 ; http://php.net/session.gc-divisor session.gc_divisor = 1000 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. ; http://php.net/session.gc-maxlifetime session.gc_maxlifetime = 1440 ; Default Value: On ; Development Value: On ; Production Value: Off ; http://php.net/session.bug-compat-42 session.bug_compat_42 = Off ; This setting controls whether or not you are warned by PHP when initializing a ; session value into the global space. session.bug_compat_42 must be enabled before ; these warnings can be issued by PHP. See the directive above for more information. ; Default Value: On ; Development Value: On ; Production Value: Off ; http://php.net/session.bug-compat-warn session.bug_compat_warn = Off ; Check HTTP Referer to invalidate externally stored URLs containing ids. ; HTTP_REFERER has to contain this substring for the session to be ; considered as valid. ; http://php.net/session.referer-check session.referer_check = ; How many bytes to read from the file. ; http://php.net/session.entropy-length ;session.entropy_length = 32 ; Specified here to create the session id. ; http://php.net/session.entropy-file ; Defaults to /dev/urandom ; On systems that don't have /dev/urandom but do have /dev/arandom, this will default to /dev/arandom ; If neither are found at compile time, the default is no entropy file. ; On windows, setting the entropy_length setting will activate the ; Windows random source (using the CryptoAPI) ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. ; http://php.net/session.cache-limiter session.cache_limiter = nocache ; Document expires after n minutes. ; http://php.net/session.cache-expire session.cache_expire = 180 session.use_trans_sid = 0 ; Select a hash function for use in generating session ids. ; Possible Values ; 0 (MD5 128 bits) ; 1 (SHA-1 160 bits) ; This option may also be set to the name of any hash function supported by ; the hash extension. A list of available hashes is returned by the hash_algos() ; function. ; http://php.net/session.hash-function session.hash_function = 0 ; Define how many bits are stored in each character when converting ; the binary hash data to something readable. ; Possible values: ; 4 (4 bits: 0-9, a-f) ; 5 (5 bits: 0-9, a-v) ; 6 (6 bits: 0-9, a-z, A-Z, "-", ",") ; Default Value: 4 ; Development Value: 5 ; Production Value: 5 ; http://php.net/session.hash-bits-per-character session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" ; Enable upload progress tracking in $_SESSION ; Default Value: On ; Development Value: On ; Production Value: On ; http://php.net/session.upload-progress.enabled ;session.upload_progress.enabled = On ; Cleanup the progress information as soon as all POST data has been read ; (i.e. upload completed). ; Default Value: On ; Development Value: On ; Production Value: On ; http://php.net/session.upload-progress.cleanup ;session.upload_progress.cleanup = On ; A prefix used for the upload progress key in $_SESSION ; Default Value: "upload_progress_" ; Development Value: "upload_progress_" ; Production Value: "upload_progress_" ; http://php.net/session.upload-progress.prefix ;session.upload_progress.prefix = "upload_progress_" ; ; Default Value: "PHP_SESSION_UPLOAD_PROGRESS" ; Development Value: "PHP_SESSION_UPLOAD_PROGRESS" ; Production Value: "PHP_SESSION_UPLOAD_PROGRESS" ;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS" ; How frequently the upload progress should be updated. ; Given either in percentages (per-file), or in bytes ; Default Value: "1%" ; Development Value: "1%" ; Production Value: "1%" ; http://php.net/session.upload-progress.freq ;session.upload_progress.freq = "1%" ; The minimum delay between updates, in seconds ; Default Value: 1 ; Development Value: 1 ; Production Value: 1 ; http://php.net/session.upload-progress.min-freq ;session.upload_progress.min_freq = "1"
#質問
上記employerlist.phpをブラウザで表示しようとすると,以下のエラー文が出ます。
"Fatal error: Call to undefined function session_save_path() in /home/a_yonamine/public_html/employerlist.php on line 7"
#解決しようと試みたこと
リンク内容が参考になるかと思い、"php -i"をターミナルで実行して"Session support => enabled"となっていればエラーが解決するみたいですが、そうなっていました。
しかし以前とエラーは表示されていました。
何か分かる方ご教授頂けたら幸いです。
情報が不足していたらなんなりとお申し付けください。
回答1件
あなたの回答
tips
プレビュー