php-general Digest 6 Jun 2010 18:08:48 -0000 Issue 6784
Topics (messages 305847 through 305857):
unlink()?
305847 by: tedd
305848 by: Richard Quadling
305849 by: tedd
305851 by: Ashley Sheridan
305857 by: tedd
What's wrong with this code?
305850 by: David Mehler
305852 by: Karl DeSaulniers
305853 by: David Mehler
305854 by: Karl DeSaulniers
305855 by: Mari Masuda
305856 by: David Mehler
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi gang:
I use unlink() to delete files on my server by using the statement:
unlink($filename);
where $filename is the physical path to the file plus file name, such as:
$filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt';
Now, I can read, write, and even create the file -- so I have the
path and permissions correct. But if I unlink() the file and then
examine the contents of the parent directory afterwards, I find the
file remains -- what's up with that?
This reminds me of the process of deleting files on your local hard
disk, which basically sets the disk-space allocated to the file as
"available for writing" without actually deleting the file.
So what am I not understanding here?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On 5 June 2010 23:45, tedd <[email protected]> wrote:
> Hi gang:
>
> I use unlink() to delete files on my server by using the statement:
>
> unlink($filename);
>
> where $filename is the physical path to the file plus file name, such as:
>
> $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt';
>
> Now, I can read, write, and even create the file -- so I have the path and
> permissions correct. But if I unlink() the file and then examine the
> contents of the parent directory afterwards, I find the file remains --
> what's up with that?
>
> This reminds me of the process of deleting files on your local hard disk,
> which basically sets the disk-space allocated to the file as "available for
> writing" without actually deleting the file.
>
> So what am I not understanding here?
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What is the result of the unlink()? Enable errors/warnings.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
Hi gang:
Never-mind.
I didn't change the parent directory permissions to unlink the file -- duh!
Cheers,
tedd
--- I asked:
Hi gang:
I use unlink() to delete files on my server by using the statement:
unlink($filename);
where $filename is the physical path to the file plus file name, such as:
$filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt';
Now, I can read, write, and even create the file -- so I have the
path and permissions correct. But if I unlink() the file and then
examine the contents of the parent directory afterwards, I find the
file remains -- what's up with that?
This reminds me of the process of deleting files on your local hard
disk, which basically sets the disk-space allocated to the file as
"available for writing" without actually deleting the file.
So what am I not understanding here?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Sat, 2010-06-05 at 18:55 -0400, tedd wrote:
> Hi gang:
>
> Never-mind.
>
> I didn't change the parent directory permissions to unlink the file -- duh!
>
> Cheers,
>
> tedd
>
> --- I asked:
>
> Hi gang:
>
> I use unlink() to delete files on my server by using the statement:
>
> unlink($filename);
>
> where $filename is the physical path to the file plus file name, such as:
>
> $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt';
>
> Now, I can read, write, and even create the file -- so I have the
> path and permissions correct. But if I unlink() the file and then
> examine the contents of the parent directory afterwards, I find the
> file remains -- what's up with that?
>
> This reminds me of the process of deleting files on your local hard
> disk, which basically sets the disk-space allocated to the file as
> "available for writing" without actually deleting the file.
>
> So what am I not understanding here?
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
I was just about to mention this! It's one of the bizarre security
loopholes in Linux. If you have write permissions to a directory but not
a file within it, you can still delete the file. I believe you can
change this behaviour with filesystem security mods, but I've not tried
that.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
At 1:02 AM +0100 6/6/10, Ashley Sheridan wrote:
On Sat, 2010-06-05 at 18:55 -0400, tedd wrote:
Hi gang:
Never-mind.
I didn't change the parent directory permissions to unlink the file -- duh!
tedd
I was just about to mention this! It's one of the bizarre security
loopholes in Linux. If you have write permissions to a directory but
not a file within it, you can still delete the file. I believe you
can change this behaviour with filesystem security mods, but I've
not tried that.
Ash
Yes, I've seen where you can delete files within a directory by
changing the directory permissions.
It's not often that my scripts create/delete files on the server --
so I'm not up on it as much as I probably should be.
However to me, it seems overly cautious to require scripts -- that
are already running on the server -- to have the authority (ftp id
and password) to create/delete files. After all, the scripts would
not be there if the person who placed them there didn't have
authority to create and delete files. So, I have to wonder under what
scenario would evil scripts be found/run on the server?
For example, if anyone was going to create an evil script and place
it on the server, they must have the authority to do that. And if
they had that authority, then they could just as easily add that to
their script and side-step this requirement, right? So, what's the
purpose?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Hello,
I've got a while loop outputting values from a database. Briefly it
looks like this:
while($row = mysql_fetch_array($result3))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['startdate'] . "</td>";
if (!empty($row['EndDate'])) {
echo "<td>" . $row['enddate'] . "</td>";
} else {
exit();
}
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['summary'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
That's not the whole code, but it is the problem code. Some output has
the ending date set, one or two records i can't remember how many i
entered with one, most do not, i want the echo to be conditional. The
output stops right before the if statement, echoes startdate and
that's it, comment out the if block and it works fine.
Thanks.
Dave.
--- End Message ---
--- Begin Message ---
Could the exit() be terminating it? Do you need this exit() as the
else for that if statement? Try deleting just the else {}.
JAT
Karl
Sent from losPhone
On Jun 5, 2010, at 6:54 PM, David Mehler <[email protected]> wrote:
Hello,
I've got a while loop outputting values from a database. Briefly it
looks like this:
while($row = mysql_fetch_array($result3))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['startdate'] . "</td>";
if (!empty($row['EndDate'])) {
echo "<td>" . $row['enddate'] . "</td>";
} else {
exit();
}
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['summary'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
That's not the whole code, but it is the problem code. Some output has
the ending date set, one or two records i can't remember how many i
entered with one, most do not, i want the echo to be conditional. The
output stops right before the if statement, echoes startdate and
that's it, comment out the if block and it works fine.
Thanks.
Dave.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
Thanks. I took out the entire else section including the exit call, it
now all processes, however $row['enddate'] is not displayed on the two
records where it is set.
Thanks.
Dave.
On 6/5/10, Karl DeSaulniers <[email protected]> wrote:
> Could the exit() be terminating it? Do you need this exit() as the
> else for that if statement? Try deleting just the else {}.
>
> JAT
>
> Karl
>
> Sent from losPhone
>
> On Jun 5, 2010, at 6:54 PM, David Mehler <[email protected]> wrote:
>
>> Hello,
>> I've got a while loop outputting values from a database. Briefly it
>> looks like this:
>>
>> while($row = mysql_fetch_array($result3))
>> {
>> echo "<tr>";
>> echo "<td>" . $row['name'] . "</td>";
>> echo "<td>" . $row['type'] . "</td>";
>> echo "<td>" . $row['startdate'] . "</td>";
>> if (!empty($row['EndDate'])) {
>> echo "<td>" . $row['enddate'] . "</td>";
>> } else {
>> exit();
>> }
>> echo "<td>" . $row['location'] . "</td>";
>> echo "<td>" . $row['summary'] . "</td>";
>> echo "<td>" . $row['description'] . "</td>";
>> echo "</tr>";
>> }
>>
>> That's not the whole code, but it is the problem code. Some output has
>> the ending date set, one or two records i can't remember how many i
>> entered with one, most do not, i want the echo to be conditional. The
>> output stops right before the if statement, echoes startdate and
>> that's it, comment out the if block and it works fine.
>> Thanks.
>> Dave.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
So your code looks like this?
while($row = mysql_fetch_array($result3))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['startdate'] . "</td>";
if (!empty($row['EndDate'])) { //This should probably be $row
['enddate']
echo "<td>" . $row['enddate'] . "</td>";
}
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['summary'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
Not to mention, you have a $row['EndDate'] and a $row['enddate'].
Probably need to choose one or the other.
HTH,
Karl
On Jun 5, 2010, at 7:43 PM, David Mehler wrote:
Hi,
Thanks. I took out the entire else section including the exit call, it
now all processes, however $row['enddate'] is not displayed on the two
records where it is set.
Thanks.
Dave.
On 6/5/10, Karl DeSaulniers <[email protected]> wrote:
Could the exit() be terminating it? Do you need this exit() as the
else for that if statement? Try deleting just the else {}.
JAT
Karl
Sent from losPhone
On Jun 5, 2010, at 6:54 PM, David Mehler <[email protected]>
wrote:
Hello,
I've got a while loop outputting values from a database. Briefly it
looks like this:
while($row = mysql_fetch_array($result3))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['startdate'] . "</td>";
if (!empty($row['EndDate'])) {
echo "<td>" . $row['enddate'] . "</td>";
} else {
exit();
}
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['summary'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
That's not the whole code, but it is the problem code. Some
output has
the ending date set, one or two records i can't remember how many i
entered with one, most do not, i want the echo to be conditional.
The
output stops right before the if statement, echoes startdate and
that's it, comment out the if block and it works fine.
Thanks.
Dave.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--- End Message ---
--- Begin Message ---
Could it be that you are not using the same variable name? In the if statement
you are using $row['EndDate'] and when attempting to print you are using
$row['enddate']. I think you need to be consistent about which capitalization
you use (and make sure it matches what is in the db).
>>> if (!empty($row['EndDate'])) {
>>> echo "<td>" . $row['enddate'] . "</td>";
>>> }
On Jun 5, 2010, at 5:43 PM, David Mehler wrote:
> Hi,
> Thanks. I took out the entire else section including the exit call, it
> now all processes, however $row['enddate'] is not displayed on the two
> records where it is set.
> Thanks.
> Dave.
>
>
> On 6/5/10, Karl DeSaulniers <[email protected]> wrote:
>> Could the exit() be terminating it? Do you need this exit() as the
>> else for that if statement? Try deleting just the else {}.
>>
>> JAT
>>
>> Karl
>>
>> Sent from losPhone
>>
>> On Jun 5, 2010, at 6:54 PM, David Mehler <[email protected]> wrote:
>>
>>> Hello,
>>> I've got a while loop outputting values from a database. Briefly it
>>> looks like this:
>>>
>>> while($row = mysql_fetch_array($result3))
>>> {
>>> echo "<tr>";
>>> echo "<td>" . $row['name'] . "</td>";
>>> echo "<td>" . $row['type'] . "</td>";
>>> echo "<td>" . $row['startdate'] . "</td>";
>>> if (!empty($row['EndDate'])) {
>>> echo "<td>" . $row['enddate'] . "</td>";
>>> } else {
>>> exit();
>>> }
>>> echo "<td>" . $row['location'] . "</td>";
>>> echo "<td>" . $row['summary'] . "</td>";
>>> echo "<td>" . $row['description'] . "</td>";
>>> echo "</tr>";
>>> }
>>>
>>> That's not the whole code, but it is the problem code. Some output has
>>> the ending date set, one or two records i can't remember how many i
>>> entered with one, most do not, i want the echo to be conditional. The
>>> output stops right before the if statement, echoes startdate and
>>> that's it, comment out the if block and it works fine.
>>> Thanks.
>>> Dave.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hello everyone,
Much thanks. Sometimes when you stare at code for so long it blurs
together, that's how it is with me at least. That was my problem, case
sensitive variable.
Thanks a lot.
Dave.
On 6/5/10, Mari Masuda <[email protected]> wrote:
> Could it be that you are not using the same variable name? In the if
> statement you are using $row['EndDate'] and when attempting to print you are
> using $row['enddate']. I think you need to be consistent about which
> capitalization you use (and make sure it matches what is in the db).
>
>>>> if (!empty($row['EndDate'])) {
>>>> echo "<td>" . $row['enddate'] . "</td>";
>>>> }
>
>
>
> On Jun 5, 2010, at 5:43 PM, David Mehler wrote:
>
>> Hi,
>> Thanks. I took out the entire else section including the exit call, it
>> now all processes, however $row['enddate'] is not displayed on the two
>> records where it is set.
>> Thanks.
>> Dave.
>>
>>
>> On 6/5/10, Karl DeSaulniers <[email protected]> wrote:
>>> Could the exit() be terminating it? Do you need this exit() as the
>>> else for that if statement? Try deleting just the else {}.
>>>
>>> JAT
>>>
>>> Karl
>>>
>>> Sent from losPhone
>>>
>>> On Jun 5, 2010, at 6:54 PM, David Mehler <[email protected]> wrote:
>>>
>>>> Hello,
>>>> I've got a while loop outputting values from a database. Briefly it
>>>> looks like this:
>>>>
>>>> while($row = mysql_fetch_array($result3))
>>>> {
>>>> echo "<tr>";
>>>> echo "<td>" . $row['name'] . "</td>";
>>>> echo "<td>" . $row['type'] . "</td>";
>>>> echo "<td>" . $row['startdate'] . "</td>";
>>>> if (!empty($row['EndDate'])) {
>>>> echo "<td>" . $row['enddate'] . "</td>";
>>>> } else {
>>>> exit();
>>>> }
>>>> echo "<td>" . $row['location'] . "</td>";
>>>> echo "<td>" . $row['summary'] . "</td>";
>>>> echo "<td>" . $row['description'] . "</td>";
>>>> echo "</tr>";
>>>> }
>>>>
>>>> That's not the whole code, but it is the problem code. Some output has
>>>> the ending date set, one or two records i can't remember how many i
>>>> entered with one, most do not, i want the echo to be conditional. The
>>>> output stops right before the if statement, echoes startdate and
>>>> that's it, comment out the if block and it works fine.
>>>> Thanks.
>>>> Dave.
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
--- End Message ---