Hi,
I'm using php to delete, rename, copy... some files. Sometimes php has
no permissions to do these operations, so the unlink(), rename(),
copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a
variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's
not exactly what I want.
For example, when mysql returns an error, I can get it with the
mysql_error() method.
Has anyone an idea, how could I do this?
Thanks
Yeray 2 33829
Yeray Garcia wrote: I'm using php to delete, rename, copy... some files. Sometimes php has no permissions to do these operations, so the unlink(), rename(), copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's not exactly what I want.
For example, when mysql returns an error, I can get it with the mysql_error() method.
Has anyone an idea, how could I do this?
========
<?php
$old_track = ini_set('track_errors', '1');
if (!@unlink('no_file')) {
echo $php_errormsg, "\n";
}
if (!@copy('no_file', 'some_file')) {
echo $php_errormsg, "\n";
}
ini_set('track_errors', $old_track);
?>
========
And the output is:
No such file or directory
failed to open stream: No such file or directory
See http://www.php.net/manual/en/ref.errorfunc.php
--
USENET would be a better place if everybody read: : mail address : http://www.catb.org/~esr/faqs/smart-questions.html : is valid for : http://www.netmeister.org/news/learn2quote2.html : "text/plain" : http://www.expita.com/nomime.html : to 10K bytes :
That is exactly what I was looking for.
Thanks a lot.
Yeray
Pedro Graca wrote: Yeray Garcia wrote:
I'm using php to delete, rename, copy... some files. Sometimes php has no permissions to do these operations, so the unlink(), rename(), copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's not exactly what I want.
For example, when mysql returns an error, I can get it with the mysql_error() method.
Has anyone an idea, how could I do this?
======== <?php
$old_track = ini_set('track_errors', '1');
if (!@unlink('no_file')) { echo $php_errormsg, "\n"; }
if (!@copy('no_file', 'some_file')) { echo $php_errormsg, "\n"; }
ini_set('track_errors', $old_track);
?> ========
And the output is:
No such file or directory failed to open stream: No such file or directory
See http://www.php.net/manual/en/ref.errorfunc.php
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gianni Mariani |
last post by:
I have a couple of template methods that take any integer type however,
the first "if" statement becomes a constant expression when T is an
unsigned type.
#include <limits>
template...
|
by: Ivan Shevanski |
last post by:
Here's a noob question for everyone (I'm not sure if my first message got
through, is had a "suspicious header" so sorry for double post is so), is
there a way to turn off syntax warnings or just...
|
by: Samuel |
last post by:
Imagine you have the following code:
try
{
...
}
catch (ThreadAbortException eThread)
{
if (WorkStopped != null) WorkStopped(this, EventArgs.Empty)
}
|
by: Steve |
last post by:
I have some general catch clauses in my app as follows:
try
{
}
catch(Exception ex)
{
}
try
|
by: Bob |
last post by:
Hi,
The compiler gives Warning 96 Variable 'cmdSource' is used before it has
been assigned a value. A null reference exception could result at runtime.
Dim cmdSource as SQlClient.SQLDataReader...
|
by: sbalak |
last post by:
I am writing code in C# and I wanted a basic solution:
In Try / Catch block, I want to get a general Exception. So, I write
code as:
try
{
// do something
}
catch (SomethingException ex)
{
|
by: aioe.cjb.net |
last post by:
So, I was planning on ridding my VS2005 solution of all warnings, but the
ones sounding "The variable 'ex' is declared but never used" in
catch-blocks, are causing a headache.
I have several...
|
by: Sergei Shelukhin |
last post by:
Hi.
I need to handle warnings in incorrect regular expressions executed
using preg_match.
Warnings shouldn't appear, instead I want to output some generic
message like: "Bad regex: $regex" and...
|
by: RP |
last post by:
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |