php-windows Digest 28 Apr 2004 14:06:27 -0000 Issue 2229
Topics (messages 23564 through 23569):
Re: Muting Errors
23564 by: Jason Barnett
Re: most latest file
23565 by: Harpreet
23566 by: Jason Barnett
23567 by: Harpreet
does php understands UNC \\server\share\file.txt
23568 by: De Greef S�bastien
Re: Windows 2003 and SQL Server issues
23569 by: Charles P. Killmer
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 ---
Matthew Huggins wrote:
Hey all,
I happened to catch on an ambiguous page describing one of the PHP functions
that you can "mute" errors from functions by using the "at" (@) character
immediately before the function name. (e.g.: @objConnection =
@mysql_connect(...);)
I can't find any documentation on the PHP website other than the one liner I
read on it. I was hoping someone may be able to send more info on it. What
signals an "error"...is it a certain type of return variable that the @ sign
recognizes, or what?
I'm not 100% sure, but I believe the Zend engine uses the error
constants defined in the standard php build, e.g. E_ERROR, E_WARNING,
E_NOTICE.
Also, is it possible to instantiate my own errors within a function such
that the calling PHP code can use the @ sign when calling my function to
detect an error from my function? Thank you!
Well, what are you wanting @ to do? What it does is suppress an error
message for *just* the return value of a function. As an example, if
your mysql_connect() fails then your webpage won't display sensitive
information (can't connect to database blah). But if you want to have
PHP detect errors from your functions you should use trigger_error.
http://www.php.net/trigger_error
If you are hoping to catch your errors and do something with them, you
might create an error handler and use set_error_handler()
http://www.php.net/set_error_handler
--- End Message ---
--- Begin Message ---
I am using the below code and get the error
Warning: fileatime() [function.fileatime]: Stat failed for abc.txt
(errno=2 - No such file or directory)
$dir='c:\pathname\temp';
$time='1';
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
echo date("m-d-y H:i:s",fileatime($file));
if ($file != "." && $file != ".." && fileatime($file) > $time) {
$time = fileatime($file);
$lastModifiedFile = $file;
}
}
closedir($handle);
echo $lastModifiedFile;
-----Original Message-----
From: Jason Barnett [mailto:[EMAIL PROTECTED]
Sent: Monday, April 26, 2004 11:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Re: most latest file
Harpreet wrote:
> Actually I have a backups folder that gets once a day backups of the
> database automaticcaly. I want to be able to know the name fo the the
latest
> file to do the restore. The name of the files have the time stamp and plus
> file has a time last mdified date attached to it.
>
> How can I know which file got restored last using php and also the file
> name.
>
> Thanks
<?php
$directory = 'path/to/backups/directory';
$handle = opendir($directory) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && fileatime($file) > $time) {
$time = fileatime($file);
$lastModifiedFile = $file;
}
}
closedir($handle);
echo $lastModifiedFile;
?>
http://www.php.net/readdir
http://www.php.net/manual/en/function.fileatime.php
or, to check file creation times:
http://www.php.net/manual/en/function.filectime.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Harpreet wrote:
I am using the below code and get the error
Warning: fileatime() [function.fileatime]: Stat failed for abc.txt
(errno=2 - No such file or directory)
$dir='c:\pathname\temp';
$time='1';
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
echo date("m-d-y H:i:s",fileatime($file));
if ($file != "." && $file != ".." && fileatime($file) > $time) {
Is this where the error occured? This is what I get for giving code
without testing it first. It seems that PHP is looking for 'abc.txt' in
the current directory (instead of in c:\pathname\temp). Using an
absolute path to $file instead of a relative one should work.
$time = fileatime($file);
$lastModifiedFile = $file;
}
}
closedir($handle);
echo $lastModifiedFile;
Modified code:
$dir='c:\pathname\temp';
$time='1';
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
$absfile = $dir.'/'.$file;
echo date("m-d-y H:i:s",fileatime($file));
if ($file != "." && $file != ".." && fileatime($absfile) > $time) {
$time = fileatime($absfile);
$lastModifiedFile = $file;
}
}
closedir($handle);
echo $lastModifiedFile;
--- End Message ---
--- Begin Message ---
It works great when accessing local files but if i put a server path like
$dir="\\Servername\c\pathname";
Warning: opendir(\\servername\c\pathname) [function.opendir]: failed to open
dir: Invalid argument in D:\web\1.php on line 36
Line 36 is $handle = opendir($dir);
Thanks for all the help, it is greatly appreciated.
-----Original Message-----
From: Jason Barnett [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 28, 2004 12:45 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Re: most latest file
Harpreet wrote:
> I am using the below code and get the error
> Warning: fileatime() [function.fileatime]: Stat failed for abc.txt
> (errno=2 - No such file or directory)
>
> $dir='c:\pathname\temp';
> $time='1';
> $handle = opendir($dir);
> while (false !== ($file = readdir($handle))) {
> echo date("m-d-y H:i:s",fileatime($file));
> if ($file != "." && $file != ".." && fileatime($file) > $time) {
Is this where the error occured? This is what I get for giving code
without testing it first. It seems that PHP is looking for 'abc.txt' in
the current directory (instead of in c:\pathname\temp). Using an
absolute path to $file instead of a relative one should work.
> $time = fileatime($file);
> $lastModifiedFile = $file;
> }
> }
>
> closedir($handle);
> echo $lastModifiedFile;
>
Modified code:
$dir='c:\pathname\temp';
$time='1';
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
$absfile = $dir.'/'.$file;
echo date("m-d-y H:i:s",fileatime($file));
if ($file != "." && $file != ".." && fileatime($absfile) > $time) {
$time = fileatime($absfile);
$lastModifiedFile = $file;
}
}
closedir($handle);
echo $lastModifiedFile;
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
hi,
i try to open a file located on a network location.
I don't want to map the drive on local computer but it seams tha php doesn't
understand \\server\share...
Somebody knows a way out?
Sorry formy bad english
--- End Message ---
--- Begin Message ---
What I ended up doing is creating a user on both the IIS box and the
SQL box. Both low level users with the same username and password. I
set IIS to use this new user account to run web requests.
This was all it took. I think there is a better solution but I havent
found it yet.
Charles Killmer
-----Original Message-----
From: Kretschmer, Daniel
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 28, 2004 9:04 AM
To: Charles P. Killmer
Subject: [PHP-WIN] Windows 2003 and SQL Server issues
Hello Charles,
i have the same problem like you (see below) and i hope you have
meanwhile a solution for this problem.
If you have, is will be very friendly if you send me the solution.
Thank, Daniel Kretschmer
************************************************************************
***************************************
I am having trouble configuring PHP 4.3.4 on Windows Server 2003 to
connect to SQL Server 2000 on a Windows 2003 Server across the LAN.
Now PHP is configured correctly because when I run the script from the
command line, ie c:\php\php.exe c:\site\file.php, I get the results from
the query.
Its a simple select count(*) from table query.
When I request the same file through a browser I get the error "PHP
Warning: mssql_connect(): Unable to connect to server: ServerName"
If I change the script to just echo phpinfo(); I get everything I would
expect. Extensions are in the right spot, mssql.dll is loaded...
This tells me that IIS 6.0 is configured to run the php.exe. The
command line test tells me that php is configured to connect to the
database. It seems to be that only when IIS tries to run the code to
connect to the database that I run into issues. Possibly an issue of
Windows 2003 being too secure in some area to allow the webuser to
connect to the database server. I have tried changing from the
predefined "Network
Has anyone run into issues with something like this? Thank you for any
help on this.
Charles Killmer
Netgain Technology
[EMAIL PROTECTED]
Office: (320) 251-4700 ext 107
************************************************************************
***************************************
--- End Message ---