OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 31 Dec 2007 12:11:39 -0000 Issue 5209

php-general-digest-helplists.php.net
Date: Mon Dec 31 2007 - 06:11:39 CST


php-general Digest 31 Dec 2007 12:11:39 -0000 Issue 5209

Topics (messages 266388 through 266424):

Re: Mail system
        266388 by: Stut
        266390 by: tedd
        266391 by: Børge Holen
        266397 by: Richard Lynch
        266399 by: Richard Lynch

I'm trying to sending an image via email
        266389 by: tedd

Re: Question about sqli class
        266392 by: Larry Garfield
        266402 by: Richard Lynch

looping through a $_POST variable
        266393 by: Richard Kurth
        266394 by: Richard Kurth
        266395 by: Richard Lynch
        266398 by: Richard Kurth
        266406 by: dg
        266415 by: Richard Lynch
        266417 by: Richard Kurth
        266419 by: Richard Lynch
        266422 by: Mark Kelly

Re: [BULK] [PHP] I'm trying to sending an image via email
        266396 by: Eddie Dunckley
        266401 by: Eddie Dunckley
        266420 by: tedd

Re: read email
        266400 by: Richard Lynch

Re: Comparison Problems with 5.2.5
        266403 by: Richard Lynch

Re: Using PHP to remove certain number of bytes from file
        266404 by: Richard Lynch

Re: Question regarding linking PHP Parser library into my private Http server
        266405 by: Richard Lynch
        266413 by: Nathan Nobbe

Re: script stoped working over christmas ?
        266407 by: Richard Lynch

Re: php.ini in php5.2.1
        266408 by: Richard Lynch

Re: when does php stop php executing when user clicks stop
        266409 by: Richard Lynch

Re: Unix date (even more bazaar)
        266410 by: Richard Lynch
        266418 by: tedd

Re: socket_read can not read the whole HTTP page?
        266411 by: Richard Lynch

Re: fopen() for http:// sometimes working, sometimes not
        266412 by: Richard Lynch
        266414 by: Richard Lynch

Re: ASP 2 PHP
        266416 by: Richard Lynch

why is <option '97' selected>Japan</option> not highlighted
        266421 by: Mary Anderson
        266423 by: Daniel Brown

simplexml problem
        266424 by: Dani Castaños

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


mattias wrote:
> Yes but i are newbie in php
> I think i should use php exec but i dont know no more

GOOGLE GOOGLE GOOGLE GOOGLE GOOGLE

http://postfixadmin.sourceforge.net/ was the first result I got. Seems
to fit the bill from where I'm sitting.

-Stut

--
http://stut.net/

> -----Ursprungligt meddelande-----
> Från: Stut [mailto:stuttlegmail.com]
> Skickat: den 30 december 2007 22:01
> Till: mattias
> Kopia: php-generallists.php.net
> Ämne: Re: SV: [PHP] Mail system
>
>
> mattias wrote:
>> First of all
>> If you have a bad day don't send to the list
>
> I'm actually having a pretty good day thanks. Seriously though, Google
> for an existing solution, and if there isn't one have a go yourself and
> then ask for help if you have problems.
>
> I apologise if you feel that's harsh, but that's the way it is.
>
> -Stut

attached mail follows:


At 9:15 PM +0000 12/30/07, Stut wrote:
>mattias wrote:
>>Yes but i are newbie in php
>>I think i should use php exec but i dont know no more
>
>GOOGLE GOOGLE GOOGLE GOOGLE GOOGLE
>

Sounds like the Ghost of Thanksgiving Turkey.

I know, my holiday meter is pegged.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On Sunday 30 December 2007 22:10:50 mattias wrote:
> Yes but i are newbie in php
> I think i should use php exec but i dont know no more

See there's no problem havin php reading your files, you just got to make sure
that it's allowed to... PHP is not doing that very well job, so there is some
perl cgi stuff thingy and I don't know.
imho, start tearing apart some software and skip googling, to much small stuff
to figure out just by thinking about it.
It's like trying to think out a car in details all by yerself... could be done
in a few months, but if you're like me... I won't even say it

>
> -----Ursprungligt meddelande-----
> Från: Stut [mailto:stuttlegmail.com]
> Skickat: den 30 december 2007 22:01
> Till: mattias
> Kopia: php-generallists.php.net
> Ämne: Re: SV: [PHP] Mail system
>
> mattias wrote:
> > First of all
> > If you have a bad day don't send to the list
>
> I'm actually having a pretty good day thanks. Seriously though, Google
> for an existing solution, and if there isn't one have a go yourself and
> then ask for help if you have problems.
>
> I apologise if you feel that's harsh, but that's the way it is.
>
> -Stut
>
> --
> http://stut.net/
>
> > -----Ursprungligt meddelande-----
> > Från: Stut [mailto:stuttlegmail.com]
> > Skickat: den 30 december 2007 21:46
> > Till: mattias
> > Kopia: php-generallists.php.net
> > Ämne: Re: [PHP] Mail system
> >
> > mattias wrote:
> >> If i run coureir and postfix
> >> I want to have a signup script
> >> How should the code be written?
> >
> > Since you're asking on a PHP list I'm going to assume you want to use
> > PHP. The answer you seek is... by you, using some form of text editor!
> >
> > We're not here to write code for you. Have a go, then come back if you
> > have problems. The manual will help, as will Google. There's a good
> > chance someone has already done this, so I'd start with Google.
> >
> > -Stut
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
---
Børge Holen
http://www.arivene.net

attached mail follows:


<?php
  $arg1 = escapeshellarg($_POST['arg1'];
  exec("/full/path/to/courier /full/path/to/any/files $arg1", $output,
$error);
  var_dump($output);
  if ($error){
    die("Use shell 'perror $error' to find out what the OS said. Or
install my nifty perror extension.<br
/>\nhttp://l-i-e.com/perror");
  }
?>

You're on your own to figure out the courier and postfix commands you
need to use.

You'll have to ask on courier and postfix mailing lists.

You'll also probably run into permissions issues, as letting the
webserver user (e.g. 'apache') run the postfix binaries is probably
not a Good Idea, really...

You need to think heavily about SECURITY before you do this, and,
frankly, as a newbie, you should probably hire somebody to review your
process/code for you.

I dunno if Shiflett and co. take on such a small task, but somebody
somewhere might... Or maybe the courier/postfix folks can comment on
just how dangerously you are behaving.

On Sun, December 30, 2007 3:10 pm, mattias wrote:
> Yes but i are newbie in php
> I think i should use php exec but i dont know no more
>
> -----Ursprungligt meddelande-----
> Från: Stut [mailto:stuttlegmail.com]
> Skickat: den 30 december 2007 22:01
> Till: mattias
> Kopia: php-generallists.php.net
> Ämne: Re: SV: [PHP] Mail system
>
>
> mattias wrote:
>> First of all
>> If you have a bad day don't send to the list
>
> I'm actually having a pretty good day thanks. Seriously though, Google
> for an existing solution, and if there isn't one have a go yourself
> and
> then ask for help if you have problems.
>
> I apologise if you feel that's harsh, but that's the way it is.
>
> -Stut
>
> --
> http://stut.net/
>
>> -----Ursprungligt meddelande-----
>> Från: Stut [mailto:stuttlegmail.com]
>> Skickat: den 30 december 2007 21:46
>> Till: mattias
>> Kopia: php-generallists.php.net
>> Ämne: Re: [PHP] Mail system
>>
>>
>> mattias wrote:
>>> If i run coureir and postfix
>>> I want to have a signup script
>>> How should the code be written?
>>
>> Since you're asking on a PHP list I'm going to assume you want to
>> use
>> PHP. The answer you seek is... by you, using some form of text
>> editor!
>>
>> We're not here to write code for you. Have a go, then come back if
>> you
>> have problems. The manual will help, as will Google. There's a good
>> chance someone has already done this, so I'd start with Google.
>>
>> -Stut
>
> --
> 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
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Sun, December 30, 2007 3:36 pm, Børge Holen wrote:
> On Sunday 30 December 2007 22:10:50 mattias wrote:
>> Yes but i are newbie in php
>> I think i should use php exec but i dont know no more
>
> See there's no problem havin php reading your files, you just got to
> make sure
> that it's allowed to... PHP is not doing that very well job, so there
> is some
> perl cgi stuff thingy and I don't know.
> imho, start tearing apart some software and skip googling, to much
> small stuff
> to figure out just by thinking about it.
> It's like trying to think out a car in details all by yerself... could
> be done
> in a few months, but if you're like me... I won't even say it

This one time, I worked a summer job for Macon County Highway in
Illinois, and some punk-[bleep] kid decided to take it upon himself to
completely strip down one of their dump trucks to parts...

He got it pretty much all apart in a day, before anybody realized what
he was doing!

They made him put it back together, but he had to have so much help
from the head mechanic, that said head mechanic was very [bleeped]
off...

I think it only took a few days/weeks of their spare time to get it
back together, but it seemed like he was getting razzed forever...

Which reminds me: I've still got a Lionel train engine to re-assemble
from my teen years... But at least I know I can handle that task,
when I have nothing more important to do...

Obligatory On-Topic Forced Analogy:
Fortunately, with code, we can BACKUP before tearing it all apart, or
use subversion (et al) :-)

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Hi gang:

I'm trying to send an image via email (hmm, must be an echo).

In any event, the following is my main-code (word, dude) and a part
of the email I receive back. The image file IS there.

Any suggestions as to what I'm doing wrong?

Cheers,

tedd

-- the code --

$eol="\r\n";
$mime_boundary=md5(time());

$headers = "From: ".$myName."<".$from.">".$eol;
$headers .= "Reply-To: ".$myName."<".$from.">".$eol;
$headers .= "Return-Path: ".$myName."<".$from.">".$eol;
$headers .= "Message-ID: <".time()."-".$from.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related;
boundary=\"".$mime_boundary."\"".$eol;

$handle=fopen($filename, 'rb');
$f_contents=fread($handle, filesize($filename));
$f_contents=chunk_split(base64_encode($f_contents));
fclose($handle);

$msg = "--".$mime_boundary.$eol;
$msg .= "Content-Type: image/jpeg; name=\"".$filename."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment;
filename=\"".$filename."\"".$eol.$eol;
$msg .= $f_contents.$eol.$eol;

mail($to, $subject, $msg, $headers);

-- what I receive --

X-Mailer: PHP v5.1.6
MIME-Version: 1.0
Content-Type: multipart/related; boundary="d4a13b4aa61d40214e49820c8f2e2e2f"

--d4a13b4aa61d40214e49820c8f2e2e2f

Content-Type: image/jpeg; name="tempa.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tempa.jpg"

/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4AJkFkb2JlAGTAAAAAAQMA
-snip- more of the same

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Both ext/mysql and ext/mysqli work exclusively with MySQL databases. They could not talk to SQLite, which is a different database engine entirely.

If you have the choice and are using MySQL 5 and PHP 5, ext/mysqli is generally faster than ext/mysql. More importantly, it supports native prepared statements which is easier to use and more secure than trying to do your own escaping.

Better still would be to use PDO, which provides the advantages of ext/mysqli and supports a half dozen databases using the same (or nearly the same) OO API.

Even better than that is to write your own thin wrapper API and then use mysqli or PDO under the hood. Then if necessary you can switch from one to another with only minimal impact on your application code.

Whether the API is OO or function-oriented doesn't make a huge difference. Prepared statements do.

--Larry Garfield

On Sun, 30 Dec 2007 20:11:16 +0100, alvaro <iormeuskalnet.net> wrote:
> I don´t know if this is the correct place to ask this questions but I
> haver some doubts about using mysqli class in php. I am designing a web
> place using wamp2 (php5, mysql 5.0.x ....). My databases have been done
> using phpmyadmin so they are "normal" mysql, I mean that I have done
> nothing with SQLITE. On the other hand, I am accessing to my databases and
> tables using mysqli class and methods for example:
> $conn = new mysqli ( ..........) (this is what I am using)
> I am using that because I read in the internet that mysqli methods where
> more efficient but I don´t know if it´s correct to use that methods with
> my mysql database (it runs perfect).
>
> so... is it correct? supposing that it´s correct to use it......is it
> faster and better to use mysqli methods than using the functions that were
> used before these new classes appeared?
>
> thanks...
>
> my email is:
> iormeuskalnet.net
>

attached mail follows:


On Sun, December 30, 2007 1:11 pm, alvaro wrote:
> I don´t know if this is the correct place to ask this questions but I
> haver some doubts about using mysqli class in php. I am designing a
> web place using wamp2 (php5, mysql 5.0.x ....). My databases have been
> done using phpmyadmin so they are "normal" mysql, I mean that I have
> done nothing with SQLITE. On the other hand, I am accessing to my
> databases and tables using mysqli class and methods for example:
> $conn = new mysqli ( ..........) (this is what I am using)
> I am using that because I read in the internet that mysqli methods
> where more efficient but I don´t know if it´s correct to use that
> methods with my mysql database (it runs perfect).

You can use either of the clients to access the DB safely.
[At least in theory. I suppose there could exist some unknown bug
that makes a serious difference...]

> so... is it correct? supposing that it´s correct to use it......is it
> faster and better to use mysqli methods than using the functions that
> were used before these new classes appeared?

It might or might not be faster, depending on a lot of factors, I
suspect...

It also might be a lot less stable, since it's a lot less pounded upon
by millions of users.

The speed difference will probably be completely irrelevant to you in
your real-life usage, if you're having to ask here...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


I am trying to loop through a $_POST variable. It comes from a text
area and it will have data like many email address or just one listed
with a space or on a new line. I can't seam to get the data to extract
properly. I have tried this below

$array = explode(' ', $_POST['emails']);
foreach ($array as $value) {
$sql = "SELECT id FROM contacts where emailaddress = '$value' AND
members_id = '$memberid'";
$sql_result=safe_query($sql);
while ($row=mysql_fetch_array($sql_result)){
$id = $row["id"];
$sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id = '$id'";
safe_query($sql1);
}}

attached mail follows:


I am trying to get one email at a time and run it through the loop and
process it but if I have more than one email in the text area it gives
me nothing and does not run
> What kind of problems are you having in extracting the data?
>
> On Dec 30, 2007, at 4:29 PM, Richard Kurth wrote:
>
>> I am trying to loop through a $_POST variable. It comes from a
>> text area and it will have data like many email address or just one
>> listed with a space or on a new line. I can't seam to get the data to
>> extract properly. I have tried this below
>>
>> $array = explode(' ', $_POST['emails']);
>> foreach ($array as $value) {
>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>> members_id = '$memberid'";
>> $sql_result=safe_query($sql);
>> while ($row=mysql_fetch_array($sql_result)){
>> $id = $row["id"];
>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>> '$id'";
>> safe_query($sql1);
>> }}
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>

attached mail follows:


On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
> I am trying to loop through a $_POST variable. It comes from a text
> area and it will have data like many email address or just one listed
> with a space or on a new line. I can't seam to get the data to extract
> properly. I have tried this below
>
> $array = explode(' ', $_POST['emails']);

//see what you have.
//maybe it's not hat you think
var_dump($_POST['emails']);

> foreach ($array as $value) {

//you should probably validate the emails using:

http://php.net/imap_rfc822_parse_adrlist

$value_sql = mysql_real_escape_string($value);

> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
> members_id = '$memberid'";

Use '$value_sql' here.

And I dunno where $memberid came from, but maybe it should be escaped
as well.

> $sql_result=safe_query($sql);

I'm not sure what "safe_query" is doing, and maybe you think it can
escape the data you embedded into the SQL, but I don't see how you can
do that... Sort of a Humpty-Dumpty problem...

> while ($row=mysql_fetch_array($sql_result)){
> $id = $row["id"];
> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
> '$id'";
> safe_query($sql1);
> }}

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


When I do a var_dump($_POST['emails']); it has all the emails in it
string(65) "rkurthcenturytel.net ckurthcenturytel.net
tkurthcenturytel.net"
I will validate the emails after I get the loop to work
$memberid comes from a part of the script I did not show you $memberid
=$_POST["members_id"];
safe_query is a function that I call that does query stuff

function safe_query ($query = ""){
     include ("dataconf.inc.php");
     dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
    global $query_debug;

    if (empty($query)) { return FALSE; }

    if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }

    $result = mysql_query($query)
        or die("Query Failed: "
            ."<li>errorno=".mysql_errno(). "<br>"
            ."<li>error=".mysql_error(). "<br><br>"
            ."<li>query=".$query
        );
    return $result;
}

> On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
>
>> I am trying to loop through a $_POST variable. It comes from a text
>> area and it will have data like many email address or just one listed
>> with a space or on a new line. I can't seam to get the data to extract
>> properly. I have tried this below
>>
>> $array = explode(' ', $_POST['emails']);
>>
>
> //see what you have.
> //maybe it's not hat you think
> var_dump($_POST['emails']);
>
>
>
>> foreach ($array as $value) {
>>
>
> //you should probably validate the emails using:
>
> http://php.net/imap_rfc822_parse_adrlist
>
> $value_sql = mysql_real_escape_string($value);
>
>
>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>> members_id = '$memberid'";
>>
>
> Use '$value_sql' here.
>
> And I dunno where $memberid came from, but maybe it should be escaped
> as well.
>
>
>> $sql_result=safe_query($sql);
>>
>
> I'm not sure what "safe_query" is doing, and maybe you think it can
> escape the data you embedded into the SQL, but I don't see how you can
> do that... Sort of a Humpty-Dumpty problem...
>
>
>> while ($row=mysql_fetch_array($sql_result)){
>> $id = $row["id"];
>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>> '$id'";
>> safe_query($sql1);
>> }}
>>
>
>
>

attached mail follows:


You might want to check the loop alone and check each value of $value:

$array = explode(' ', $_POST['emails']);
foreach($array as $value) {
        print "'$value'<br>";
}

if it works that way, at least you narrow down the possibilities of
weirdness.

On Dec 30, 2007, at 5:34 PM, Richard Kurth wrote:

> When I do a var_dump($_POST['emails']); it has all the emails in it
> string(65) "rkurthcenturytel.net ckurthcenturytel.net tkurthcenturytel.net
> "
> I will validate the emails after I get the loop to work
> $memberid comes from a part of the script I did not show you
> $memberid =$_POST["members_id"];
> safe_query is a function that I call that does query stuff
>
> function safe_query ($query = ""){
> include ("dataconf.inc.php");
> dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
> global $query_debug;
>
> if (empty($query)) { return FALSE; }
>
> if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
>
> $result = mysql_query($query)
> or die("Query Failed: "
> ."<li>errorno=".mysql_errno(). "<br>"
> ."<li>error=".mysql_error(). "<br><br>"
> ."<li>query=".$query
> );
> return $result;
> }
>
>> On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
>>
>>> I am trying to loop through a $_POST variable. It comes from a
>>> text
>>> area and it will have data like many email address or just one
>>> listed
>>> with a space or on a new line. I can't seam to get the data to
>>> extract
>>> properly. I have tried this below
>>>
>>> $array = explode(' ', $_POST['emails']);
>>>
>>
>> //see what you have.
>> //maybe it's not hat you think
>> var_dump($_POST['emails']);
>>
>>
>>
>>> foreach ($array as $value) {
>>>
>>
>> //you should probably validate the emails using:
>>
>> http://php.net/imap_rfc822_parse_adrlist
>>
>> $value_sql = mysql_real_escape_string($value);
>>
>>
>>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>>> members_id = '$memberid'";
>>>
>>
>> Use '$value_sql' here.
>>
>> And I dunno where $memberid came from, but maybe it should be escaped
>> as well.
>>
>>
>>> $sql_result=safe_query($sql);
>>>
>>
>> I'm not sure what "safe_query" is doing, and maybe you think it can
>> escape the data you embedded into the SQL, but I don't see how you
>> can
>> do that... Sort of a Humpty-Dumpty problem...
>>
>>
>>> while ($row=mysql_fetch_array($sql_result)){
>>> $id = $row["id"];
>>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>>> '$id'";
>>> safe_query($sql1);
>>> }}
>>>
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Okay.

Now var_dump($array) and see what it has.

On Sun, December 30, 2007 6:34 pm, Richard Kurth wrote:
> When I do a var_dump($_POST['emails']); it has all the emails in it
> string(65) "rkurthcenturytel.net ckurthcenturytel.net
> tkurthcenturytel.net"
> I will validate the emails after I get the loop to work
> $memberid comes from a part of the script I did not show you
> $memberid
> =$_POST["members_id"];
> safe_query is a function that I call that does query stuff
>
> function safe_query ($query = ""){
> include ("dataconf.inc.php");
> dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
> global $query_debug;
>
> if (empty($query)) { return FALSE; }
>
> if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
>
> $result = mysql_query($query)
> or die("Query Failed: "
> ."<li>errorno=".mysql_errno(). "<br>"
> ."<li>error=".mysql_error(). "<br><br>"
> ."<li>query=".$query
> );
> return $result;
> }
>
>> On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
>>
>>> I am trying to loop through a $_POST variable. It comes from a
>>> text
>>> area and it will have data like many email address or just one
>>> listed
>>> with a space or on a new line. I can't seam to get the data to
>>> extract
>>> properly. I have tried this below
>>>
>>> $array = explode(' ', $_POST['emails']);
>>>
>>
>> //see what you have.
>> //maybe it's not hat you think
>> var_dump($_POST['emails']);
>>
>>
>>
>>> foreach ($array as $value) {
>>>
>>
>> //you should probably validate the emails using:
>>
>> http://php.net/imap_rfc822_parse_adrlist
>>
>> $value_sql = mysql_real_escape_string($value);
>>
>>
>>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>>> members_id = '$memberid'";
>>>
>>
>> Use '$value_sql' here.
>>
>> And I dunno where $memberid came from, but maybe it should be
>> escaped
>> as well.
>>
>>
>>> $sql_result=safe_query($sql);
>>>
>>
>> I'm not sure what "safe_query" is doing, and maybe you think it can
>> escape the data you embedded into the SQL, but I don't see how you
>> can
>> do that... Sort of a Humpty-Dumpty problem...
>>
>>
>>> while ($row=mysql_fetch_array($sql_result)){
>>> $id = $row["id"];
>>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>>> '$id'";
>>> safe_query($sql1);
>>> }}
>>>
>>
>>
>>
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


looks like that is my problem it is not separating the emails
string(67) "rkurthcenturytel.net ckurthcenturytel.net
tkurthcenturytel.net"
array(1) { [0]=> string(67) "rkurthcenturytel.net ckurthcenturytel.net
tkurthcenturytel.net" }

$array = explode(' ', $_POST['emails']);
what should I use for spaces or next line to separate them

> Okay.
>
> Now var_dump($array) and see what it has.
>
> On Sun, December 30, 2007 6:34 pm, Richard Kurth wrote:
>
>> When I do a var_dump($_POST['emails']); it has all the emails in it
>> string(65) "rkurthcenturytel.net ckurthcenturytel.net
>> tkurthcenturytel.net"
>> I will validate the emails after I get the loop to work
>> $memberid comes from a part of the script I did not show you
>> $memberid
>> =$_POST["members_id"];
>> safe_query is a function that I call that does query stuff
>>
>> function safe_query ($query = ""){
>> include ("dataconf.inc.php");
>> dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
>> global $query_debug;
>>
>> if (empty($query)) { return FALSE; }
>>
>> if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
>>
>> $result = mysql_query($query)
>> or die("Query Failed: "
>> ."<li>errorno=".mysql_errno(). "<br>"
>> ."<li>error=".mysql_error(). "<br><br>"
>> ."<li>query=".$query
>> );
>> return $result;
>> }
>>
>>
>>> On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
>>>
>>>
>>>> I am trying to loop through a $_POST variable. It comes from a
>>>> text
>>>> area and it will have data like many email address or just one
>>>> listed
>>>> with a space or on a new line. I can't seam to get the data to
>>>> extract
>>>> properly. I have tried this below
>>>>
>>>> $array = explode(' ', $_POST['emails']);
>>>>
>>>>
>>> //see what you have.
>>> //maybe it's not hat you think
>>> var_dump($_POST['emails']);
>>>
>>>
>>>
>>>
>>>> foreach ($array as $value) {
>>>>
>>>>
>>> //you should probably validate the emails using:
>>>
>>> http://php.net/imap_rfc822_parse_adrlist
>>>
>>> $value_sql = mysql_real_escape_string($value);
>>>
>>>
>>>
>>>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>>>> members_id = '$memberid'";
>>>>
>>>>
>>> Use '$value_sql' here.
>>>
>>> And I dunno where $memberid came from, but maybe it should be
>>> escaped
>>> as well.
>>>
>>>
>>>
>>>> $sql_result=safe_query($sql);
>>>>
>>>>
>>> I'm not sure what "safe_query" is doing, and maybe you think it can
>>> escape the data you embedded into the SQL, but I don't see how you
>>> can
>>> do that... Sort of a Humpty-Dumpty problem...
>>>
>>>
>>>
>>>> while ($row=mysql_fetch_array($sql_result)){
>>>> $id = $row["id"];
>>>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>>>> '$id'";
>>>> safe_query($sql1);
>>>> }}
>>>>
>>>>
>>>
>>>
>>
>
>
>

attached mail follows:


You should use whatever is actually BETWEEN the emails, which could be
anything...

See the thread about Tedd's bazaar (sic) problem and use the technique
there to see what you are actually getting.

You may even need to resort to a split instead of explode if newlines,
spaces, and carriage-returns are all possible inputs from the end
users...

On Sun, December 30, 2007 7:33 pm, Richard Kurth wrote:
> looks like that is my problem it is not separating the emails
> string(67) "rkurthcenturytel.net ckurthcenturytel.net
> tkurthcenturytel.net"
> array(1) { [0]=> string(67) "rkurthcenturytel.net
> ckurthcenturytel.net
> tkurthcenturytel.net" }
>
> $array = explode(' ', $_POST['emails']);
> what should I use for spaces or next line to separate them
>
>
>> Okay.
>>
>> Now var_dump($array) and see what it has.
>>
>> On Sun, December 30, 2007 6:34 pm, Richard Kurth wrote:
>>
>>> When I do a var_dump($_POST['emails']); it has all the emails in it
>>> string(65) "rkurthcenturytel.net ckurthcenturytel.net
>>> tkurthcenturytel.net"
>>> I will validate the emails after I get the loop to work
>>> $memberid comes from a part of the script I did not show you
>>> $memberid
>>> =$_POST["members_id"];
>>> safe_query is a function that I call that does query stuff
>>>
>>> function safe_query ($query = ""){
>>> include ("dataconf.inc.php");
>>> dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
>>> global $query_debug;
>>>
>>> if (empty($query)) { return FALSE; }
>>>
>>> if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
>>>
>>> $result = mysql_query($query)
>>> or die("Query Failed: "
>>> ."<li>errorno=".mysql_errno(). "<br>"
>>> ."<li>error=".mysql_error(). "<br><br>"
>>> ."<li>query=".$query
>>> );
>>> return $result;
>>> }
>>>
>>>
>>>> On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
>>>>
>>>>
>>>>> I am trying to loop through a $_POST variable. It comes from a
>>>>> text
>>>>> area and it will have data like many email address or just one
>>>>> listed
>>>>> with a space or on a new line. I can't seam to get the data to
>>>>> extract
>>>>> properly. I have tried this below
>>>>>
>>>>> $array = explode(' ', $_POST['emails']);
>>>>>
>>>>>
>>>> //see what you have.
>>>> //maybe it's not hat you think
>>>> var_dump($_POST['emails']);
>>>>
>>>>
>>>>
>>>>
>>>>> foreach ($array as $value) {
>>>>>
>>>>>
>>>> //you should probably validate the emails using:
>>>>
>>>> http://php.net/imap_rfc822_parse_adrlist
>>>>
>>>> $value_sql = mysql_real_escape_string($value);
>>>>
>>>>
>>>>
>>>>> $sql = "SELECT id FROM contacts where emailaddress = '$value' AND
>>>>> members_id = '$memberid'";
>>>>>
>>>>>
>>>> Use '$value_sql' here.
>>>>
>>>> And I dunno where $memberid came from, but maybe it should be
>>>> escaped
>>>> as well.
>>>>
>>>>
>>>>
>>>>> $sql_result=safe_query($sql);
>>>>>
>>>>>
>>>> I'm not sure what "safe_query" is doing, and maybe you think it
>>>> can
>>>> escape the data you embedded into the SQL, but I don't see how you
>>>> can
>>>> do that... Sort of a Humpty-Dumpty problem...
>>>>
>>>>
>>>>
>>>>> while ($row=mysql_fetch_array($sql_result)){
>>>>> $id = $row["id"];
>>>>> $sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
>>>>> '$id'";
>>>>> safe_query($sql1);
>>>>> }}
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Hi.

On Monday 31 December 2007 00:34, Richard Kurth wrote:
> When I do a var_dump($_POST['emails']); it has all the emails in it
> string(65) "rkurthcenturytel.net ckurthcenturytel.net
> tkurthcenturytel.net"

Then this simple regex should do you; just use it instead of explode:

$AddressList = preg_split('/\s+/', $_POST['emails']);

> I will validate the emails after I get the loop to work

An better idea might be to do that INSIDE the loop (the following assumes
your $memberid is a number, adjust to suit if this is not the case):

foreach ($AddressList as $emailaddress) {
    // Escape the data before letting it near the db
    $SAFE_emailaddress = mysql_real_escape_string($emailaddress);
    $SAFE_memberid = intval($_POST["members_id"]);
    // Build the query
    $sql = "SELECT id
            FROM contact
            WHERE emailaddress = '$SAFE_emailaddress'
            AND members_id = '$SAFE_memberid'";
    // etc. etc.
    }

> safe_query is a function that I call that does query stuff

That is a *terrible* name for that function, as it does nothing at all to
make the query safe. You might consider renaming it to run_query or
something. Remember, other people may have to make sense of your code one
day.

Hope this helps,

Mark

attached mail follows:


On Sun 30 Dec 07, tedd wrote:
> I'm trying to send an image via email (hmm, must be an echo).
> In any event, the following is my main-code (word, dude) and a part
> of the email I receive back. The image file IS there.
> Any suggestions as to what I'm doing wrong?

> -- the code --
> $msg .= "Content-Disposition: attachment;
> filename=\"".$filename."\"".$eol.$eol;
> $msg .= $f_contents.$eol.$eol;

guess/think that should read:
$msg .= $f_contents.$eol. $boundary . "---" . $eol;
i.e. message needs a closing boundary terminated with either 2 or 3
dashes (cant remember off-hand).

--
Eddie
Most burning issues generate far more heat than light.

attached mail follows:


> On Sun 30 Dec 07, tedd wrote:
> > I'm trying to send an image via email (hmm, must be an echo).
> > In any event, the following is my main-code (word, dude) and a part
> > of the email I receive back. The image file IS there.
> > Any suggestions as to what I'm doing wrong?
> >
> > -- the code --
> > $msg .= "Content-Disposition: attachment;
> > filename=\"".$filename."\"".$eol.$eol;
> > $msg .= $f_contents.$eol.$eol;

On Mon 31 Dec 07, Eddie Dunckley wrote:
> guess/think that should read:
> $msg .= $f_contents.$eol. $boundary . "---" . $eol;
> i.e. message needs a closing boundary terminated with either 2 or 3
> dashes (cant remember off-hand).

oops .. didnt read properly.
$msg .= $f_contents . $eol . '--' . $mime_boundary . "---" . $eol.$eol;

send yourself an email with an attachment and view the email source and
compare with your program output.

or you could just google for MIME.class site:*.phpbuilder.net and
download and use it like

require_once("MIME.class");

// check if parm bcc is in lib, think its not.
$msg = new MIME_mail($from, $to,$cc,$bcc, $subject);

$msg->fattach($filename);
// parms = $path, $description, $contenttype=OCTET, $encoding=BASE64,
//$disp='inline' etc, view the mime class to see options

$msg->send_mail();

--
Eddie
Dreams are free, but you get soaked on the connect time.

attached mail follows:


>oops .. didnt read properly.
>$msg .= $f_contents . $eol . '--' . $mime_boundary . "---" . $eol.$eol;
>
>send yourself an email with an attachment and view the email source and
>compare with your program output.
>

Yep, it's -- two hyphens.

Thanks,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On Sun, December 30, 2007 2:19 pm, Yui Hiroaki wrote:
> HI!
>
> I am trying to access qmail with php.
>
> Why!
> Because I would like to read mail who someone send an email me to
> qmail.
>
> If anyone knows the code, please send me the code.

http://php.net/imap

Sample Code:

http://l-i-e.com/imap/index.phps

Some spam filtering I set up to catch what slips through spam assasin
and get the email sorted server-side rather than have my desktop
client CHOKES trying to sort out thousands of emails upon login...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


You want >= and not =>

The => operator doesn't even make any sense in that context, as far
as I know...

On Sun, December 30, 2007 8:34 am, Magnus Anderson wrote:
>
> Hi,
>
> I have runned into a slight annoying problem with my code, that I have
> never
> had before.
> Either I have something wrong in my code or PHP 5.2.5 that I user is
> acting
> weird in windows. I have recently installed PHP on my windows machine
> for
> local developement instead of a remote server.
>
> What I try to do is to make an if statement betwean two string
> numbers.
>
> $_USER['level'] = The level the user has
>
> The $_USER['level'] string is taken from the Database and is "5".
>
> This will not work (I expect this to work since _USER['level'] is 5)
> if($_USER['level'] => 5)
>
> This will work (And I expect it to work to)
> if($_USER['level'] => 6)
>
> This will work (Not supposed to work since _USER['level'] is 5)
> if($_USER['level'] > 5)
>
> --
> View this message in context:
> http://www.nabble.com/Comparison-Problems-with-5.2.5-tp14547671p14547671.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Sun, December 30, 2007 11:20 am, Scott Wilcox wrote:
> Is it possible with PHP to remove a certain number of bytes from a
> file,
> purely within PHP?
>
> If so, does someone have an example of doing this, removing the first
> 230 bytes from a file.

Something like this might work:

<?php
  $path = "/full/path/to/file";
  $file = fopen($path, 'r+') or die("Could not open $path");
  //read 200 bytes
  $goners = fread($file, 200);
  if (!strlen($goners) === 200){
    ftruncate($file, 0);
  }
  $offset = 0;
  while(!feof($file)){
    $buffer = fread($file, 2048);
    ftell($file, $offset);
    fwrite($file, $buffer);
    $offset += strlen($buffer);
    ftell($file, $offset + 200);
  }
?>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Sun, December 30, 2007 3:02 am, Talya Nevo wrote:
> I am porting my software from Linux to µC/OS-II OS.
> On Linux I ran the Boa Web server with PHP.
> The µC/OS-II has a basic open source Http Server that does not support
> PHP or CGI.
>
> What I was able to do - is from the Http server, each time an http
> request is received, call using 'System' function the PHP interpreter
> program (like from cli) with input the requested page.
> This seams to basically work but it is not efficient at all.
>
> What I would like to do is to link the Http Server to the basic PHP
> parser library and call the 'parse' function each time the server gets
> an http request.
>
> Is this possible?
> Does anyone know how to do this - which library to link to, which
> function to call, maybe an example.
>
> Thanks for your help.
>
> Talya Nevo
> talya.nevoceleno.com

You could probably have a MUCH easier time and benefit the PHP
community a WHOLE lot more by looking at the Apache/CLI/Isapi API
implementations.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Dec 30, 2007 7:57 PM, Richard Lynch <ceol-i-e.com> wrote:

> On Sun, December 30, 2007 3:02 am, Talya Nevo wrote:
> > I am porting my software from Linux to µC/OS-II OS.
> > On Linux I ran the Boa Web server with PHP.
> > The µC/OS-II has a basic open source Http Server that does not support
> > PHP or CGI.
> >
> > What I was able to do - is from the Http server, each time an http
> > request is received, call using 'System' function the PHP interpreter
> > program (like from cli) with input the requested page.
> > This seams to basically work but it is not efficient at all.
> >
> > What I would like to do is to link the Http Server to the basic PHP
> > parser library and call the 'parse' function each time the server gets
> > an http request.
> >
> > Is this possible?
> > Does anyone know how to do this - which library to link to, which
> > function to call, maybe an example.
> >
> > Thanks for your help.
> >
> > Talya Nevo
> > talya.nevoceleno.com
>
> You could probably have a MUCH easier time and benefit the PHP
> community a WHOLE lot more by looking at the Apache/CLI/Isapi API
> implementations.
>

or maybe something more lean like lighttpd would be a bit easier.
(it supports php via cgi and optionally fastcgi)

-nathan

attached mail follows:


Dude, put some error checking in there...

On Sat, December 29, 2007 5:23 am, Joker7 wrote:
> Can anyone see why this has stopped working...
> latest.php is used with <?
> include("/home/sever2/public_html/teaup/article/article_summary.php")
> ?> to
> show the latest news articles.
>
> Cheers
> Chris
>
> config.php
> <?php
> $max_summary = 6;
> $max_latest = 7;
> $summary_template = "t_summary.tp";
> $article_template = "t_article.tp";
> $password = "password";
> ?>
>
> latest.php
> <?php
>
> require('config.php');
>
> $filename = "article_summary.php";
>
> #- open article summaries
> if(file_exists($filename)){
> $fh = fopen($filename, "r");

if (!$fh) die("Failed to open $filename");

> $old_news = fread($fh, filesize($filename));
> fclose($fh);
> }
else{
die("file $filename does not exist!");
>
> #- get article
> $articles = explode("<!--ARTICLE-->", $old_news);
> $i=0;
> foreach ( $articles as $article ){
> if(count($articles)>$i){
> if($max_latest >= $i++){
> print $article;
> }
> }
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


make install should install one, but may be putting it in some place
that it's not expected.

If you are using some kind of package manager like apt-get or RedHat
rpms or whatever, you are in duck soup for where some package-maker
THINKS they should put the php.ini file, and where their binary
actually looks for it...

You can always just COPY the php.ini-dist file to where phpinfo() says
it should be and then edit it.

If PHP cannot find the file, it just uses all the defaults, so it's no
real shock that there's nothing there.

On Sat, December 29, 2007 12:23 am, jekillen wrote:
> Hello;
> I have not had the necessity to deal with php.ini files for some time.
> Now, because I switch from Sendmail to Postfix on one system I
> need to adjust the sendmail path variable. I cannot find a php.ini
> file
> in the specified location. That is not a problem because I can use
> ini_set(). What is puzzling is that my system,
> I built and installed from source on a number of different systems and
> seem to remember that the process creates a php.ini file. Maybe I have
> it wrong but in the past I seem to remember being able to find one to
> make sure register variables was set to off. (or maybe I ignored it
> because
> that is the default now). So, is the fact that this file is missing
> something
> I should be concerned about?
> PS; I have subscribed to the php-install list and get not responses to
> my posts, or e-mails my ISP says contain viruses, possibly from a user
> who requested I contact him (of her) off list.
> Thanks
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, December 28, 2007 6:33 pm, Eric Wood wrote:
> If database operations are underway when a user accesses a web page,
> then user clicks stop on the browser, does the php stop immediately
> too?

Maybe.

http://php.net/ignore_user_abort

> I'd rather the php continue behind the scenes to fullfill all the
> actions I need it do to whether the user wants to see if happen or
> not.
>
> Overall I wonder how modphp keeps the code executing even if the
> browser
> drops the connection via stop.
>
> Any insight is greatly appreciated.

If you want to be 100% sure something gets done, then don't do it. :-)

Set up a "task" to be done later, and put that in the DB, and then
have a cron job to run through the "tasks" and do them, and mark them
"done" or not.

The fact you are asking indicates that you've got something that takes
too long for a user to wait around anyway, and that's another reason
to just insert a "task" and act on it later.

Don't make a human wait for a slow computer, ever.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Spacing and/or control (unprintable) characters could easily be
messing you up.

Use something like:

$l = strlen($input);
for ($i = 0; $i < $l; $i++){
  echo "$i: $input[$i] (", ord($input[$i]), ")<br />\n";
}
to see what you're getting.

On Fri, December 28, 2007 5:08 pm, tedd wrote:
> At 6:01 PM -0500 12/28/07, tedd wrote:
>>Hi gang:
>>
>>This really bazaar
>>
>>Here's the code and demo:
>>
>>http://webbytedd.com/c/unix-time1/index.php
>>
>>If I cut/paste the following string "as-is" into the "Input Date"
>>portion of the form:
>>
>>10-18-2009 00:00:00
>>
>>It works and returns a UNIX timestamp of 1255885200
>>
>>However, if I cut/paste the following string "as-is" into the "Input
>>Date" portion of the form:
>>
>>10-18-2009 00:00:00
>>
>>It doesn't work and returns a UNIX timestamp of "".
>>
>>Am I going mad? What the hell is the difference between these two
>> stings?
>>
>>Arrgggg!!!! I knew this day would come.
>>
>>tedd
>
>
> As I feared, the email translation made both strings identical -- so
> this won't work for those trying it.
>
> BUT, I do have two strings that look identical but aren't.
>
> I hate it when things like this happen.
>
> 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
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


At 7:07 PM -0600 12/30/07, Richard Lynch wrote:
>Spacing and/or control (unprintable) characters could easily be
>messing you up.
>
>Use something like:
>
>$l = strlen($input);
>for ($i = 0; $i < $l; $i++){
> echo "$i: $input[$i] (", ord($input[$i]), ")<br />\n";
>}
>to see what you're getting.

Richard:

As usual, you are exactly right.

I found that somehow a gremlin had crept in -- I still don't
understand how, but it did. So, I stepped through the string similar
to what you did and replaced everything that wasn't supposed to be
there.

Interesting that making a text file with the string and looking at it
via a Hex Editor, I found that the gremlin was a 0A (new line), but
when it was on the server, it was two characters ("High" ASCII
194/160) -- very strange.

In any event, I fixed it. I didn't have the time to run down why.

Thanks,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


HTTP 1.1 requires more complex client/server interaction, and if your
client (which is about as brain-dead simple as it gets) isn't doing
that complex stuff, 1.1 will not work.

All HTTP 1.1 servers will work just fine with 1.0, so stick with that
unless you really NEED a feature of 1.1

On Fri, December 28, 2007 2:58 am, ked wrote:
> Wow, That's correct answer! Thank to Eddie Dunckley !
>
> scheme:
> $in .= "GET {$file} HTTP/1.0\r\n"; //-----------
> $in .= "Accept: text/html\r\n";
> $in .= "Accept-Language: zh-cn\r\n";
> $in .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
> .NET
> CLR 2.0.50727)\r\n";
> $in .= "Host: {$host}\r\n";
> $in .= "Cache-Control: no-cache\r\n";
> $in .= "Connection: closed\r\n\r\n";//------------must be "closed"
>
> 1.must be "HTTP/1.0" : why? IE post "HTTP/1.1" .
> 2. must be "closed" : so that should be close not closed;
>
> Both modification are required.
>
> Shall anyone tell me sth. about "HTTP/1.0" and "HTTP/1.1" ?
>
> best regards!
> ked
>
>
>> -----Original Message-----
>> From: Eddie Dunckley [mailto:eddierttc.co.za]
>> Sent: Friday, December 28, 2007 3:50 PM
>> To: php-generallists.php.net
>> Subject: Re: [PHP] socket_read can not read the whole HTTP page?
>>
>> On Fri 28 Dec 07, ked wrote:
>> > I wrote those script to get HTTP url content, and it
>> works , but it
>> > can't read the whole content of the page.
>> > Blocked on "while ($out = socket_read($socket, 1024)) ".
>> > $in .= "GET {$file} HTTP/1.1\r\n";
>> try to change this to $in .= "GET {$file} HTTP/1.0\r\n";
>>
>> > $in .= "Connection: Keep-Alive\r\n\r\n";
>> and change this to
>> $in .= "Connection: closed\r\n\r\n";
>>
>> --
>> Eddie Dunckley - eddierttc.co.za - Realtime Travel
>> Connections IBE Development, www.rttc.co.za, cell
>> 083-379-6891, fax 086-617-7831 Where 33deg53'37.23"S
>> 18deg37'57.87"E Cape Town Bellville Oakdale ZA
>> Chaos, panic, and disorder - my work here is done.
>>
>> --
>> 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
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


DNS records are failing to lookup the domain name for you...

Maybe just put the URL back into a queue to try later.

You should also toy with nslookup or dig from the command line and see
if you can get it to fail as often.

On Thu, December 27, 2007 12:00 pm, Albert Wiersch wrote:
>
> Some additional info. It seems I am getting these warnings when it
> fails:
>
> Warning: fopen() [function.fopen]: php_network_getaddresses:
> getaddrinfo
> failed: Name or service not known
>
> Warning: fopen(http://wanganda2u.co.uk) [function.fopen]: failed to
> open
> stream:
>
> Now I have to find out why that is failing some of the time but not
> other
> times.
>
> --
> Albert Wiersch
> Fix your website: http://onlinewebcheck.com
>
>
> ""Albert Wiersch"" <supporthtmlvalidator.com> wrote in message
> news:D5.5A.52211.973D3774pb1.pair.com...
>>
>> I noticed my script at http://onlinewebcheck.com was sometimes
>> (fairly
>> often) failing to open some URLs that users have entered. fopen()
>> returns
>> false very quickly, but when tried again with the same URL,
>> sometimes it
>> works. What would cause this behavior? Why does fopen() occasionally
>> fail
>> to open valid http addresses but works at other times?
>>
>> --
>> Albert Wiersch
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


If it's a busy server, you may be running out of TCP connections...

If PHP can't open ANY connection at all, it can't do a DNS lookup, and
it would fail very fast, as it's hitting an OS limit/cap on the number
of connections and not even getting to try to talk to the Internet.

On Fri, December 28, 2007 12:03 pm, Albert Wiersch wrote:
> I'm now using PHP 5.2.5.
>
> Well, it seems to still be happening. This describes the problem but I
> haven't found a solution that works for me yet:
> http://bugs.php.net/bug.php?id=11058
>
> Is it a PHP problem or DNS? It works sometimes but not other
> times......
> something strange is going on.
>
> Example messages:
> [Fri Dec 28 11:59:04 2007] [error] [client 192.168.0.51] PHP Warning:
> fopen() [<a href='function.fopen'>function.fopen</a>]:
> php_network_getaddresses: getaddrinfo failed: Name or service not
> known
> [Fri Dec 28 11:59:04 2007] [error] [client 192.168.0.51] PHP Warning:
> fopen(http://www.lantanalinks.com) [<a
> href='function.fopen'>function.fopen</a>]: failed to open stream:
> Success
>
> I suppose I could adjust the script to try again if it fails the first
> time,
> but I shouldn't have to.
>
> Some additional info, when it fails with this problem, it fails very
> quickly
> (in less than half a second)... its like it doesn't even try to look
> up the
> name.
>
> --
> Albert Wiersch
> Fix your website: http://onlinewebcheck.com
>
>
> ""Albert Wiersch"" <supporthtmlvalidator.com> wrote in message
> news:D5.5A.52211.973D3774pb1.pair.com...
>>
>> I noticed my script at http://onlinewebcheck.com was sometimes
>> (fairly
>> often) failing to open some URLs that users have entered. fopen()
>> returns
>> false very quickly, but when tried again with the same URL,
>> sometimes it
>> works. What would cause this behavior? Why does fopen() occasionally
>> fail
>> to open valid http addresses but works at other times?
>>
>> --
>> Albert Wiersch
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, December 26, 2007 10:26 am, tedd wrote:
> I have a client who has an entire site done in asp and wants me to
> convert it to php -- is there an easy way to do this or do I have to
> do it line by line?

There once was an asp2php script that would convert the brain-dead
code-by-click-wizard type ASP scripts to PHP with about 90% of it
working right...

If they coded ASP intelligently by hand, then it failed pretty
miserably...

I have no idea how well maintained it is, but Google for it and give
it a whirl.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


in my <select> scrolling list?

Here is the offending code (abbreviated)
<select name="sr_location_id" class="" size=10 >
<option value='94' >Italy</option>
<option value='97' selected>Japan</option>
<option value='252' >Jersey</option>
<option value='294' >Jiangsu</option>
<option value='295' >Jiangxi</option>

I have data series which have a location specified. I wish to edit the
data series. I select the location from the database (Note: database
stuff is not a problem) and display a scrolling list with the location
specified by that data series highlighted. Problem is, even though the
option is marked selected, the Japan entry in the scrolling list does
not highlight.

The offending page may be viewed at

http://www.demog.berkeley.edu/~maryfran/memdev/edit_series.php?sr_data_series_id=2

Sometimes when it loads, Japan is highlighted correctly. Sometimes
nothing is highlighted. Sometimes some random option in the list is
highlighted. Similar behavior is observed in the data series types
scrolling list next to the locations list on the page.

I have been using Firefox 2.0.0.3. I just tried it out on IE7 and it
seems to work OK. Maybe it is a browser problem, but the XDynamic HTML
Definitive Reference seems to say that the selected attribute on option
works OK with mozilla.

attached mail follows:


On Dec 30, 2007 10:46 PM, Mary Anderson <maryfrandemog.berkeley.edu> wrote:
> in my <select> scrolling list?
>
> Here is the offending code (abbreviated)
> <select name="sr_location_id" class="" size=10 >
> <option value='94' >Italy</option>
> <option value='97' selected>Japan</option>
> <option value='252' >Jersey</option>
> <option value='294' >Jiangsu</option>
> <option value='295' >Jiangxi</option>
>
> I have data series which have a location specified. I wish to edit the
> data series. I select the location from the database (Note: database
> stuff is not a problem) and display a scrolling list with the location
> specified by that data series highlighted. Problem is, even though the
> option is marked selected, the Japan entry in the scrolling list does
> not highlight.
>
> The offending page may be viewed at
>
> http://www.demog.berkeley.edu/~maryfran/memdev/edit_series.php?sr_data_series_id=2
>
>
> Sometimes when it loads, Japan is highlighted correctly. Sometimes
> nothing is highlighted. Sometimes some random option in the list is
> highlighted. Similar behavior is observed in the data series types
> scrolling list next to the locations list on the page.
>
> I have been using Firefox 2.0.0.3. I just tried it out on IE7 and it
> seems to work OK. Maybe it is a browser problem, but the XDynamic HTML
> Definitive Reference seems to say that the selected attribute on option
> works OK with mozilla.

    On five attempts, it worked 100% of the time on Firefox 2.0.0.11.

--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

attached mail follows:


Hi all!

I'm using simplexml to load an xml into an object.
The XML is this:
<?xml version="1.0"?>
<request>
  <customerID>3</customerID>
  <appName>agenda</appName>
  <ticketType>cticket_agenda_server</ticketType>
  <ticketTypeID>1</ticketTypeID>
  <platformID>1</platformID>
  <ticketAction>addUsersToGroup</ticketAction>
</request>

When I do this:

$file = simplexml_load_file( 'file.xml' );
$ticketType = $file->ticketType;

What i really have into $ticketType is a SimpleXMLElement... not the
value "cticket_agenda_server"... What am I doing wrong?

Because if I echo this value... Yes, I obtain the
"cticket_agenda_server"... But if I want to use like:

$ticket = new $ticketType( $param1, $param2);

It throws:
Uncaught exception 'Exception' with message
'SimpleXMLElement::__construct() expects parameter 1 to be string, array
given' in C:\Dani\htdocs\ticket_server\ticket_execute.php:134
Stack trace:
#0 C:\Dani\htdocs\ticket_server\ticket_execute.php(134):
SimpleXMLElement->__construct(Array, Object(clogger))
#1 {main}
  thrown

It seems like it uses $ticketType class instead the value inside.

Than you in advance