During the execution of a project in PHP ( CodeIgniter ) I get this error.
It corresponds to that line of code in the file Session_files_driver.php of CodeIgniter.
Previously I worked on Linux, but since I passed under W10, I get this error.
Thanks for your help.
A PHP Error was encountered
Severity: Warning
Message: touch(): Unable to create file
sys_get_temp_dir()\ci_sessionc1e70147453a4c2aa17523a19927bce80ef4afe9
because No such file or directory
Filename: drivers/Session_files_driver.php
Line Number: 234
Backtrace:
if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
It appears that you've provided 'sys_get_temp_dir()' as a string (note the quotes) for your sess_save_path value. It's a function, you're not supposed to put quotes around it.
Also, it's a bad idea to use the system-wide temporary directory for your session files' location. That directory is readable by everybody, which means that any other user on the system can read your users' session data - you must avoid that!
Most likely a write permission error. Grant apache user the permission to write to disk.
Related
After creating .theme file in my template folder (whether empty or not), I get the following error message:
The website encountered an unexpected error. Please try again later.RuntimeException: Failed to start the session because headers have already been sent by "/homepages/d825952918/htdocs/themes/universaldenker/universaldenker.theme" at line 1. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 145 of vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php).
If I delete .theme file again, everything works again. I think it has something to do with opcache, because the path "/homepages/d825952918/htdocs/themes/universaldenker/universaldenker.theme" comes from the .opcache folder.
Can anyone help me?
I'm trying to execute "opendir" to understand how it works & use it in a recursive page call (I get wrong directories using .. & .).
My folder is constructed as follows:
C:\xampp\htdocs\Ask_Alansky
C:\xampp\htdocs\ is what comes in the XAMPP package, & Ask_Alansky is the folder in which I'm working.
The issue is simply that I cannot get a opendir () to work & open the directory. I'm not sure if I'm misunderstanding the concept, but I expect the code to simply open the folder "Ask_Alansky" & show me the files.
My code is:
<?php
opendir($_SERVER['C:/xampp/htdocs/Ask_Alansky'] . '/index.php');
?>
I get:
Notice: Undefined index: C:/xampp/htdocs/Ask_Alansky in
C:\xampp\htdocs\Ask_Alansky\php_main\Testing.php on line 14
Warning: opendir(/index.php,/index.php): The system cannot find the file specified. (code: 2) in
C:\xampp\htdocs\Ask_Alansky\php_main\Testing.php on line 14
Warning: opendir(/index.php): failed to open dir: No such file or directory in
C:\xampp\htdocs\Ask_Alansky\php_main\Testing.php on line 14
What I'm doing wrong?
$_SERVER is an associative array that contains multiple server information. Therefore, there is not such key C:/xampp/htdocs/Ask_Alansky. If you wish to access the current directory, use getcwd() instead. It is also not a good idea to use absolute path to your file, this will cause a problem when you migrate your app to another server.
I am using Codeigniter as my PHP framework. When I run the factual API I get results but there are PHP warnings.
Severity: Warning
Message: include(/home/bwilson/public_html/factual/CI_DB.php): failed to open stream: No such file or directory
Filename: factual/Factual.php
Line Number: 217
Severity: Warning
Message: include(): Failed opening '/home/bwilson/public_html/factual/CI_DB.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear')
Filename: factual/Factual.php
Line Number: 217
I a look at line 217 in the factual.php file and it reads:
include dirname(__FILE__)."/".$className . ".php";
What is the referring to? I have tested this without running the Factual API and the controllers load find. It is only when I start using the Factual API.
This is the reply I received from Factual:
The driver employs an SPL Autoload function to include files for
unloaded classes dynamically.
Here, the class CI_DB -- a Codeigniter class, not Factual -- is being
called without being loaded first. This triggers our autoload feature
in a final attempt to load the file.
In short: this is not a Factual driver issue; to solve, ensure the
file containing the CI_DB class is loaded properly.
It's just trying to find CI_DB.php in the same folder as factual.php.
Make sure that file actually exists where it's trying to find it. Pay attention to what case the filename is.
If the file does indeed exist where its supposed to, check its permissions.
After looking for into the error returns unsupported modules. I just disabled the error reporting in the index.php file by setting error reporting to production. In the mean time I am okay with it as long as my results are the same.
Thank you everyone that contributed.
Do you use?:
require_once BASEPATH . "/{$className}.php";
I have a PHP script which reads from an xml file to generate a table. The first thing it does is check to make sure the file exists.
$path = getcwd();
if(file_exists($path.'\inc\php\kbs.xml')){
$kbs = simplexml_load_file($path.'\inc\php\kbs.xml');
} else {
echo "Error: No KB file found";
}
For some reason, intermittently, it doesn't find the file. I've tried removing the file_exists check all together (since I know the file does exist) but it still doesn't load the file at times. I can refresh the page and 7 times out of 10 it doesn't load, but sometimes it does.
I never ran into this problem during development, but once it went production (being used by maybe 200 users now) it started happening.
How do I go about troubleshooting this? (PHP 5.2.14 running on IIS)
EDIT: Error logs give me the following messages when it fails:
Notice: Undefined variable: kbs in <the path> on line 16
Notice: Trying to get property of non-object in <the path> on line 16
Warning: Invalid argument supplied for foreach() in <the path> on line 16
line 16 is the first time the variable $kbs is accessed. Obviously $kbs isn't set if the file isn't found.
Please use the absolute path, relative path make things a mess.
Is the location relative to PHP? Do permissions allow the web server to see it?
I have looked around on the issue - but it seems that all I can find about it is people who are having the problem connecting to a local database or something (not really sure). I am having the problem on my website (any time I make an ajax call to a file that has a session_start())
Anyways, this is the error message I am getting:
Warning: session_start() [function.session-start]: open(/usr/local/apache/bin/httpd/sess_5840483107c1db9753c32214723b64a6, O_RDWR) failed: Not a directory (20) in /data/in/r/reiconsultants/www/employee/user_page_login.php on line 3
Warning: Unknown(): open(/usr/local/apache/bin/httpd/sess_5840483107c1db9753c32214723b64a6, O_RDWR) failed: Not a directory (20) in Unknown on line 0
Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/usr/local/apache/bin/httpd) in Unknown on line 0
I haven't touched the code in a while - and I can be quite sure that no one else has either, so I am not sure why the error is occurring. I read a bunch about people going in and setting the php.ini file, but I have never had to do that before - and can't even find the file.
Like I said - the error is occurring on my company website, not when trying to connect to a local database.
The error just popped up today - I got flooded with emails about it, and it is on more than one web page being hosted on the server - all the pages I have that include a session_start() at the top have the issue.
Could it be a server side issue that I can't fix? or what...
sorry if I am not descriptive enough - I have absolutely no idea what is going on, and therefore don't know what to say. Just ask me for any clarification you need.
Thanks!
Paul
The error is indicating that /usr/local/apache/bin/httpd/ is set as your folder to save session data in. Does that folder exist and is writable by the user Apache is running as? Does the Linux server have any other security measures like SELinux running that might be stopping writing to that directory?
Did you verify that the current setting of session.save_path is correct? Is /usr/local/apache/bin/httpd correct folder for saving session data?
Try set session.save_path = "/tmp" in you php.ini to ensure that problem is in folder.
you can also change the session path at run time:
string session_save_path([string $path])