php-general Digest 9 Jan 2007 04:26:17 -0000 Issue 4559

Topics (messages 246762 through 246778):

Re: unpack on offsets in binary data in variable?
        246762 by: Robert Cummings

Re: send email by php class
        246763 by: Sancar Saran
        246764 by: Jochem Maas

Table contents not updated
        246765 by: Wikus Moller
        246766 by: Wikus Moller
        246770 by: Chris

Confused on the status of a "bogus" bug report
        246767 by: Bill Moran
        246768 by: Jochem Maas
        246769 by: Chris
        246771 by: Robert Cummings
        246772 by: Robert Cummings
        246773 by: Chris
        246774 by: Jochem Maas
        246776 by: Robert Cummings

Convert .txt or .doc to Javascript data format
        246775 by: Jade Tippett
        246777 by: Jochem Maas

Parsing an XML return from a POST
        246778 by: Richard Luckhurst

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 ---
On Mon, 2007-01-08 at 16:20 +0100, Markus Fischer wrote:
> Hi,
> 
> I'm searching for an efficient way to use unpack on binary data within a
> variable (php 5.1.something). In the past I was doing
> 
> fopen
> fseek
> unpack( fread(...)
> fseek
> etc.
> 
> Now this time I need to do the same, but I don't have an actual file: my
> data is only in a variable and I don't want to operate on a file but the
> variable within.

Ummm, you aren't using unpack() on a file in the above example, you're
using it on the string returned by fread(). You use unpack() on strings
and thus it should work fine when you don't have a file.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Monday 08 January 2007 16:56, Jochem Maas wrote:
> [EMAIL PROTECTED] wrote:
> >> [EMAIL PROTECTED] wrote:
> >>> Hi,
>
> ...
>
> >>> Was looking on phpclasses.net for the class but there are tons of them.
> >>> Can somebody recomend any class? Something simple.
> >>
> >> phpmailer.sourceforge.net
> >
> > I think this is it.
> >
> > :)
>
> not to sound like an ass (there's at least 3 people out there that will
> hear me going 'Eeee Aw' regardless of what I say so what the hack) - but
> this has been mentioned about 3 times on the list on the last week, it's
> one of these ones things that keeps coming up.
>
> this is a good example of why scanning the list on a regular basis (and/or
> doing the occasional search in the archives when your looking into a
> problem) is a really good idea.
>
> I can't emphasize enough how much I personally learn from just reading
> questions and answers on this list - many a time I've [vaguely] remembered
> reading something that I didn't quite understand at the time but 6 months
> later I was confronted by a similar problem and I was able to solve the
> problem in a fraction of the time that it would have taken if I had not
> read whatever thread was relevant.
>
> an extension to this is trying to answer questions that you don't actually
> know the answers to ... the act of trying to figure out someone else's
> questions/problems can often be a great way to increase your skills ...
> additionally it's good practice for solving the problems you encounter in
> your own work, I remember when I first started out that trying things out,
> researching and debugging problems was often a very daunting proposition
> [that never-ending-story feeling] ... I have found that the more practice
> the less impedance I find when it comes to figuring out something I'm stuck
> on ... this is pretty obvious I guess, but worth mentioning.

After using this kind of lists, forums, boards, people realize, asking same 
question again and again easier than diggin entire list and or searching 
manuals etc.

Yes you are absolute right about dealing others questions makes you stronger 
and this is Shaolin Monk aproach and another question was is that people 
wants to be stronger?

Anyhow this is one of the can't be solved problem of internet (and or mailing 
lists, forums etc.) . People will asking same question again and again... 

Regards

Sancar

--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
> On Monday 08 January 2007 16:56, Jochem Maas wrote:
>> [EMAIL PROTECTED] wrote:
>>>> [EMAIL PROTECTED] wrote:
>>>>> Hi,
>> ...
>>
>>>>> Was looking on phpclasses.net for the class but there are tons of them.
>>>>> Can somebody recomend any class? Something simple.
>>>> phpmailer.sourceforge.net
>>> I think this is it.
>>>
>>> :)
>> not to sound like an ass (there's at least 3 people out there that will
>> hear me going 'Eeee Aw' regardless of what I say so what the hack) - but
>> this has been mentioned about 3 times on the list on the last week, it's
>> one of these ones things that keeps coming up.
>>
>> this is a good example of why scanning the list on a regular basis (and/or
>> doing the occasional search in the archives when your looking into a
>> problem) is a really good idea.
>>
>> I can't emphasize enough how much I personally learn from just reading
>> questions and answers on this list - many a time I've [vaguely] remembered
>> reading something that I didn't quite understand at the time but 6 months
>> later I was confronted by a similar problem and I was able to solve the
>> problem in a fraction of the time that it would have taken if I had not
>> read whatever thread was relevant.
>>
>> an extension to this is trying to answer questions that you don't actually
>> know the answers to ... the act of trying to figure out someone else's
>> questions/problems can often be a great way to increase your skills ...
>> additionally it's good practice for solving the problems you encounter in
>> your own work, I remember when I first started out that trying things out,
>> researching and debugging problems was often a very daunting proposition
>> [that never-ending-story feeling] ... I have found that the more practice
>> the less impedance I find when it comes to figuring out something I'm stuck
>> on ... this is pretty obvious I guess, but worth mentioning.
> 
> After using this kind of lists, forums, boards, people realize, asking same 
> question again and again easier than diggin entire list and or searching 
> manuals etc.
> 
> Yes you are absolute right about dealing others questions makes you stronger 
> and this is Shaolin Monk aproach and another question was is that people 
> wants to be stronger?

funny that you mention Shaolin Monks ... I stayed up way too late last night
watching a Discovery Channel (or was it Nat. Geo.?) documentary about the
Shaolin Monk that defected to the US - and now hangs out with the Wu Tang Clan!
(amongst others). most inspiring stuff :-)

> 
> Anyhow this is one of the can't be solved problem of internet (and or mailing 
> lists, forums etc.) . People will asking same question again and again... 

I would have to agree with you! I just can't help trying though, regardless :-)
maybe it's penance for all the dumb questions I have posted (and no doubt will
post again)

> 
> Regards
> 
> Sancar
> 

--- End Message ---
--- Begin Message ---
Hi.

I am new to uising html forms with php and I am having a problem with
database contents not being updated although it seems my coding is
correct.

It's a xhtml formatted site with html forms:

Here are my functions:

<?
function login($uid, $pwd)
{
 $pass = md5($pwd);
 $pasw = mysql_fetch_array(mysql_query("SELECT pass FROM members
WHERE name='".$uid."'"));
 $dbpw = $pasw[0];
 if($pass == $dbpw)
 {
   $banned=mysql_fetch_array(mysql_query("SELECT * FROM members WHERE
banned='1' and name='".$uid."'"));
   if($banned)
   {
     return 2;
   }else{
       return 0;
   }

 }else{
   return 1;
 }
}


function 
edtsite($username,$pass,$snm,$lnk,$imgu,$catg,$uid,$dsc,$keywords,$weblnk,$sid)
       {


        if (login($username,$pass)==0)
          {
           $adds=mysql_query("UPDATE sub_sites SET
sitename='".$snm."', sitelink='".$lnk."', sitelogo='".$image."',
catid='".$catg."', uid='".$uid."', dscr='".$dsc."',
keywords='".$keywords."', weblink='".$weblnk."' WHERE id='".$sid."'");
           if ($adds) {

           return true;
           } else {

             return false ;
          }
       }else{
         return false;
       }
       }
?>

Everything seems to be correct, but the table isn't updated...

<?
 echo "<form method=\"post\"
action=\"editsitefin.php?uid=$uid&amp;pwd=$pwd&amp;sid=$sid\">";
 echo "*Site Name: <input type=\"text\" name=\"snm\" maxlength=\"30\"
size=\"10\" value=\"$sites[1]\"/><br/>";
 echo "*Wap Link: <input type=\"text\" name=\"lnk\" maxlength=\"200\"
size=\"10\" value=\"$sites[3]\"/><br/>";
 echo "Web Link: <input type=\"text\" name=\"weblnk\"
maxlength=\"200\" size=\"10\" value=\"$sites[14]\"/><br/>";
 echo "Logo URL: <input type=\"text\" name=\"imgu\" maxlength=\"200\"
size=\"10\" value=\"$sites[4]\"/><br/>";
 echo "*Description: <input type=\"text\" name=\"dsc\"
maxlength=\"200\" size=\"10\" value=\"$sites[11]\"/><br/>";
 echo "*Category:";
 echo "<select name=\"catg\" value=\"$sites[2]\">";
 echo "<option value=\"1\">Entertainment</option>";
 echo "<option value=\"2\">Portal - Search</option>";
 echo "<option value=\"3\">Messaging - Chat</option>";
 echo "<option value=\"4\">Ringtones - Logos</option>";
 echo "<option value=\"5\">Fun - Games</option>";
 echo "<option value=\"6\">Hobbies - Interests</option>";
 echo "<option value=\"7\">Services</option>";
 echo "<option value=\"8\">Personal</option>";
 echo "<option value=\"9\">Others</option>";
 echo "</select><br/>";
 echo "*Keywords: (separate by spaces)<input type=\"text\"
name=\"keywords\" maxlength=\"200\" size=\"20\"
value=\"$sites[13]\"/><br/>";
 echo "* = Denotes a required field.<br/>";
 echo "<input type=\"submit\" name=\"add\" value=\"Edit\"/>";
 echo "</form>";
?>

Theres my form, also everything seems to be correct... The correct
values are displayed when the form is loaded.

<?
$uid=$_GET["uid"];
$pwd=$_GET["pwd"];
$snm = $_POST["snm"];
$lnk = $_POST["lnk"];
$imgu = $_POST["imgu"];
$catg = $_POST["catg"];
$dsc = $_POST["dsc"];
$weblnk = $_POST["weblnk"];
$keywords = $_POST["keywords"];
$sid = $_POST["sid"];

$uidid = mysql_fetch_array(mysql_query("SELECT * from members where
name='".$uid."';"));
$res =  
edtsite($uid,$pwd,$snm,$lnk,$imgu,$catg,$uidid[0],$dsc,$keywords,$weblnk,$sid);
$snm=htmlspecialchars($snm);
if ($res) {
   $stid = mysql_fetch_array(mysql_query("SELECT * from sub_sites
where sitelink='".$lnk."';"));
echo "<head>";
metatags();
echo "<title>Chilling Lounge.net</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";
echo "</head>";
echo "<body>";
echo "<table>";
echo "<div class=\"cre\">";
echo "$snm Updated Successfully</div>";
?>

And theres my site finished page (editsitefin.php), I can't find any
errors, but I am not that clued up with html forms. Does anyone notice
any errors? It displays a success message yet when I look at the
database or when I browse again to the site, the info isn't updated.
Please check if you find any errors that could cause the database
fields not to be updated or suggest a possible fix


Thanks

--- End Message ---
--- Begin Message ---
The function page IS included on every page so that wouldn't be what
is causing the errors.

On 1/8/07, Wikus Moller <[EMAIL PROTECTED]> wrote:
Hi.

I am new to uising html forms with php and I am having a problem with
database contents not being updated although it seems my coding is
correct.

It's a xhtml formatted site with html forms:

Here are my functions:

<?
function login($uid, $pwd)
{
  $pass = md5($pwd);
  $pasw = mysql_fetch_array(mysql_query("SELECT pass FROM members
WHERE name='".$uid."'"));
  $dbpw = $pasw[0];
  if($pass == $dbpw)
  {
    $banned=mysql_fetch_array(mysql_query("SELECT * FROM members WHERE
banned='1' and name='".$uid."'"));
    if($banned)
    {
      return 2;
    }else{
        return 0;
    }

  }else{
    return 1;
  }
}


function
edtsite($username,$pass,$snm,$lnk,$imgu,$catg,$uid,$dsc,$keywords,$weblnk,$sid)
        {


         if (login($username,$pass)==0)
           {
            $adds=mysql_query("UPDATE sub_sites SET
sitename='".$snm."', sitelink='".$lnk."', sitelogo='".$image."',
catid='".$catg."', uid='".$uid."', dscr='".$dsc."',
keywords='".$keywords."', weblink='".$weblnk."' WHERE id='".$sid."'");
            if ($adds) {

            return true;
            } else {

              return false ;
           }
        }else{
          return false;
        }
        }
?>

Everything seems to be correct, but the table isn't updated...

<?
  echo "<form method=\"post\"
action=\"editsitefin.php?uid=$uid&amp;pwd=$pwd&amp;sid=$sid\">";
  echo "*Site Name: <input type=\"text\" name=\"snm\" maxlength=\"30\"
size=\"10\" value=\"$sites[1]\"/><br/>";
  echo "*Wap Link: <input type=\"text\" name=\"lnk\" maxlength=\"200\"
size=\"10\" value=\"$sites[3]\"/><br/>";
  echo "Web Link: <input type=\"text\" name=\"weblnk\"
maxlength=\"200\" size=\"10\" value=\"$sites[14]\"/><br/>";
  echo "Logo URL: <input type=\"text\" name=\"imgu\" maxlength=\"200\"
size=\"10\" value=\"$sites[4]\"/><br/>";
  echo "*Description: <input type=\"text\" name=\"dsc\"
maxlength=\"200\" size=\"10\" value=\"$sites[11]\"/><br/>";
  echo "*Category:";
  echo "<select name=\"catg\" value=\"$sites[2]\">";
  echo "<option value=\"1\">Entertainment</option>";
  echo "<option value=\"2\">Portal - Search</option>";
  echo "<option value=\"3\">Messaging - Chat</option>";
  echo "<option value=\"4\">Ringtones - Logos</option>";
  echo "<option value=\"5\">Fun - Games</option>";
  echo "<option value=\"6\">Hobbies - Interests</option>";
  echo "<option value=\"7\">Services</option>";
  echo "<option value=\"8\">Personal</option>";
  echo "<option value=\"9\">Others</option>";
  echo "</select><br/>";
  echo "*Keywords: (separate by spaces)<input type=\"text\"
name=\"keywords\" maxlength=\"200\" size=\"20\"
value=\"$sites[13]\"/><br/>";
  echo "* = Denotes a required field.<br/>";
  echo "<input type=\"submit\" name=\"add\" value=\"Edit\"/>";
  echo "</form>";
?>

Theres my form, also everything seems to be correct... The correct
values are displayed when the form is loaded.

<?
$uid=$_GET["uid"];
$pwd=$_GET["pwd"];
$snm = $_POST["snm"];
$lnk = $_POST["lnk"];
$imgu = $_POST["imgu"];
$catg = $_POST["catg"];
$dsc = $_POST["dsc"];
$weblnk = $_POST["weblnk"];
$keywords = $_POST["keywords"];
$sid = $_POST["sid"];

$uidid = mysql_fetch_array(mysql_query("SELECT * from members where
name='".$uid."';"));
$res =
edtsite($uid,$pwd,$snm,$lnk,$imgu,$catg,$uidid[0],$dsc,$keywords,$weblnk,$sid);
$snm=htmlspecialchars($snm);
if ($res) {
    $stid = mysql_fetch_array(mysql_query("SELECT * from sub_sites
where sitelink='".$lnk."';"));
echo "<head>";
metatags();
echo "<title>Chilling Lounge.net</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";
echo "</head>";
echo "<body>";
echo "<table>";
echo "<div class=\"cre\">";
echo "$snm Updated Successfully</div>";
?>

And theres my site finished page (editsitefin.php), I can't find any
errors, but I am not that clued up with html forms. Does anyone notice
any errors? It displays a success message yet when I look at the
database or when I browse again to the site, the info isn't updated.
Please check if you find any errors that could cause the database
fields not to be updated or suggest a possible fix


Thanks


--- End Message ---
--- Begin Message ---
Wikus Moller wrote:
Hi.

I am new to uising html forms with php and I am having a problem with
database contents not being updated although it seems my coding is
correct.

Is it getting into the function? What is the exact database query that is being run? Does that return an error when you run it manually?


$adds=mysql_query("UPDATE sub_sites SET
sitename='".$snm."', sitelink='".$lnk."', sitelogo='".$image."',
catid='".$catg."', uid='".$uid."', dscr='".$dsc."',
keywords='".$keywords."', weblink='".$weblnk."' WHERE id='".$sid."'");

You're not doing any escaping here, so a quote or something like that could be causing the problem. I'd suggest using mysql_real_escape_string or mysql_escape_string depending on what version of php you are running (see manual for more info).

$update_query = "UPDATE sub_sites SET
sitename='".mysql_real_escape_string($snm)."', sitelink='".mysql_real_escape_string($lnk) ..............

echo $update_query;

$adds = mysql_query($update_query);

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
With reference to:
http://bugs.php.net/bug.php?id=40067

I'm confused as to why this was marked bogus, and the message that
marked as such doesn't give much insight.

It would seem to me that infinite recursion within PHP is a bug.
Shouldn't the interpreter catch this sort of thing before it
coredumps?  Or is the design philosophy for PHP different than
that?

If anyone can point me to a online explanation for this or other
resource, I'd be happy to read up a bit.  More than happy to understand
why I'm wrong, but right now I feel as if this problem is getting the
brush-off.

-- 
Bill Moran
Collaborative Fusion Inc.

--- End Message ---
--- Begin Message ---
Bill Moran wrote:
> With reference to:
> http://bugs.php.net/bug.php?id=40067
> 
> I'm confused as to why this was marked bogus, and the message that
> marked as such doesn't give much insight.
> 
> It would seem to me that infinite recursion within PHP is a bug.
> Shouldn't the interpreter catch this sort of thing before it
> coredumps?  Or is the design philosophy for PHP different than
> that?

the way I understand it is that there is no decent way for the engine to
tell the difference between a piece of recursive code that will complete
and a piece of recursive code that will never complete ... so the only
sane solution is to leave it up to user land code to make sure the recursive
loop is not infinite.

put another way if the engine catches/stops what it *thinks* is an infinite loop
then how would stopping the loop at an arbitrary location be any better
than dumping core?

I believe this is why the bug was marked as bogus - sorry I can't explain it
any better.

> 
> If anyone can point me to a online explanation for this or other
> resource, I'd be happy to read up a bit.  More than happy to understand
> why I'm wrong, but right now I feel as if this problem is getting the
> brush-off.
> 

--- End Message ---
--- Begin Message ---
Bill Moran wrote:
With reference to:
http://bugs.php.net/bug.php?id=40067

I'm confused as to why this was marked bogus, and the message that
marked as such doesn't give much insight.

It would seem to me that infinite recursion within PHP is a bug.
Shouldn't the interpreter catch this sort of thing before it
coredumps?  Or is the design philosophy for PHP different than
that?

If anyone can point me to a online explanation for this or other
resource, I'd be happy to read up a bit.  More than happy to understand
why I'm wrong, but right now I feel as if this problem is getting the
brush-off.

Getting the interpreter to catch infinite recursion would be bad (imo).

It can actually come in handy if you handle it properly:

while (true) {
  ... do stuff
  if ($conditions_are_met) {
    break;
  }
}

I use this type of idea in some scripts and it works quite well (sometimes I forget the break out part and yeh it causes me some confusion :P).

I think the bug report is too complicated.. there are lots of variables involved in what you posted there and for one of the php c developers it's too time consuming to try and replicate - both your environment (php version, how you have it set up and so on) and your script.

Pear itself is a complicated beast.

If you can narrow it down to a really really simple test case then try again.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
> Bill Moran wrote:
> > With reference to:
> > http://bugs.php.net/bug.php?id=40067
> > 
> > I'm confused as to why this was marked bogus, and the message that
> > marked as such doesn't give much insight.
> > 
> > It would seem to me that infinite recursion within PHP is a bug.
> > Shouldn't the interpreter catch this sort of thing before it
> > coredumps?  Or is the design philosophy for PHP different than
> > that?
> 
> the way I understand it is that there is no decent way for the engine to
> tell the difference between a piece of recursive code that will complete
> and a piece of recursive code that will never complete ... so the only
> sane solution is to leave it up to user land code to make sure the recursive
> loop is not infinite.
> 
> put another way if the engine catches/stops what it *thinks* is an infinite 
> loop
> then how would stopping the loop at an arbitrary location be any better
> than dumping core?

Ummm, on many systems you end up with a core dump with the following
name: core.<pid>. Now multiply that by 1000 at 16 to 32 megs a piece.
Not fun :)

Anyways, the core dump happens because memory is exhausted and the
engine is unable to allocate anymore. It should be possible for PHP to
exit gracefully upon finding itself out of memory... Possibly it could
allocate another 1k and write to the error logfile on which line it was
running when it ran out of memory. Or better yet, maybe a
debug_backtrace() output *drool*.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Tue, 2007-01-09 at 10:01 +1100, Chris wrote:
> Bill Moran wrote:
> > With reference to:
> > http://bugs.php.net/bug.php?id=40067
> > 
> > I'm confused as to why this was marked bogus, and the message that
> > marked as such doesn't give much insight.
> > 
> > It would seem to me that infinite recursion within PHP is a bug.
> > Shouldn't the interpreter catch this sort of thing before it
> > coredumps?  Or is the design philosophy for PHP different than
> > that?
> > 
> > If anyone can point me to a online explanation for this or other
> > resource, I'd be happy to read up a bit.  More than happy to understand
> > why I'm wrong, but right now I feel as if this problem is getting the
> > brush-off.
> 
> Getting the interpreter to catch infinite recursion would be bad (imo).
> 
> It can actually come in handy if you handle it properly:
> 
> while (true) {
>    ... do stuff
>    if ($conditions_are_met) {
>      break;
>    }
> }

Determining infinite recursion pre-emptively is too much work. But it
should be able to catch too much recursion causing memory exhaustion.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Tue, 2007-01-09 at 10:01 +1100, Chris wrote:
Bill Moran wrote:
With reference to:
http://bugs.php.net/bug.php?id=40067

I'm confused as to why this was marked bogus, and the message that
marked as such doesn't give much insight.

It would seem to me that infinite recursion within PHP is a bug.
Shouldn't the interpreter catch this sort of thing before it
coredumps?  Or is the design philosophy for PHP different than
that?

If anyone can point me to a online explanation for this or other
resource, I'd be happy to read up a bit.  More than happy to understand
why I'm wrong, but right now I feel as if this problem is getting the
brush-off.
Getting the interpreter to catch infinite recursion would be bad (imo).

It can actually come in handy if you handle it properly:

while (true) {
   ... do stuff
   if ($conditions_are_met) {
     break;
   }
}

Determining infinite recursion pre-emptively is too much work. But it
should be able to catch too much recursion causing memory exhaustion.

True.. my point was more that just finding & disabling infinite recursion would be a bad decision, but of course that's just my opinion :)

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
>> Bill Moran wrote:
>>> With reference to:
>>> http://bugs.php.net/bug.php?id=40067
>>>
>>> I'm confused as to why this was marked bogus, and the message that
>>> marked as such doesn't give much insight.
>>>
>>> It would seem to me that infinite recursion within PHP is a bug.
>>> Shouldn't the interpreter catch this sort of thing before it
>>> coredumps?  Or is the design philosophy for PHP different than
>>> that?
>> the way I understand it is that there is no decent way for the engine to
>> tell the difference between a piece of recursive code that will complete
>> and a piece of recursive code that will never complete ... so the only
>> sane solution is to leave it up to user land code to make sure the recursive
>> loop is not infinite.
>>
>> put another way if the engine catches/stops what it *thinks* is an infinite 
>> loop
>> then how would stopping the loop at an arbitrary location be any better
>> than dumping core?
> 
> Ummm, on many systems you end up with a core dump with the following
> name: core.<pid>. Now multiply that by 1000 at 16 to 32 megs a piece.
> Not fun :)

core dump files are only generated in debug builds I thought. I may well be
completely wrong though :-)

> 
> Anyways, the core dump happens because memory is exhausted and the
> engine is unable to allocate anymore. It should be possible for PHP to
> exit gracefully upon finding itself out of memory... Possibly it could
> allocate another 1k and write to the error logfile on which line it was
> running when it ran out of memory. 

that does sound sane.

> Or better yet, maybe a
> debug_backtrace() output *drool*.

wouldn't the backtrace be massive, leaving you with the same problem as
indicated by your point regarding the core dump files?


> 
> Cheers,
> Rob.

--- End Message ---
--- Begin Message ---
On Tue, 2007-01-09 at 01:11 +0100, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
> >> Bill Moran wrote:
> >>> With reference to:
> >>> http://bugs.php.net/bug.php?id=40067
> >>>
> >>> I'm confused as to why this was marked bogus, and the message that
> >>> marked as such doesn't give much insight.
> >>>
> >>> It would seem to me that infinite recursion within PHP is a bug.
> >>> Shouldn't the interpreter catch this sort of thing before it
> >>> coredumps?  Or is the design philosophy for PHP different than
> >>> that?
> >> the way I understand it is that there is no decent way for the engine to
> >> tell the difference between a piece of recursive code that will complete
> >> and a piece of recursive code that will never complete ... so the only
> >> sane solution is to leave it up to user land code to make sure the 
> >> recursive
> >> loop is not infinite.
> >>
> >> put another way if the engine catches/stops what it *thinks* is an 
> >> infinite loop
> >> then how would stopping the loop at an arbitrary location be any better
> >> than dumping core?
> > 
> > Ummm, on many systems you end up with a core dump with the following
> > name: core.<pid>. Now multiply that by 1000 at 16 to 32 megs a piece.
> > Not fun :)
> 
> core dump files are only generated in debug builds I thought. I may well be
> completely wrong though :-)

It is configurable, but often forgotten :)

> > Anyways, the core dump happens because memory is exhausted and the
> > engine is unable to allocate anymore. It should be possible for PHP to
> > exit gracefully upon finding itself out of memory... Possibly it could
> > allocate another 1k and write to the error logfile on which line it was
> > running when it ran out of memory. 
> 
> that does sound sane.
> 
> > Or better yet, maybe a
> > debug_backtrace() output *drool*.
> 
> wouldn't the backtrace be massive, leaving you with the same problem as
> indicated by your point regarding the core dump files?

Good point... maybe just the last 10 to 20 calls... Quite likely the
recursion will be seen then :) Admittedly, one can usually grab the same
info from the core dump.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
New to php.

I  took over a web site where everything is written in javascript and 
renders on the browser level.  One of the pages is a weekly announcements 
page that takes an hour to update by hand, copying in the text, then 
escaping all the "'s etc., then adding the <br> tags for carriage 
return/line feeds.

Is there a php funtion or object that does this automatically??  If so, 
which and where??

Thank you.

--j 

--- End Message ---
--- Begin Message ---
Jade Tippett wrote:
> New to php.
> 
> I  took over a web site where everything is written in javascript and 
> renders on the browser level.  One of the pages is a weekly announcements 
> page that takes an hour to update by hand, copying in the text, then 
> escaping all the "'s etc., then adding the <br> tags for carriage 
> return/line feeds.
> 
> Is there a php funtion or object that does this automatically??  If so, 
> which and where??

it'll take more than one function, and how you incorporate these
functions in to your site and/or workflow is another question.

some examples (assume that the variable $string contains the relevant text):

// escaping single quotes (I dont think you want to be doing this)
$string = str_replace("'", "\\'", $string);

        see: http://php.net/str_replace

// turning relevant characters into their html entity equivelants.
$string = htmlentities($string, ENT_QUOTES);

        see: http://php.net/htmlentities

// turning linebreaks in <br> tags,
$string = nl2br($string);

        see: http://php.net/nl2br

the description of your problem suggests that, in the first instance,
you need to find a text editor you like and learn to use it's
text replacement functionality - this is a skill that will make the
work you describe *much* faster and will stand you in good stead when
writing code as well.

if you have more specific questions about integrating php into
what seems to currently be static pages (in terms of what the
webserver is serving) send some actual code (not too much or people
will struggle to wade through it), that always helps people to
help you.

and remember the manual is your friend - most phper's will atest to
how good the php manual for learning php, even when starting from stratch.

> 
> Thank you.
> 
> --j 
> 

--- End Message ---
--- Begin Message ---
Hi List

I am working owards completing a rather urgent project for one of our clients.
There is a requirement to send a request to a server and I now have that working
using cURL, thanks to help from this list. I now have the responses coming back
as an XML response. What I need to do is to parse the XML response and break it
up into either an array or variables so I can pass the returned responses back
to a calling process.

I have spent most of last night and today looking at XML parsing and now am
totally confused. Some testing I have done suggests that SimpleXML is not the
way to go however I am open to suggestions if it might be an answer. I would
appreciate any help or advice on how to parse this XML response and break it up
into either an array or individual variables.

I have included a sample response from the server below. A few points to be
aware of,

1) In the fares section there could be any number of fares however each fare
will have a fareID and then the fareBases child.
2) In the tarifs section there could be any number of tarifs however each tarif
will have a tarifId and then 1 or more fareXrefs.
3) In the vcrSummary section there could be 1 or more vcr entries
4) The response comes back as one long string and I have formatted this to make
it a little easier to read.

<?xml version="1.0" encoding="UTF-8"?>
<?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
<fareResponse cntTarifs="122" offset="0">
  <fares>
        <fare fareId="11429927" fareType="PUB" checked="false" class="V" 
depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false" 
avail="false">
                <fareBases>
                        <fareBase pax="ADT">VLOX2</fareBase>
                        <fareBase pax="CHD">VLOX2</fareBase>
                        <fareBase pax="INF">VLOX2</fareBase>
                </fareBases>
        </fare>
        <fare fareId="11429924" fareType="PUB" checked="false" class="M" 
depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false" 
avail="false">
                <fareBases>
                        <fareBase pax="ADT">MLOW2</fareBase>
                        <fareBase pax="CHD">MLOW2</fareBase>
                        <fareBase pax="INF">MLOW2</fareBase>
                </fareBases>
        </fare>
  </fares>
  <tarifs currency="USD">
        <tarif tarifId="11429927" adtBuy="675.07" adtSell="675.07" 
chdBuy="675.07" chdSell="675.07" infBuy="675.07" infSell="675.07" 
topCar="false" topHotel="false">
                <fareXRefs>
                        <fareXRef>11429927</fareXRef>
                </fareXRefs>
        </tarif>
        <tarif tarifId="11429926" adtBuy="714.83" adtSell="714.83" 
chdBuy="714.83" chdSell="714.83" infBuy="714.83" infSell="714.83" 
topCar="false" topHotel="false">
                <fareXRefs>
                        <fareXRef>11429926</fareXRef>
                </fareXRefs>
        </tarif>
  </tarifs>
  <taxes currency="USD">
        <tax vcr="OS">201.52</tax>
  </taxes>
  <vcrSummary>
        <vcr minPrice="1667" maxPrice="1667" totalTarifs="1" 
currency="USD">AA</vcr>
        <vcr minPrice="1374" maxPrice="4704" totalTarifs="2" 
currency="USD">PR</vcr>
  </vcrSummary>
</fareResponse>

  
I would certainly appreciate any help I can get. Thanks in advance.

Regards,
Richard Luckhurst                      
Product Development
Exodus Systems - Sydney, Australia.
[EMAIL PROTECTED]

--- End Message ---

Reply via email to