php-general Digest 7 Feb 2004 16:35:47 -0000 Issue 2576
Topics (messages 177077 through 177096):
Re: Cannot send mail after upgrading to OS X v10.3
177077 by: Jason Wong
177078 by: John Nichel
fopen() Problems
177079 by: rabbit.cold-chaos.net
177080 by: Jason Wong
excel output question
177081 by: Jake McHenry
177082 by: Joshua D. Drake
177083 by: Paul Furman
177085 by: Jake McHenry
177089 by: Phillip Jackson
177092 by: Jake McHenry
177094 by: Paul Furman
Re: How can I run php 5 beta 3 on windows?
177084 by: Adam Bregenzer
Problems with ö or ä in script
177086 by: Piet from South Africa
Use a Server or Client Socket?
177087 by: Tan Ai Leen
177093 by: Raditha Dissanayake
explode() an array and grep out a string
177088 by: Bobby R.Cox
Re: Need a way to automate user logout
177090 by: Phillip Jackson
Re: include_once() isnt!
177091 by: Eric Bolikowski
Beginner amazes self with image gallery script!
177095 by: Paul Furman
177096 by: Paul Furman
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 ---
On Saturday 07 February 2004 11:39, gohaku wrote:
> I am using OS X v10.3.2 and just discovered that I can't send mail
> using the mail() function.
> According to phpinfo(), PHP is configured with sendmail.
AFAIK phpinfo() does not tell you whether whether mail capabilities has been
compiled in.
> I ran Postfix Enabler and still could not email myself.
> What do I need to configure to get the mail() function to work?
1) check your php error logs
2) check your MTA logs
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Just because everything is different doesn't mean anything has changed.
-- Irene Peter
*/
--- End Message ---
--- Begin Message ---
gohaku wrote:
Hi everyone,
I am using OS X v10.3.2 and just discovered that I can't send mail using
the mail() function.
According to phpinfo(), PHP is configured with sendmail.
Before upgrading to v10.3, I did not check if the mail() function worked
in v10.2
The script I'm using does work on other servers.
Make sure the path to sendmail is correct in your php.ini.
Ensure that sendmail is installed.
Check to see if sendmail is running.
Make sure sendmail is configured to relay for localhost.
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--- End Message ---
--- Begin Message ---
I am using the below code (kind of sloppy..). I have tried for fopen r+, w,
and w+, but no matter what I do, the file is always truncated, and previously
entered data is erased. I have been unable to fix this.
<?php
$filename = 'news.php';
$divhead = '<div style="padding:15;padding-left:0" class="ver10">';
$d1 = date("l dS of F Y h:i:s A");
$divclose = '</i></div></p><BR>';
$some = " $divhead <p><B><font size=2 color=#FF0000>";
$some1 = $_POST['topic'];
$some = " $some $some1 </font></b><BR><B><a
href=mailto:[EMAIL PROTECTED]>R.a.B.B.i.T</a></B><i> - $d1 </i><BR>";
$some1 = $_POST['news'];
$some = " $some $some1 $divclose";
$some = " $some <BR><BR>";
$some = stripslashes($some);
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'r+')) {
echo "Cannot open file ($filename)";
} else {
if (!fwrite($handle, $some)) {
echo "Cannot write to file ($filename)";
} else {
echo "Success, wrote data to file ($filename)";
fclose($handle);
}
}
} else {
echo "The file $filename is not writable";
}
?>
--- End Message ---
--- Begin Message ---
On Saturday 07 February 2004 07:08, [EMAIL PROTECTED] wrote:
> I am using the below code (kind of sloppy..). I have tried for fopen r+,
> w, and w+, but no matter what I do, the file is always truncated, and
> previously entered data is erased. I have been unable to fix this.
Assuming that you're trying to add something to the end of an existing file:
either fopen() using mode 'a' or use fseek().
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"In short, _N is Richardian if, and only if, _N is not Richardian."
*/
--- End Message ---
--- Begin Message ---
Hi everyone. I'm outputing payroll information to an excel csv file, and when anyone
get's paid over 1k, the amount is split into two fields because of the comma in the
amount. Is there anyway I can tell excel that this particular comma is not a
deliminator?
Thanks,
Jake
--- End Message ---
--- Begin Message ---
On Sat, 7 Feb 2004, Jake McHenry wrote:
> Hi everyone. I'm outputing payroll information to an excel csv file, and when anyone
> get's paid over 1k, the amount is split into two fields because of the comma in the
> amount. Is there anyway I can tell excel that this particular comma is not a
> deliminator?
quote it
>
> Thanks,
> Jake
--
Co-Founder
Command Prompt, Inc.
The wheel's spinning but the hamster's dead
--- End Message ---
--- Begin Message ---
Single quote everything should work.
Jake McHenry wrote:
Hi everyone. I'm outputing payroll information to an excel csv file, and when anyone get's paid over 1k, the amount is split into two fields because of the comma in the amount. Is there anyway I can tell excel that this particular comma is not a deliminator?
Thanks,
Jake
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Paul Furman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, February 07, 2004 1:56 AM
Subject: [PHP] Re: excel output question
> Single quote everything should work.
>
> Jake McHenry wrote:
>
> > Hi everyone. I'm outputing payroll information to an excel csv file, and
when anyone get's paid over 1k, the amount is split into two fields because
of the comma in the amount. Is there anyway I can tell excel that this
particular comma is not a deliminator?
> >
> > Thanks,
> > Jake
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
like this?
output =
"'$fullname',,'$location',,'$regularhours','$vachours','$sickhours','$compho
urs','$mischours','$wopyhours','$sefahours','$biweekly[0]','$adjustedtime',,
,,,'$sub401k
','$payrate','$gross5'\n";
That just filled my spreadshit with quotes around everything... still the
amounts larger than 1k are in 2 columns......
did I do something wrong?
Thanks,
Jake
--- End Message ---
--- Begin Message ---
I would do it like this:
$build = " '%s','%s','%s','%s'\n";
$build = sprintf($build,$field1,$field2,$field3,$fieldN);
you could also try escaping the comma. if this doesn't work you can always
just dump to html tables and save the file as *.xls (excel spreadsheet);
excel understands html tables and simple markup as spreadsheet data.
ie:
<html>
<table>
<tr>
<td>field1</td><td>field2</td><td>field3</td><td>field4</td>
</tr>
<tr>
<td>value1</td><td>value2</td><td>value3</td><td>value4</td>
</tr>
</table>
</html>
~phillip
"Jake McHenry" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ----- Original Message -----
> From: "Paul Furman" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, February 07, 2004 1:56 AM
> Subject: [PHP] Re: excel output question
>
>
> > Single quote everything should work.
> >
> > Jake McHenry wrote:
> >
> > > Hi everyone. I'm outputing payroll information to an excel csv file,
and
> when anyone get's paid over 1k, the amount is split into two fields
because
> of the comma in the amount. Is there anyway I can tell excel that this
> particular comma is not a deliminator?
> > >
> > > Thanks,
> > > Jake
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> like this?
>
> output =
>
"'$fullname',,'$location',,'$regularhours','$vachours','$sickhours','$compho
>
urs','$mischours','$wopyhours','$sefahours','$biweekly[0]','$adjustedtime',,
> ,,,'$sub401k
> ','$payrate','$gross5'\n";
>
> That just filled my spreadshit with quotes around everything... still the
> amounts larger than 1k are in 2 columns......
>
> did I do something wrong?
>
> Thanks,
> Jake
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Phillip Jackson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, February 07, 2004 4:37 AM
Subject: Re: [PHP] Re: excel output question
> I would do it like this:
>
> $build = " '%s','%s','%s','%s'\n";
> $build = sprintf($build,$field1,$field2,$field3,$fieldN);
>
> you could also try escaping the comma. if this doesn't work you can always
> just dump to html tables and save the file as *.xls (excel spreadsheet);
> excel understands html tables and simple markup as spreadsheet data.
>
> ie:
>
> <html>
> <table>
> <tr>
> <td>field1</td><td>field2</td><td>field3</td><td>field4</td>
> </tr>
> <tr>
> <td>value1</td><td>value2</td><td>value3</td><td>value4</td>
> </tr>
> </table>
> </html>
>
>
> ~phillip
> "Jake McHenry" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > ----- Original Message -----
> > From: "Paul Furman" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, February 07, 2004 1:56 AM
> > Subject: [PHP] Re: excel output question
> >
> >
> > > Single quote everything should work.
> > >
> > > Jake McHenry wrote:
> > >
> > > > Hi everyone. I'm outputing payroll information to an excel csv file,
> and
> > when anyone get's paid over 1k, the amount is split into two fields
> because
> > of the comma in the amount. Is there anyway I can tell excel that this
> > particular comma is not a deliminator?
> > > >
> > > > Thanks,
> > > > Jake
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > like this?
> >
> > output =
> >
>
"'$fullname',,'$location',,'$regularhours','$vachours','$sickhours','$compho
> >
>
urs','$mischours','$wopyhours','$sefahours','$biweekly[0]','$adjustedtime',,
> > ,,,'$sub401k
> > ','$payrate','$gross5'\n";
> >
> > That just filled my spreadshit with quotes around everything... still
the
> > amounts larger than 1k are in 2 columns......
> >
> > did I do something wrong?
> >
> > Thanks,
> > Jake
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
This is in a simple while loop, data is coming from a mysql database.
Creating a seperate function would too time consuming changing all of the
existing code for what this page is doing. It orignally was in html form in
an xls file, but when the file was opened, there were no cell borders
anymore. If anyone can tell me how to turn on the cell boarders in an xls
html outputted file, that would also work. This is the only reason I went
back to a csv file.
Thanks,
Jake
--- End Message ---
--- Begin Message ---
Jake McHenry wrote:
That just filled my spreadsh**t with quotes around everything... still the
amounts larger than 1k are in 2 columns......
did I do something wrong?
Sorry it didn't work. Maybe double quotes? I've output data from MS
Access that came out smothered in quotes and when importing to excel,
the import wizard asks what string indicator is being used and strips
those. Or maybe use something other than a comma as the separator &
Excel will ask. Sounds like you may need to extract the values and strip
the commas out before sending to CSV. I know Access database is much
more obsessive about data types (string vs number) than PHP.
--- End Message ---
--- Begin Message ---
On Fri, 2004-02-06 at 18:47, omer katz wrote:
> Help!!!
> "Omer Katz" <[EMAIL PROTECTED]>
> :[EMAIL PROTECTED]
> > Can I update PHPTraid's php files?
I'm not sure I understand what you are having a problem with...
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--- End Message ---
--- Begin Message ---
When using ö or ä the hyperlinks or photo references does not work even
though it point correct like "../banner/Jörns Gästehaus/mainphoto.jpg, i
tried specialchars but this does not seem to work, can anyone tell me why?
--- End Message ---
--- Begin Message ---
Hi all,
I have this situation now that requires socket programming. But I am not
sure how to realise the requirements in programming whether as a client or
server
The requirement is like this.
I have to connect to an external server constantly to listen for incoming
data. How can I make sure that the connection is there all the time? Upon
receiving the message, I will have to response back an acknowledgement that
the message is received. I can also send data to the server. From my
requirements, I understand that there will only be one connection. Therefore
the data exchange need not be in sequence.
Currently, what I have is a server programmed using the socket library.
Server logic :
socket_create
socket_bind
socket_listen
while(true)
{
socket_select
if(new connection)
{
add to connections array
}
else
{
if(can read)
{
read incoming
response back
}
else
{
//error or connection close
if(error)
{
print error
}
else
{
print connection close
remove from connections array
}
}
}
}
I am planning to include a check somewhere in the codes for maintaining the
connection between my server and the other server. Where should I place it?
Also, I need to initiate a connection to the external server and then
listen. Where should this piece of code be insert at? Is this the right
approach? Or I am over killing by writing a server if this can be handle in
easier manner.
Hope that I have been clear in the above.
Thanks for helping
Ai Leen
--- End Message ---
--- Begin Message ---
Hi Tan,
If you are connecting to another server you are using a client socket
you do not need to make a server socket. If you need to listen for
connections make use of a server socket. To give you an example your
browser makes use of client sockets while apache makes use of server
sockets. That is an over simplified view of things but hope it helps you
understand things better.
Generally working with client sockets is easier.
best regards
raditha
Tan Ai Leen wrote:
Hi all,
I have this situation now that requires socket programming. But I am not
sure how to realise the requirements in programming whether as a client or
server
The requirement is like this.
I have to connect to an external server constantly to listen for incoming
data. How can I make sure that the connection is there all the time? Upon
receiving the message, I will have to response back an acknowledgement that
the message is received. I can also send data to the server. From my
requirements, I understand that there will only be one connection. Therefore
the data exchange need not be in sequence.
Currently, what I have is a server programmed using the socket library.
Server logic :
socket_create
socket_bind
socket_listen
while(true)
{
socket_select
if(new connection)
{
add to connections array
}
else
{
if(can read)
{
read incoming
response back
}
else
{
//error or connection close
if(error)
{
print error
}
else
{
print connection close
remove from connections array
}
}
}
}
I am planning to include a check somewhere in the codes for maintaining the
connection between my server and the other server. Where should I place it?
Also, I need to initiate a connection to the external server and then
listen. Where should this piece of code be insert at? Is this the right
approach? Or I am over killing by writing a server if this can be handle in
easier manner.
Hope that I have been clear in the above.
Thanks for helping
Ai Leen
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Hi all.
Is it possible to explode an array and have it exclude a certain
string. I currently have an array that is an ldapsearch that returns
sub-accounts of a parent account. These accounts are then displayed so
customer can either change the passwd or delete them. Thing is
ldapsearch returns everymatch which includes the parent account, which
is already listed on the page as the parent account. I would like to
eliminate the second listing of the parent account where the
sub-accounts are listed.
This is where the array is collected:
$search = ldap_search($connection,"dc=isp,dc=com",
"ispParentAcct=$sessUsername");
$entries = ldap_get_entries($connection, $search);
$num = $entries["count"];
if ($num) {
$sessSubAccounts = "";
$i = 0;
while ($i < $num) {
$sessSubAccounts .=
$entries[$i]["uid"][0] . "|";
$i++;
}
}
One thing I would like to point out is that I did not have this problem
before, but when I updated to a new version of openldap the following
ldapsearch would no longer return the subaccounts:
$search = ldap_search($connection,"dc=isp,dc=com",
"homeDirectory=/home/$sessUsername/*");
Any idea why that may be?
This is where the array is exploded:
<?
$i = 0;
if ($sessSubAccounts) {
$accounts = explode("|", $sessSubAccounts);
while ($i < count($accounts) - 1)
?>
TIA
----------------------------------------------------
Bobby R. Cox
Linux Systems Administrator
Project Mutual Telephone
[EMAIL PROTECTED]
208.434.7185
----------------------------------------------------
Fix the problem, not the blame. <><
----------------------------------------------------
--- End Message ---
--- Begin Message ---
I used cron to do this as well; but i devised a much simpler, elegant
solution that is cross-browser and event-based and not schedule-based.
I basically have a javascript include file that instantiates a function that
counts down in T-minus 10 minutes fashion. at 9:30 the browser pops a
window and says "you appear to be inactive; would you like to continue
working?" clicking on yes closes the popup and resets the timer; not
clicking expires the popout which redirects the parent page to the logout.
clicking on "log me out" basically circumvents the 30-second countdown
straight to the logout.
to handle the alt+F4-happy crowd i devised a way to pop a special logout
window when the browser is closed. this child window destroys sessions and
makes database logs; this window closes itself.
this happened to work for me, YMMV.
~phillip jackson
"Craig" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > I can write a script in
> > perl, php, java, u name it, but how do I have it run on a set
> > schedule?
> > Thanks
> >
> > Christian
>
> you will want to use the cron command. run 'man cron' at a shell prompt
> to
> get the manual page that will explain the finer points. =)
>
> HTH,
> Craig
>
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
--- End Message ---
--- Begin Message ---
"Rob" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ive programmed with C/C++ for years and have recently started to dabble in
> PHP. Ive written a multi-part script for a friend and Ive run into a
> problem.
>
> Ive got 14 include files 3 of which are basic components that may or may
not
> be used by other components. One is an authorisation class, another is a
> Dbase clas (For MySQL) and another is a file system component.
>
> Now heres the problem. My authorisation component uses the DBase
component.
> Some of my other components use the DBase component only some of the time
> and the Auth and DBase components some of the time and the Auth component
> some of the time. SO... In the Auth component ive included (via
> include_once()) the DB component, because it needs it. NOW... in other
> modules Ive included (via include_once()) the auth, DB, and gallery
> components.
> Heres where the problem lies. Each component is in a separate file, and
when
> I run the script, I get an arror saying I cant re-define the classes.
> Which makes me believe that the include_once() function is trying to
include
> the other components even though they are already included. So, does that
> mean that include_once() only works right when it is used in the same
file?
> It wont recognise that an include was already included in another include?
> Have I confused you yet? I am.
There may be a problem with include_once, something about where it's placed
and so on...
But anyway I would advise you to not generally rely on include_once() or
require_once().
These are just meant to protect you from making an error, but you should
check to see that you don't use include_once() on the same file many times.
It's bad practice to include one file several times.
One tip i would give you, is to set up one file, something like
"define_classes.inc.php", which is responsable for including the classes and
defining them.
In this way you can just include define_classes.inc.php in the scripts where
you need classes, and your work will be a lot more structured.
I personally use this system on my web-site, and it does that i don't have
to be worried about if I am getting the correct classes, because I get them
all through define_classes.inc.php
Eric
--- End Message ---
--- Begin Message ---
This PHP stuff is too cool!
Thanks for getting me over the hump folks.
Here's my work in progress:
http://hills.ccsf.edu/~pfurma02/index.php?SCREEN=ecards.php
Only the 'next' button works for now but still I'm darn impressed with
myself <g>. This will work on any folder of pictures with a subfolder of
thumbs!
(source code below)
My question is, I'm updating the pages by creating a url back to the
same script with some differing $_REQUEST settings for the page number
(&PAGE=2) and on a smaller screen this bumps the page back to the top.
Is there a better way to do this with some kind of update image function
without getting into incompatible javascript or CSS or am I following
normal procedure? Of course I'll want to be able to click each thumbnail
to bring it into the big picture box, for now it's just displaying the
first image on the page.
Here's another example of such a thing that leads me to believe I'm on
the right track:
http://butterflies.bruciesusenetshit.info/butterflies
<?php
$url = URL_DIR."index.php?SCREEN=ecards.php";
if (isset ($_REQUEST ['IMGDIR'])){
$imagedir=$_REQUEST ['IMG_DIR'];
$subimagedir = $imagedir;
# takes any url from the address bar
# subimagedir is used for setting up relative urls
# imagedir is for getting the directory listing
} else {
$subimagedir = 'grasses';
$imagedir = PUB_DIR . "/" . $subimagedir;
# PUB_DIR global coordinates my public htm location at home & school
}
# get page for large sets
if (isset ($_REQUEST ['PAGE'])){
$page=$_REQUEST ['PAGE'];
} else {$page=1;}
# verify page number after counting the pictures
# if the following is going to take an external url it'll need work
if (!(chdir ($imagedir))){
print "invalid directory";
}
$fh=opendir($imagedir);
# extract & count pictures
while ($file = readdir($fh)){
if (strstr ($file, '.jpg')){
$pictures[] = $file;
}
}
# check picture sizes [LATER TASK]
$thumbsize = 100;
# verify if page number too high & loop back
$pic_count = count($pictures);
$pages = ($pic_count / 6);
if ($page > $pages + 1) {
$page = 1;
$_REQUEST ['PAGE'] = "1";
}
?>
<?
# title row
?>
<div style="font-size:200%">
Current gallery: <?php print $subimagedir ?><br>
</div>
<?
# build the table
?>
<center>
<table width="100%" border=0>
<?
# navigation row and page number
?>
<tr>
<td align="right"">
<a href="<?php print "$url&PAGE=$page"; ?>"> back </a>
</td>
<td align="center">
page: <?php print $page; ?>
</td>
<td align="left">
<a href="<?php
#create a url with a page number one larger
$next = ($page + 1);
if ($next > $pages +1)
# if too big, set back to 1
{
$next = 1;
$_REQUEST ['PAGE'] = "1";
}
print "$url&PAGE=$next";
?>"> next </a>
</td>
</tr>
</table>
<table height="<?php $thumbsize ?>px" valign="center">;
<tr>
<?php
# get six images for the given page
# first picture in index based on current page
$pic_num = ((6 * $page) -6);
# while the picture number has not exceeded
# the current page
# and total images
while ($pic_num <= ((6 * $page) - 1)
and ($pic_num <= $pic_count - 1)){
?>
<td>
<?
#print $pic_num . "   < ";
#print ((6 * $page) - 1) . "   < ";
#print ($pic_count - 1);####################
# create thumbnail image tags
?>
<img src="<?php print $subimagedir ?>/thumbs/<?php print
$pictures[$pic_num] ?>"
alt="<?php print $pictures[$pic_num++] ?>" border=0>
<br>
</td>
<?php }
$pic_num = $pic_num - 6
?>
</tr>
</table>
<table>
<tr>
<td align="center"">
<?
# create large image tag
#need to verify pic_num in last or empty page
?>
<img src="<?php print "$subimagedir/$pictures[$pic_num]"; ?>"
alt="click to select this image" border=0>
</td>
</tr>
</table>
</center>
--- End Message ---
--- Begin Message ---
Paul Furman wrote:
This PHP stuff is too cool!
Thanks for getting me over the hump folks.
Here's my work in progress:
http://hills.ccsf.edu/~pfurma02/index.php?SCREEN=ecards.php
Only the 'next' button works for now...
...Of course I'll want to be able to click each thumbnail
to bring it into the big picture box...
OK I got the thumb links working.
: - )
Damn this PHP is cool!
--- End Message ---