I am trying to use unlink command on my server Apache/2.2.3 PHP Version 5.2.10. I have been using the same script on a bunch of other servers including my local PC. Unfortunately, the command doesn't work.
I tried this so far:
chmod everything to 777
putting new files and unlinking them
also I notice that I can't upload or saveXML files to the server
I am guessing that it is some kind of setting inside the php.ini file, but I don't know which.
May be it's a safe_mode?
Solved
Checking if it is writable first and then unlink it seem to do the trick
if (is_writable("$bannerlink")) unlink("$bannerlink");
thanks to everybody
Related
i'm trying to set the certain path for the php extension in my vscode (using linux)
i started installing the XAMPP
and after it..i tried to use the extension writing some php scripts(php extension INTELLISENSE and DEBUG), but the extension is not working properly and it's showing that error:
Cannot validate since /usr/bin/php is not a valid php executable. Use the setting 'php.validate.executablePath' to configure the PHP executable.
i tried to set it using que path which is provided by vscode documentation, but it's still no working.
Can anyone help me !! please!!!
I found a solution, typing in terminal
'whereis php'
that returns the absolute path for set it in the vscode extension
/opt/lampp/bin/php
Then, setting the path in the follow line
php.validate.executablePath: "/opt/lampp/bin/php",
So, I hope this solution is helping someone behind the screen.
Php path in windows
Typing in terminal
where php
And it'll gives the path as (in my case)
C:\xampp\php\php.exe
Just extending the answer by #Reinaldo Duguet with a ton of thanks to him !
If you are using Xampp, the PHP path can be found by running the local server and then typing localhost in the browser. This will open the Xampp dashboard. Click on phpinfo() and there you will get the exact path shown as
Configuration File (php.ini) Path = /opt/lampp/etc
Please note that the path may very as per the PHP installation in your system. So you may have to use the respective path shown with above ways.
Then, to let VSCode know this path, open settings in VSCode and search for "PHP debug" and click on the PHP > Debug:Executable Path setting
Add the following line at the first place after "{" telling VSCode where PHP is installed in the system.
"php.validate.executablePath": "/opt/lampp/etc",
If you are using Xampp, the PHP path can be found by running the local server and then typing
the correct version C:/xampp/php/php.exe
XAMPP isn't the best option for linux and i wouldn't recommend it.
Assuming this is not the problem, here is how to do :
find php executable
whereis php
Check your vscode installation. You want to make sure it's not using flatpak (it runs in a container and it would mess up everything)
go in vscode settings, search for php and set "php.debug.executablePath": "/your path/php"
If it still doesn't work, this might be a permission problem. Then :
copy the php executable in your user folder
sudo cp original_path/php /your_user_folder/php
add permissions
sudo chmod 777 /your_user_folder/php
If none of above worked, at this point, you may want to use a VM.
I just wanted to add a possibility here that ended up being my issue in case it helps someone else in the future. My issue was that I was using a Debian based distro and installed VSCode through the software app which relies on Snap apparently. Snap runs the programs in a sandbox and prevents them from seeing other locations on the computer. My solution was that I uninstalled the shop version and installed VScode manually via downloading directly from the website. After that, everything works as expected.
I am using PHP. I have a file in local storage of Xampp. I have been trying to delete that using unlink. I tried copying the relative path and pasted in unlink, but it does not delete the file from local storage. I even tried pasting the path, so not the relative one, but it still does not delete the files. Can someone reckon what I might be doing wrong?
My code:
unlink("userdir/username/181");
As someone mention in comments I try changing the permission. I tried sudo chmod -R 755 /Users/hemlatamahaur/.bitnami/stackman/machines/xampp/volumes/root/htdocs
but it still says Operation not permitted. What shall I do?
this code working for me!
// first check location exist or not
if (file_exists(#locationfile)) {
unlink(#locationfile);
}
I am a Centos 7 machine on which I have configured PHP with Apache and Slim Framework.
The simple code to check if the file exists and copy the code into a directory is working fine on one of the machine but not working on another machine. Its really weird.
Actually I am accessing the API through Apache to trigger this function.
Functions like shell_exec alaways return 0
copy function is also not workingg
file_exists also not working.
Any help or clue why this is wrong or debug this issue.
Thanks all for the help.
Problem was file permission issue.
The reason was all of the above function I was performing was on the file. Since the files has different permission for different user.
So If I hit the URL from browser it was through "Apache" user which does not have execute permission on the folder to access the file and read permission on the file.
In short
sudo chmod +rx file
sudo chmod +x "All the directory structure"
I am installing composer for laravel installation.but when it want php.exe file i coudn't find it in c:/xampp/php folder.I set up my path variable c:/xampp/php but it is still not working.help me guys.
If xampp has correctly installed, but you are failing to run PHP it is more than possible that you don't have PHP set in your environment paths.
To set this go to;
Start > right click computer > properties > Advanced system settings > Environment Variables.
Under System variables find a variable named PATH, highlight then click Edit... Append the absolute path to your root PHP folder, this could either be xampps located in.
c:/xampp/php/
Press Ok, once you've finished; close down any command prompt windows you may have open. Re-open command prompt and run php -v. Hopefully at this point PHP has responded with it's version and license information.
Make sure you have xampp properly installed.
If you add c:/xampp/php to your PATH while you have a console open, you need to open another console, in order for the PATH to be updated.
i think I have that problem one day, i solved uninstalling xampp server and reinstalling it, but when xampp ask you wich folder to install you need to create a new folder:
C://new folder/xampp/.......
If you install/uninstall multiples xampp or wampp versions for some reasons create storage info in the xampp folder, so creating a new folder solve the problem.
You can use this path:
c:/xampp/php/php.exe
PATH should be a directory, not a file, so you should set it to "c:\xampp\php\", other than"c:\xampp\php\php.exe"
I'm getting 401.1 errors when trying to run a .php file on windows 2003/IIS6
I've been all over the web, given Everyone Full perms on the folder containing the file as well as the file... Nothing.
What am I missing?
Here's a step-by-step guide for getting PHP running on IIS 6.
can you serve HTML in the folder trying to serve PHP?
If yes, what are the permissions on the PHP directory and PHP DLL (e.g. php5isapi.dll)? The IUSR will need execute.
Take a look at the logs produced by IIS (found somwhere in C:\WINDOWS\system32\LogFiles\W3SVC1)
this might give you some additional info.