php-general Digest 1 Mar 2006 23:47:18 -0000 Issue 3992

Topics (messages 231254 through 231286):

leading slash in SCRIPT_NAME variable
        231254 by: Roman Rumisek

Re: Dynamic Form List - how to change values
        231255 by: tedd

Re: PDO Changes from 5.0.x To 5.1.x
        231256 by: Jared Williams

ftp_get from an IBM Mainframe z/vm system ?
        231257 by: Nils Reimann
        231260 by: Robin Vickery
        231261 by: Barry

Mailto members..?
        231258 by: Gustav Wiberg
        231259 by: Jim Moseby
        231262 by: Kevin Davies - Bonhurst Consulting
        231263 by: Gustav Wiberg
        231270 by: Gustav Wiberg
        231271 by: Jim Moseby
        231272 by: John Nichel
        231274 by: Gustav Wiberg
        231275 by: Jim Moseby
        231282 by: Gustav Wiberg

Re: fopen failing, permission denied
        231264 by: Dan Baker
        231281 by: Dan Baker

Failed to open stream
        231265 by: tedd
        231266 by: jblanchard.pocket.com
        231267 by: Robin Vickery
        231273 by: tedd
        231276 by: Robin Vickery
        231277 by: John Nichel

preg_replace problem
        231268 by: Benjamin Adams

Re: About date & time...
        231269 by: Gustav Wiberg

internal error when mailing...
        231278 by: Gustav Wiberg
        231280 by: John Nichel
        231283 by: Gustav Wiberg

binding adodb
        231279 by: Raúl Castro Marín

subtract dates
        231284 by: Benjamin Adams
        231285 by: John Nichel
        231286 by: tedd

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hi,

i have configured apache 2.0.50 with mod_php 4.4.2 and
$_SERVER['SCRIPT_NAME'] beginning with /// (three slash).

Where have i a error ? (probably configuration)

Application apache configuration:

Alias /trsklad/ /.../projects/akce/src/html/
<Directory /.../projects/akce/src/html/>
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
</Directory>

Thanks

Rumisek

--- End Message ---
--- Begin Message ---
I have a list from a MYSQL database that I am dumping to a screen. I'd like the user to be able to change the quantity on the form for any record on the screen, then post that information back so the user can review it, and I can then update the database.

Simple checkout routine. Or so I thought.

I have these fields displayed on the screen before the user changes the quantity:

$imageqty = $row["cialbum"]."-".$row["ciset"]."-".$row["ciimage"];
$qty = $row["ciqty"];
print "<td align='center' valign='top'><input type='text' name='$imageqty' size='5' value='$qty'></td>";

I've set the $imageqty variable to hold the initial value from the database. The initial screen works fine.

However, when I reprocess the file, how can I retrieve the original value of the field that is named the same as $imageqty?

The form outputs something like this:
http://.../chkout.php?NATURE-1.jpg=6&continue=Continue+Checkout, which does show the $imageqty of "NATURE-1.jpg" value with the new qty of "6".

How can I get the script to pull the value?

$imageqty = $row["cialbum"]."-".$row["ciset"]."-".$row["ciimage"];
$newqty = $_GET["$imageqty"];

Retrieves nothing.

Thanks for your help.

Pat

Pat:

I would suggest changing to:

http://.../chkout.php?imagename=NATURE-1.jpg&count=6&continue=Continue+Checkout,

$newqty = $_GET['count'];
$imagename = $_GET['imagename'];

Also, to see what you are actually "getting" try:

echo ("<br/>");
echo ("<pre>");
echo ("GET info:\n");
print_r($_GET);
echo("</pre>");

You might also want to consider taking care of undefined variables -- here's a reference:

http://www.weberdev.com/get_example-3823.html

HTH's

tedd

--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
Hi,

Only way I know is to import them into the global scope with define()

If (!defined(PDO_FETCH_ASSOC))
 define('PDO_FETCH_ASSOC', PDO::FETCH_ASSOC);

As for further differences, I'm not aware of any.

Jared

> 
> According to documentation, PDO globals constants in 5.0.3+ 
> were changed to class constants in 5.1.
> 
> Does anyone have a suggestion for portability of constants 
> between the 5.0.x branch and the 5.1 branch without having to 
> rewrite code.
> 
> Besides the constants, what other differences exist in PDO 
> for 5.0.x and 5.1 that may effect portability/functionality?
> 
> Chris D.
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Hi,

i got a realy special problem with a little php work. i need some files from a
z/vm ftp server over an php script. z/vm is a virtualization operating system
for the ibm mainframe. my php script runs on a linux os, mountet on a z/vm
guest. to test if an ftp transfer is possible i've maked some test with a
normal ftp console client and it may be important for helping me if you know
the results.

Here ist the example for a ftp connection to the z/vm ftp .

230 LINUXCL logged in; working directory = LINUXCL
191 Remote system type is z/VM.

ok, we got connected. now it comes the problem, in my opinion.

ftp> ls
500 Unknown command, 'EPSV'
227 Data transfer will passively listen to 172,16,145,65,4,48
125 List started OK
PROFILE EXEC V 42 12 1 2006-02-20 11:19:06 WORK
TEST EXEC V 38 5 1 2006-02-06 14:36:40 WORK
250 List completed successfully.

as you can see, the files in z/vm are not named by the normal way. z/vm naming
need 2 qualifier (actually 3 but thats not important now) so file called

textdata.txt

will be written in z/vm like this

TEXTDATA TXT

put with my console ftp client i got no problems getting that file

ftp> get "TEST EXEC"
local: TEST EXEC remote: TEST EXEC
227 Data transfer will passively listen to 172,16,145,65,4,49
125 Sending file 'TEST.EXEC'
100% |*************************************| 88 99.23 KB/s 00:00 ETA
250 Transfer completed successfully. 88 bytes received in 00:00 (48.85 KB/s)

No problems, so i createt an php script....

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
$download = ftp_get($conn_id, "$locale", "TEST EXEC", FTP_ASCII);
ftp_quit($conn_id);

connection workd, but the download did not. i got this error.

Warning: ftp_get(): Error opening in phpfile on line 174

i think the filenaming makes the problem. chaning "TEST EXEC" to "TEST.EXEC"
works at the ftp console client, but for the php way neither.

i wrote in several forums and you guys are my last hope =)

hope you can help me :)

thx and greetings from germany
nils reimann

--- End Message ---
--- Begin Message ---
On 01/03/06, Nils Reimann <[EMAIL PROTECTED]> wrote:
>
> $conn_id = ftp_connect($ftp_server);
> $login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
> $download = ftp_get($conn_id, "$locale", "TEST EXEC", FTP_ASCII);
> ftp_quit($conn_id);
>
> connection workd, but the download did not. i got this error.
>
> Warning: ftp_get(): Error opening in phpfile on line 174

The format of this error message is "Error opening <local filename> in
<script> on line <line>", so as the local filename is blank, I expect
you've probably left $locale empty.

  -robin

--- End Message ---
--- Begin Message ---
Robin Vickery wrote:
On 01/03/06, Nils Reimann <[EMAIL PROTECTED]> wrote:

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
$download = ftp_get($conn_id, "$locale", "TEST EXEC", FTP_ASCII);
ftp_quit($conn_id);

connection workd, but the download did not. i got this error.

Warning: ftp_get(): Error opening in phpfile on line 174


The format of this error message is "Error opening <local filename> in
<script> on line <line>", so as the local filename is blank, I expect
you've probably left $locale empty.

  -robin
Thats why you should use ...,$locale,... rather then ...,"$locale",...

You will get better errors!

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--- End Message ---
--- Begin Message ---
Hi guys!

Anyone knows of something like this, but for free?
http://www.webscriptsdirectory.com/PHP/E-Mail-Systems/Php-Newsletter-Script-L1237/

All I want to do is to send "a html mail" to all my members at http://www.stammis.com/ (swedish site for pedigrees). It would be a informative letter that tells them about latest news at Stammis Internet.

I could something like this...

while ($dbArray = mysql_fetch_array($querys)) {
...sendmail (from, to, htmltext...)...
}

but this will bring a timeout. Any suggestions? (I don't want to change the timeout - value, it doesn't seem correct)


/G
ps. OT: Planning of making this site Open Source, do you think it matters if the site is in swedish for the sake of Open Source? (the code is in english).
--- End Message ---
--- Begin Message ---
> Hi guys!
> 
> Anyone knows of something like this, but for free?
> http://www.webscriptsdirectory.com/PHP/E-Mail-Systems/Php-News
> letter-Script-L1237/
> 
> All I want to do is to send "a html mail" to all my members at 
> http://www.stammis.com/ (swedish site for pedigrees). It would be a 
> informative letter that tells them about latest news at 
> Stammis Internet.
> 
> I could something like this...
> 
> while ($dbArray = mysql_fetch_array($querys)) {
> ...sendmail (from, to, htmltext...)...
> }
> 
> but this will bring a timeout. Any suggestions? (I don't want 
> to change the 
> timeout - value, it doesn't seem correct)

I wouldn't be shy about adjusting your timeout value.  Its common practice
to do so.  Sounds to me you just need to read up on the mail() function:
http://us3.php.net/manual/en/ref.mail.php There are TONS of code examples in
the comments at the bottom of the page.  Others here have mentioned the use
of a mailer class I can't remember the name of (phpmailer maybe?).

JM

--- End Message ---
--- Begin Message ---
<snip>
Others here have mentioned the use
of a mailer class I can't remember the name of (phpmailer maybe?).
</snip>


PHPMailer is really good for sending HTML/Text/Both emails - I'm using it on
a few different sites.

Link: http://phpmailer.sourceforge.net/

Also, if you're going to use PHPMailer an excellent tutorial can be found
here: http://www.phpfreaks.com/tutorials/130/0.php

HTH

Cheers,

Kev

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Kevin Davies - Bonhurst Consulting" <[EMAIL PROTECTED]> To: "'Jim Moseby'" <[EMAIL PROTECTED]>; "'Gustav Wiberg'" <[EMAIL PROTECTED]>; "'PHP General'" <php-general@lists.php.net>
Sent: Wednesday, March 01, 2006 4:32 PM
Subject: RE: [PHP] Mailto members..?


<snip>
Others here have mentioned the use
of a mailer class I can't remember the name of (phpmailer maybe?).
</snip>


PHPMailer is really good for sending HTML/Text/Both emails - I'm using it on
a few different sites.

Link: http://phpmailer.sourceforge.net/

Also, if you're going to use PHPMailer an excellent tutorial can be found
here: http://www.phpfreaks.com/tutorials/130/0.php

HTH

Cheers,

Kev

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Hi there!

THANX! This was really what I was looking for! :-)

/G

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "Marcus Gnaß" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Wednesday, March 01, 2006 5:29 PM
Subject: Re: [PHP] Mailto members..?


Gustav Wiberg schrieb:
while ($dbArray = mysql_fetch_array($querys)) {
...sendmail (from, to, htmltext...)...
}
Why let PHP do all the work? If the body is all the same for all recipients you could send only one mail with all recipients in the BCC-field and only one dummy-adress in the To-field. This would lead to a very short execution-time.

Marcus

Yes, that's true! Is there any sideffects maybe...?

/G

--- End Message ---
--- Begin Message ---
> > Gustav Wiberg schrieb:
> >> while ($dbArray = mysql_fetch_array($querys)) {
> >> ...sendmail (from, to, htmltext...)...
> >> }
> > Why let PHP do all the work? If the body is all the same for all 
> > recipients you could send only one mail with all recipients in the 
> > BCC-field and only one dummy-adress in the To-field. This 
> would lead to a 
> > very short execution-time.
> >
> > Marcus
> 
> Yes, that's true! Is there any sideffects maybe...?

This type of email may be more susceptible to being caught in spam traps.
Check with your webhost to learn of any limits to the number of recipients
per message, and number of messages per day/hour/etc.

JM

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
----- Original Message ----- From: "Marcus Gnaß" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Wednesday, March 01, 2006 5:29 PM
Subject: Re: [PHP] Mailto members..?


Gustav Wiberg schrieb:
while ($dbArray = mysql_fetch_array($querys)) {
...sendmail (from, to, htmltext...)...
}
Why let PHP do all the work? If the body is all the same for all recipients you could send only one mail with all recipients in the BCC-field and only one dummy-adress in the To-field. This would lead to a very short execution-time.

Marcus

Yes, that's true! Is there any sideffects maybe...?

/G


Outside of being a major spam flag, and possibly reaching the limits of your smtp server.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Jim Moseby" <[EMAIL PROTECTED]> To: "'Gustav Wiberg'" <[EMAIL PROTECTED]>; "Marcus Gnaß" <[EMAIL PROTECTED]>
Cc: "PHP General" <php-general@lists.php.net>
Sent: Wednesday, March 01, 2006 7:29 PM
Subject: RE: [PHP] Mailto members..?



> Gustav Wiberg schrieb:
>> while ($dbArray = mysql_fetch_array($querys)) {
>> ...sendmail (from, to, htmltext...)...
>> }
> Why let PHP do all the work? If the body is all the same for all
> recipients you could send only one mail with all recipients in the
> BCC-field and only one dummy-adress in the To-field. This
would lead to a
> very short execution-time.
>
> Marcus

Yes, that's true! Is there any sideffects maybe...?

This type of email may be more susceptible to being caught in spam traps.
Check with your webhost to learn of any limits to the number of recipients
per message, and number of messages per day/hour/etc.

JM

Aha.. that's a reason good enough for me for not using this method.

Thanx.

/G

--- End Message ---
--- Begin Message ---
> > This type of email may be more susceptible to being caught 
> in spam traps.
> > Check with your webhost to learn of any limits to the 
> number of recipients
> > per message, and number of messages per day/hour/etc.
> >
> > JM
> 
> Aha.. that's a reason good enough for me for not using this method.

It would still be to your advantage to check with your hosting about limits.
I ran up against that on the last newsletter I coded where I could have only
25 recipients per message and 99 total messages per day.

JM

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Jim Moseby" <[EMAIL PROTECTED]> To: "'Gustav Wiberg'" <[EMAIL PROTECTED]>; "Jim Moseby" <[EMAIL PROTECTED]>
Cc: "PHP General" <php-general@lists.php.net>
Sent: Wednesday, March 01, 2006 9:17 PM
Subject: RE: [PHP] Mailto members..?


> This type of email may be more susceptible to being caught
in spam traps.
> Check with your webhost to learn of any limits to the
number of recipients
> per message, and number of messages per day/hour/etc.
>
> JM

Aha.. that's a reason good enough for me for not using this method.

It would still be to your advantage to check with your hosting about limits. I ran up against that on the last newsletter I coded where I could have only
25 recipients per message and 99 total messages per day.

JM

That's true!

Thanx again!

/G

--- End Message ---
--- Begin Message ---
"Chris" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Dan Baker wrote:
>> I have the following code snippet:
>> $h = fopen("$path/file.txt", 'x+');
>>
>> And it generates the following error:
>> Warning: fopen(/home/...../myarea/file.txt): failed to open stream: 
>> Permission denied
>>
>> The path is correct, but the php process doesn't seem to have file 
>> permissions in the folder.
>> Is there some magic I can do to allow php to have file rights to the 
>> "myarea" folder?  (This is on a purchased ISP site)
>
> Go in through ftp or ssh and fix the permissions.
>
> If you only want to read the file, then it only needs to be 644.
>
> If you need to write the file it will either need to be 646 or 664.
>
> That's your only option apart from deleting the file (through ftp) and 
> recreating it through your php script ... or getting your host to change 
> to the CGI version of php which is most unlikely to happen.

I'm actually trying to create the file (thus the 'x+' mode).  The file 
doesn't exists.  It appears to me that the php process doesn't have 
permission to the entire folder.  My ftp client has full access to the 
folder ("myarea"), but the php process doesn't.  The folder is under the 
http folder.  I'll check if I can alter the permissions on the "myarea" 
folder.

DanB

--- End Message ---
--- Begin Message ---
(SOLVED, see below)

"Dan Baker" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Chris" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Dan Baker wrote:
>>> I have the following code snippet:
>>> $h = fopen("$path/file.txt", 'x+');
>>>
>>> And it generates the following error:
>>> Warning: fopen(/home/...../myarea/file.txt): failed to open stream: 
>>> Permission denied
>>>
>>> The path is correct, but the php process doesn't seem to have file 
>>> permissions in the folder.
>>> Is there some magic I can do to allow php to have file rights to the 
>>> "myarea" folder?  (This is on a purchased ISP site)
>>
>> Go in through ftp or ssh and fix the permissions.
>>
>> If you only want to read the file, then it only needs to be 644.
>>
>> If you need to write the file it will either need to be 646 or 664.
>>
>> That's your only option apart from deleting the file (through ftp) and 
>> recreating it through your php script ... or getting your host to change 
>> to the CGI version of php which is most unlikely to happen.
>
> I'm actually trying to create the file (thus the 'x+' mode).  The file 
> doesn't exists.  It appears to me that the php process doesn't have 
> permission to the entire folder.  My ftp client has full access to the 
> folder ("myarea"), but the php process doesn't.  The folder is under the 
> http folder.  I'll check if I can alter the permissions on the "myarea" 
> folder.

I took the suggestion from Chris, and checked the permissions on the 
"myarea" folder.  They were set so others could NOT "write".  I added this 
permission, and everything works great now!

Thanks for the pointer Chris

DanB


--- End Message ---
--- Begin Message ---
Hi gang:

I have two *identical*l routines residing on two difference hosts -- one works and the other doesn't.

Please review (this works):

http://www.webbytedd.com/examples/rank.php

However, this doesn't:

http://www.xn--ovg.com/rank.php

Any idea as to what is wrong?

I can provide code if asked.

Thanks.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
[snip]
I have two *identical*l routines residing on two difference hosts -- 
one works and the other doesn't.
[/snip]

Is safe mode 'on' on one and not the other?

--- End Message ---
--- Begin Message ---
On 01/03/06, tedd <[EMAIL PROTECTED]> wrote:
> Hi gang:
>
> I have two *identical*l routines residing on two difference hosts --
> one works and the other doesn't.
>
> Please review (this works):
>
> http://www.webbytedd.com/examples/rank.php
>
> However, this doesn't:
>
> http://www.xn--ovg.com/rank.php
>
> Any idea as to what is wrong?

Yes. You're violating google's terms of service.

From your script:

 Warning: 
fopen(http://www.google.com/search?client=navclient-auto&ch=61898169760&features=Rank&q=info:webbytedd.com):
failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in
/home/tedd/public_html/rank.php on line 124

From the page that gave you the HTTP 403 Forbidden response (surely
that was a a bit of a clue?):

> Forbidden
> Your client does not have permission to get URL
> /search?client=navclient-auto&ch=61898169760&features=Rank&q=info:webbytedd.com
> from this server. (Client IP address: xx.xx.xx.xx)
>
> Please see Google's Terms of Service posted at 
> http://www.google.com/terms_of_service.html

From google's terms of service:
>
> You may not send automated queries of any sort to Google's system without
> express permission in advance from Google. Note that "sending automated
> queries" includes, among other things:
>
>    * using any software which sends queries to Google to determine how a
>       website or webpage "ranks" on Google for various queries;

  -robin

--- End Message ---
--- Begin Message ---
 > Please review (this works):

 http://www.webbytedd.com/examples/rank.php

 > However, this doesn't:

 http://www.xn--ovg.com/rank.php
 >
 Any idea as to what is wrong?

Yes. You're violating google's terms of service.

Okay, so one is violating google's terms of service and failing while the other isn't? OR are they both violating, but one slipping through, or what?

From the page that gave you the HTTP 403 Forbidden response (surely
that was a a bit of a clue?):

Yeah, that was a clue -- but not why one works and the other doesn't. Do you have a clue as to why?

The point here was that I was trying to learn -- I'm sure that my code is NOT representative of Google's current PageRank system and I'm not using it for any purpose other than to learn.

In any event, considering the Google Police here, I've removed the offending code.

Question closed.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
On 01/03/06, tedd <[EMAIL PROTECTED]> wrote:
>
> In any event, considering the Google Police here, I've removed the
> offending code.
>

Google Police? Aye, right!

You asked why your script was failing. It's failing because they
detected you were breaking their terms. Couldn't care less myself;
it's not a php problem.

 -robin

--- End Message ---
--- Begin Message ---
tedd wrote:
 > Please review (this works):

 http://www.webbytedd.com/examples/rank.php

 > However, this doesn't:

 http://www.xn--ovg.com/rank.php
 >
 Any idea as to what is wrong?

Yes. You're violating google's terms of service.

Okay, so one is violating google's terms of service and failing while the other isn't? OR are they both violating, but one slipping through, or what?

From the page that gave you the HTTP 403 Forbidden response (surely
that was a a bit of a clue?):

Yeah, that was a clue -- but not why one works and the other doesn't. Do you have a clue as to why?

The point here was that I was trying to learn -- I'm sure that my code is NOT representative of Google's current PageRank system and I'm not using it for any purpose other than to learn.

In any event, considering the Google Police here, I've removed the offending code.

Google Police???  Here???  Quick, somebody get me my tin-foil hat!!!

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
$file = dog.txt;
$today = date("Ymd");

function incDate($new, $date){
        //$date = settype('int');
        return $new.($date++);
}

$getOldValue = parse_ini_file($file, 1);
$newValue = $getOldValue[$today] + 1;
$oldDate = $today . " = ". $newValue;
$newDate = preg_replace('/(\d+\s\=\s)(\d+)/ie', 'incDate("$1","$2")', $oldDate);
file_put_contents($file, $newDate . "\n");

This works with one file but with multi lines I'm having trouble:
if the file has:
20060301 = 34
20060302 = 3
the file after script will be:
20060302 = 4

I want it to preserve the previous lines
so output should be:
20060301 = 34
20060302 = 4

Help would be great, thanks
Ben

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Marcus Gnaß" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Wednesday, March 01, 2006 5:24 PM
Subject: Re: [PHP] About date & time...


Gustav Wiberg schrieb:
function currenttime() {

 $t = date('h\:\ i\:\ s');
 $returnTime = str_replace(" ", "", $t);
 return $returnTime;

}

function currentdate() {

 $d = date('Y\-\ m\-\ d');
 $returnDate = str_replace(" ", "", $d);
 return $returnDate;

}
Although beeing a totally noob to PHP I suggest this instead:
function currenttime() {return date('H\:i\:s');}
function currentdate() {return date('Y\-m\-d');}

Marcus

Why?

return date('H\:i\:s') doesn't work as expected... :-)

/G

--- End Message ---
--- Begin Message ---
Here's my code


<?php
//Thanx to jcwebb at dicoe dot com
//base of the code at php.net is used here
// Is the OS Windows or Mac or Linux
//
if (strtoupper(substr(PHP_OS,0,3)=='WIN')): $eol="\r\n"; elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')): $eol="\r"; else: $eol="\n"; endif;

//Message Subject
$emailsubject="Stammis Internet nyhetsbrev " . date("Y/m/d H:i:s");

//Message Body
ob_start();
require("emailbody.php"); // page for showing in the email (no html and body-tags here)
$body=ob_get_contents(); ob_end_clean();

// Common Headers
//

$headers .= 'From: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Reply-To: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Return-Path: Stammis Internet <[EMAIL PROTECTED]>'.$eol; // these two to set reply address $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-type: text/html; charset=iso-8859-1\n";

// HTML Version
//
$msg = $body.$eol.$eol;

// SEND THE EMAIL(s)
// FROM MYSQL-db
//

require("../phpfunctions/opendb.php");

$sql = "SELECT mail FROM tbusers ORDER BY mail";
$querys = mysql_query($sql);

while ($dbArray = mysql_fetch_array($querys)) {
$dbMail = $dbArray["mail"];

$emailaddress=$dbMail;

ini_set(sendmail_from,'[EMAIL PROTECTED]'); // the INI lines are to force the From Address to be used !
 mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);

echo "SENT EMAIL TO $dbMail right now....<br>";
}

mysql_close();
?>

When I tested this script all mails I think was sent, BUT this error showed when the loop hade gone through all posts...


HTTP/1.1 200 OK Date: Wed, 01 Mar 2006 20:41:15 GMT Server: Apache X-Powered-By: PHP/4.4.1 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1
OK
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



What could have caused this?



/G

ps. YES http://phpmailer.sourceforge.net/ seems very great, but this code above is mostly for testing and experimenting...
--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
Here's my code


<?php
//Thanx to jcwebb at dicoe dot com
//base of the code at php.net is used here
// Is the OS Windows or Mac or Linux
//
if (strtoupper(substr(PHP_OS,0,3)=='WIN')): $eol="\r\n"; elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')): $eol="\r"; else: $eol="\n"; endif;

//Message Subject
$emailsubject="Stammis Internet nyhetsbrev " . date("Y/m/d H:i:s");

//Message Body
ob_start();
require("emailbody.php"); // page for showing in the email (no html and body-tags here)
$body=ob_get_contents(); ob_end_clean();

// Common Headers
//

$headers .= 'From: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Reply-To: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Return-Path: Stammis Internet <[EMAIL PROTECTED]>'.$eol; // these two to set reply address $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-type: text/html; charset=iso-8859-1\n";

// HTML Version
//
$msg = $body.$eol.$eol;

// SEND THE EMAIL(s)
// FROM MYSQL-db
//

require("../phpfunctions/opendb.php");

$sql = "SELECT mail FROM tbusers ORDER BY mail";
$querys = mysql_query($sql);

while ($dbArray = mysql_fetch_array($querys)) {
$dbMail = $dbArray["mail"];

$emailaddress=$dbMail;

ini_set(sendmail_from,'[EMAIL PROTECTED]'); // the INI lines are to force the From Address to be used !
 mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);

echo "SENT EMAIL TO $dbMail right now....<br>";
}

mysql_close();
?>

When I tested this script all mails I think was sent, BUT this error showed when the loop hade gone through all posts...


HTTP/1.1 200 OK Date: Wed, 01 Mar 2006 20:41:15 GMT Server: Apache X-Powered-By: PHP/4.4.1 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1
OK
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



What could have caused this?

Gremlins?   ;)

Misconfigured mail server.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "John Nichel" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Wednesday, March 01, 2006 9:57 PM
Subject: Re: [PHP] internal error when mailing...


Gustav Wiberg wrote:
Here's my code


<?php
//Thanx to jcwebb at dicoe dot com
//base of the code at php.net is used here
// Is the OS Windows or Mac or Linux
//
if (strtoupper(substr(PHP_OS,0,3)=='WIN')): $eol="\r\n"; elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')): $eol="\r"; else: $eol="\n"; endif;

//Message Subject
$emailsubject="Stammis Internet nyhetsbrev " . date("Y/m/d H:i:s");

//Message Body
ob_start();
require("emailbody.php"); // page for showing in the email (no html and body-tags here)
$body=ob_get_contents(); ob_end_clean();

// Common Headers
//

$headers .= 'From: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Reply-To: Stammis Internet <[EMAIL PROTECTED]>'.$eol;
$headers .= 'Return-Path: Stammis Internet <[EMAIL PROTECTED]>'.$eol; // these two to set reply address $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-type: text/html; charset=iso-8859-1\n";

// HTML Version
//
$msg = $body.$eol.$eol;

// SEND THE EMAIL(s)
// FROM MYSQL-db
//

require("../phpfunctions/opendb.php");

$sql = "SELECT mail FROM tbusers ORDER BY mail";
$querys = mysql_query($sql);

while ($dbArray = mysql_fetch_array($querys)) {
$dbMail = $dbArray["mail"];

$emailaddress=$dbMail;

ini_set(sendmail_from,'[EMAIL PROTECTED]'); // the INI lines are to force the From Address to be used !
 mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);

echo "SENT EMAIL TO $dbMail right now....<br>";
}

mysql_close();
?>

When I tested this script all mails I think was sent, BUT this error showed when the loop hade gone through all posts...


HTTP/1.1 200 OK Date: Wed, 01 Mar 2006 20:41:15 GMT Server: Apache X-Powered-By: PHP/4.4.1 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1
OK
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



What could have caused this?

Gremlins?  ;)

Misconfigured mail server.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

Ok, but the code is okay right?

/G

--- End Message ---
--- Begin Message ---
I got a little question, I just start to use binding adodb but I got a problem: 
my primary query on Oracle is:

$query = "SELECT munici_mun, UPPER(nombre_mun) 
FROM MUNI 
WHERE departa_dpt = ? AND 
munici_mun <= 994";

It is execute with any problem, but when I add another clause with keyword:

AND UPPER(nombre_mun) LIKE '%?%'   then next sentence is execute but no record 
is returned
$query = "SELECT munici_mun, UPPER(nombre_mun) 
FROM MUNI 
WHERE departa_dpt = ? 
AND munici_mun <= 994 
AND UPPER(nombre_mun) LIKE '%?%' 

I think that adodbd doesn't parse "?" like a variable on clause LIKE '%?%'. 
What can I do to write this sentence correctly?

thanks for your help!

--- End Message ---
--- Begin Message --- I'm trying subtract to dates the user enters in and get the days between.
Dates are stored as
date('mdY')
is there a built in function to subtract to dates is this format?

Thanks

--- End Message ---
--- Begin Message ---
Benjamin Adams wrote:
I'm trying subtract to dates the user enters in and get the days between.
Dates are stored as
date('mdY')
is there a built in function to subtract to dates is this format?

Thanks


Built in, not that I'm aware of. However, if you're the one storing the dates, you could store them as a timestamp; if not, you could convert them to a timestamp. Then it's just simple math.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Benjamin:

I'm trying subtract to dates the user enters in and get the days between.
Dates are stored as
date('mdY')
is there a built in function to subtract to dates is this format?


Try this for starters:

<?php
$century = mktime(12, 0, 0, 1, 1, 2001);
$today = time();
$difference = $today - $century;
echo 'This century started ';
echo floor($difference / 84600);
$difference -= 84600 * floor($difference / 84600);
echo ' days, ';
echo floor($difference / 3600);
$difference -= 3600 * floor($difference / 3600);
echo ' hours, ';
echo floor($difference / 60);
$difference -= 60 * floor($difference / 60);
echo " minutes, and $difference seconds ago.";
?>

There are other examples at:

http://www.weberdev.com/get_example-3646.html

http://www.weberdev.com/get_example-3240.html

http://www.weberdev.com/get_example-95.html

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---

Reply via email to