php-general Digest 24 Mar 2011 02:18:26 -0000 Issue 7240

Topics (messages 311999 through 312028):

Re: echo?
        311999 by: Jim Giner
        312000 by: Jim Giner
        312001 by: Steve Staples
        312002 by: Jim Giner
        312003 by: Jim Giner
        312004 by: Jim Giner
        312005 by: Stuart Dallas
        312006 by: Jim Giner
        312007 by: Jim Giner
        312008 by: Paul M Foster
        312027 by: David Robley

Protecting against session hijacking.
        312009 by: Paul Halliday

Upload Progress Meter
        312010 by: Floyd Resler
        312011 by: Steve Staples
        312012 by: Floyd Resler

adding objects to $SESSION with serialize()
        312013 by: Daniele Capuano
        312022 by: Donovan Brooke

help with _get error
        312014 by: Jack
        312015 by: David Harkness
        312016 by: Shane Rutter
        312024 by: Donovan Brooke

PHP hangs with empty result set
        312017 by: Curtis Maurand
        312018 by: Ashley Sheridan
        312019 by: Curtis Maurand

looking for a newsgroup for JS
        312020 by: Jim Giner
        312021 by: Jay Blanchard
        312023 by: Ken Robinson

Can I modify a MySQL object?
        312025 by: Brian Dunning
        312026 by: Brian Dunning
        312028 by: Paul M Foster

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
I am outputting to a <textarea> on an html page.  A <br> doesn't work, nor 
does \n, hence the &#13&#10.  Of course, if I don't need the & then I've 
just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and that 
didn't work either.

"Paul M Foster" <[email protected]> wrote in message 
news:[email protected]...
> On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>
>> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
>> wouldn't run.  That's why I created $j.
>
> Yes, the substitution creates a syntax error unless surrounded by
> parentheses or the like.
>
>> And just what is wrong with the old cr/lf sequence?  How would you have 
>> done
>> it?
>
> You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
> use 0x0d and 0x0a instead. If you're running this in a web context, you
> should use "<br/>" instead of CRLF. At the command line, I'm not
> familiar with running PHP on Windows. In *nix environments, it's enough
> to use "\n", just as they do in C. It might even work in Windows; I
> don't know. If not, you should be able to use "\r\n". You can also try
> the constant PHP_EOL, which is supposed to handle newlines in a
> cross-platform way.
>
> Paul
>
> -- 
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com 



--- End Message ---
--- Begin Message ---
By george - I think you've solved it!

As for my coding choice - that's the beauty of programming - everybody has a 
way of solving a problem/creating a solution.  Unless you are concerned with 
performance(which in this particular case is not a concern), there is no 
'wrong way'.
"Geoff Lane" <[email protected]> wrote in message 
news:[email protected]...
> Hi Jim,
>
> On Wednesday, March 23, 2011, 1:42:18 AM, you wrote:
>
>> ok - here's the code in question.
>> $q = 'select * from director_records ';
>> $qrslt = mysql_query($q);
>> $rows = mysql_num_rows($qrslt);
>> for ($i=0; $i<$rows; $i++)
>>     {
>>     $j = $i+1;
>>     $row = mysql_fetch_array($qrslt);
>>     echo $j.'-'.$row['userid'];
>>     if ($row['user_priv']<> "")
>>         echo ' ('.$row['user_priv'].')&#13&#10';
>>     else
>>         echo '&#13&#10';
>>     }
>
>
>> The output I get is:
>
>
>> 1-smith5
>> f-ginerjm (M)
>> g-smith8
>
>> While the alpha parts are valid, the index is only correct for the first 
>> one
>> (0) obviously.
>
>
> I couldn't understand why you're getting characters, so I thought I'd
> have a go myself. First, some DDL and DML to recreate your data:
>
>  create table director_records (userid char(16), user_priv char(8));
>  insert into director_records (userid, user_priv) values ('smith5', 
> ''),('ginerjm','M'),('smith8','');
>
> Now when I ran your code I got:
>
> 1-smith5&#13&#102-ginerjm (M)&#13&#103-smith8&#13&#10
>
> That is, all but the first result has &#10x in front of it. These are
> HTML entities that display as characters and it so happens that &#102
> is 'j' and &#103 is 'g'. Strictly, these entities should be terminated
> with a semi-colon (i.e. &#102; and &#103;), but your browser is
> 'obligingly' making sense of the 'bad formatting' and  this is why
> you're getting characters.
>
> BTW, an alternative to your for construct would be to use a while loop
> to iterate through a data table. e.g. in your case, I'd have used:
>
>  $q = 'select * from director_records ';
>  $qrslt = mysql_query($q);
>  $i = 1;
>  while ($row = mysql_fetch_array($qrslt)){
>      echo $i++ . '-' . $row['userid'];
>      if ($row['user_priv']<>""){
>          echo " (" . $row['user_priv'] . ")";
>      }
>      echo "<br>\n";
>  }
>
> HTH,
>
> -- 
> Geoff Lane
> Cornwall, UK
> [email protected]
> 



--- End Message ---
--- Begin Message ---
On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
> I am outputting to a <textarea> on an html page.  A <br> doesn't work, nor 
> does \n, hence the &#13&#10.  Of course, if I don't need the & then I've 
> just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and that 
> didn't work either.
> 
> "Paul M Foster" <[email protected]> wrote in message 
> news:[email protected]...
> > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
> >
> >> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
> >> wouldn't run.  That's why I created $j.
> >
> > Yes, the substitution creates a syntax error unless surrounded by
> > parentheses or the like.
> >
> >> And just what is wrong with the old cr/lf sequence?  How would you have 
> >> done
> >> it?
> >
> > You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
> > use 0x0d and 0x0a instead. If you're running this in a web context, you
> > should use "<br/>" instead of CRLF. At the command line, I'm not
> > familiar with running PHP on Windows. In *nix environments, it's enough
> > to use "\n", just as they do in C. It might even work in Windows; I
> > don't know. If not, you should be able to use "\r\n". You can also try
> > the constant PHP_EOL, which is supposed to handle newlines in a
> > cross-platform way.
> >
> > Paul
> >
> > -- 
> > Paul M. Foster
> > http://noferblatz.com
> > http://quillandmouse.com 
> 
> 
> 

Jim

with the \n, it does work in a textarea.   you must put the \n inside
the "", so:

$q = 'select * from director_records ';
$qrslt = mysql_query($q);
$rows = mysql_num_rows($qrslt);
for ($i = 0; $i < $rows; $i++)
{
    $row = mysql_fetch_array($qrslt);
    echo ($i + 1) .'-'. $row['userid'];
    if ($row['user_priv'] != "")
        echo ' ('. $row['user_priv'] .')';
    echo "\n";
}


give that a try



--- End Message ---
--- Begin Message ---
not the concern in this posting
"Richard Quadling" <[email protected]> wrote in message 
news:[email protected]...
On 23 March 2011 07:46, Geoff Lane <[email protected]> wrote:
> Hi Jim,
>
> On Wednesday, March 23, 2011, 1:42:18 AM, you wrote:
>
>> ok - here's the code in question.
>> $q = 'select * from director_records ';
>> $qrslt = mysql_query($q);
>> $rows = mysql_num_rows($qrslt);
>> for ($i=0; $i<$rows; $i++)
>> {
>> $j = $i+1;
>> $row = mysql_fetch_array($qrslt);
>> echo $j.'-'.$row['userid'];
>> if ($row['user_priv']<> "")
>> echo ' ('.$row['user_priv'].')&#13&#10';
>> else
>> echo '&#13&#10';
>> }
>
>
>> The output I get is:
>
>
>> 1-smith5
>> f-ginerjm (M)
>> g-smith8
>
>> While the alpha parts are valid, the index is only correct for the first 
>> one
>> (0) obviously.
>
>
> I couldn't understand why you're getting characters, so I thought I'd
> have a go myself. First, some DDL and DML to recreate your data:
>
> create table director_records (userid char(16), user_priv char(8));
> insert into director_records (userid, user_priv) values ('smith5', 
> ''),('ginerjm','M'),('smith8','');
>
> Now when I ran your code I got:
>
> 1-smith5&#13&#102-ginerjm (M)&#13&#103-smith8&#13&#10
>
> That is, all but the first result has &#10x in front of it. These are
> HTML entities that display as characters and it so happens that &#102
> is 'j' and &#103 is 'g'. Strictly, these entities should be terminated
> with a semi-colon (i.e. &#102; and &#103;), but your browser is
> 'obligingly' making sense of the 'bad formatting' and this is why
> you're getting characters.
>
> BTW, an alternative to your for construct would be to use a while loop
> to iterate through a data table. e.g. in your case, I'd have used:
>
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $i = 1;
> while ($row = mysql_fetch_array($qrslt)){
> echo $i++ . '-' . $row['userid'];
> if ($row['user_priv']<>""){
> echo " (" . $row['user_priv'] . ")";
> }
> echo "<br>\n";
> }
>
> HTH,

I use ...

while(False !== ($row = mysql_fetch_array($qrslt)){
}

just so that if I have a query with 1 cell which is 0, or '', I don't
abort the loop.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY 



--- End Message ---
--- Begin Message ---
it was as complete as need be to demonstrate my dilemma, as Richard has 
discovered above
"Frank Arensmeier" <[email protected]> wrote in message 
news:[email protected]...

23 mar 2011 kl. 02.42 skrev Jim Giner:

> ok - here's the code in question.
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $rows = mysql_num_rows($qrslt);
> for ($i=0; $i<$rows; $i++)
>    {
>    $j = $i+1;
>    $row = mysql_fetch_array($qrslt);
>    echo $j.'-'.$row['userid'];
>    if ($row['user_priv']<> "")
>        echo ' ('.$row['user_priv'].')&#13&#10';
>    else
>        echo '&#13&#10';
>    }
>
>
> The output I get is:
>
>
> 1-smith5
> f-ginerjm (M)
> g-smith8
>
> While the alpha parts are valid, the index is only correct for the first 
> one
> (0) obviously.
>
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Why not try some basic debugging strategies and see what you get?

Try:
for ($i=0; $i<$rows; $i++)
   {
   var_dump($i);
   $j = $i+1;
   $row = mysql_fetch_array($qrslt);
   echo $j.'-'.$row['userid'];
   var_dump($j);
   if ($row['user_priv']<> "")
       echo ' ('.$row['user_priv'].')&#13&#10';
   else
       echo '&#13&#10';
   }

The output you've posted, that's rendered output, right? What's the raw 
output?

By the way, the code snippet you gave us is not complete. Is there anything 
else? As Dan noticed earlier, judging from that code snippet only, there 
must be something else funky going on.

/frank




--- End Message ---
--- Begin Message ---
Very Interesting - '\n' doesn't work, but "\n" does work.
"Steve Staples" <[email protected]> wrote in message 
news:1300883645.5100.973.camel@webdev01...
> On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
>> I am outputting to a <textarea> on an html page.  A <br> doesn't work, 
>> nor
>> does \n, hence the &#13&#10.  Of course, if I don't need the & then I've
>> just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and 
>> that
>> didn't work either.
>>
>> "Paul M Foster" <[email protected]> wrote in message
>> news:[email protected]...
>> > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>> >
>> >> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
>> >> wouldn't run.  That's why I created $j.
>> >
>> > Yes, the substitution creates a syntax error unless surrounded by
>> > parentheses or the like.
>> >
>> >> And just what is wrong with the old cr/lf sequence?  How would you 
>> >> have
>> >> done
>> >> it?
>> >
>> > You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
>> > use 0x0d and 0x0a instead. If you're running this in a web context, you
>> > should use "<br/>" instead of CRLF. At the command line, I'm not
>> > familiar with running PHP on Windows. In *nix environments, it's enough
>> > to use "\n", just as they do in C. It might even work in Windows; I
>> > don't know. If not, you should be able to use "\r\n". You can also try
>> > the constant PHP_EOL, which is supposed to handle newlines in a
>> > cross-platform way.
>> >
>> > Paul
>> >
>> > -- 
>> > Paul M. Foster
>> > http://noferblatz.com
>> > http://quillandmouse.com
>>
>>
>>
>
> Jim
>
> with the \n, it does work in a textarea.   you must put the \n inside
> the "", so:
>
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $rows = mysql_num_rows($qrslt);
> for ($i = 0; $i < $rows; $i++)
> {
>    $row = mysql_fetch_array($qrslt);
>    echo ($i + 1) .'-'. $row['userid'];
>    if ($row['user_priv'] != "")
>        echo ' ('. $row['user_priv'] .')';
>    echo "\n";
> }
>
>
> give that a try
>
> 



--- End Message ---
--- Begin Message ---
 http://php.net/manual/en/language.types.string.php

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

On Wednesday, 23 March 2011 at 12:39, Jim Giner wrote: 
> Very Interesting - '\n' doesn't work, but "\n" does work.
> "Steve Staples" <[email protected]> wrote in message 
> news:1300883645.5100.973.camel@webdev01...
> > On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
> > > I am outputting to a <textarea> on an html page. A <br> doesn't work, 
> > > nor
> > > does \n, hence the &#13&#10. Of course, if I don't need the & then I've
> > > just saved two keystrokes. :) Also - I do believe I tried ($i+1) and 
> > > that
> > > didn't work either.
> > > 
> > > "Paul M Foster" <[email protected]> wrote in message
> > > news:[email protected]...
> > > > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
> > > > 
> > > > > Yes - it is J and I. I tried using $i+1 in the echo originally but it
> > > > > wouldn't run. That's why I created $j.
> > > > 
> > > > Yes, the substitution creates a syntax error unless surrounded by
> > > > parentheses or the like.
> > > > 
> > > > > And just what is wrong with the old cr/lf sequence? How would you 
> > > > > have
> > > > > done
> > > > > it?
> > > > 
> > > > You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
> > > > use 0x0d and 0x0a instead. If you're running this in a web context, you
> > > > should use "<br/>" instead of CRLF. At the command line, I'm not
> > > > familiar with running PHP on Windows. In *nix environments, it's enough
> > > > to use "\n", just as they do in C. It might even work in Windows; I
> > > > don't know. If not, you should be able to use "\r\n". You can also try
> > > > the constant PHP_EOL, which is supposed to handle newlines in a
> > > > cross-platform way.
> > > > 
> > > > Paul
> > > > 
> > > > -- 
> > > > Paul M. Foster
> > > > http://noferblatz.com
> > > > http://quillandmouse.com
> > 
> > Jim
> > 
> > with the \n, it does work in a textarea. you must put the \n inside
> > the "", so:
> > 
> > $q = 'select * from director_records ';
> > $qrslt = mysql_query($q);
> > $rows = mysql_num_rows($qrslt);
> > for ($i = 0; $i < $rows; $i++)
> > {
> >  $row = mysql_fetch_array($qrslt);
> >  echo ($i + 1) .'-'. $row['userid'];
> >  if ($row['user_priv'] != "")
> >  echo ' ('. $row['user_priv'] .')';
> >  echo "\n";
> > }
> > 
> > 
> > give that a try
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
As Richard proved my problem was caused by my use of the archaic cr/lf 
character pair.  Once I found the correct syntax for using \n my output of 
the loop counter worked.

thanks for all the suggestions.  My first experience on a PHP newsgroup and 
it was a postiive one.  I've spent the last 12+ years using newsgroups for 
Paradox development and this group is *just* as supportive and 
knowledgeable.

(no jokes about using paradox for so long.  If your users can manage on a 
desktop solution, pdox can't be beaten for what it could/can do.) 



--- End Message ---
--- Begin Message ---
Thanks for the pointer.  Had not run across that tidbit before.
"Stuart Dallas" <[email protected]> wrote in message 
news:[email protected]...
> http://php.net/manual/en/language.types.string.php
>
> -Stuart
>
> -- 
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>
> On Wednesday, 23 March 2011 at 12:39, Jim Giner wrote:
>> Very Interesting - '\n' doesn't work, but "\n" does work.
>> "Steve Staples" <[email protected]> wrote in message
>> news:1300883645.5100.973.camel@webdev01...
>> > On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
>> > > I am outputting to a <textarea> on an html page. A <br> doesn't work,
>> > > nor
>> > > does \n, hence the &#13&#10. Of course, if I don't need the & then 
>> > > I've
>> > > just saved two keystrokes. :) Also - I do believe I tried ($i+1) and
>> > > that
>> > > didn't work either.
>> > >
>> > > "Paul M Foster" <[email protected]> wrote in message
>> > > news:[email protected]...
>> > > > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>> > > >
>> > > > > Yes - it is J and I. I tried using $i+1 in the echo originally 
>> > > > > but it
>> > > > > wouldn't run. That's why I created $j.
>> > > >
>> > > > Yes, the substitution creates a syntax error unless surrounded by
>> > > > parentheses or the like.
>> > > >
>> > > > > And just what is wrong with the old cr/lf sequence? How would you
>> > > > > have
>> > > > > done
>> > > > > it?
>> > > >
>> > > > You're using HTML-encoded entities for 0x0d and 0x0a. You can 
>> > > > simply
>> > > > use 0x0d and 0x0a instead. If you're running this in a web context, 
>> > > > you
>> > > > should use "<br/>" instead of CRLF. At the command line, I'm not
>> > > > familiar with running PHP on Windows. In *nix environments, it's 
>> > > > enough
>> > > > to use "\n", just as they do in C. It might even work in Windows; I
>> > > > don't know. If not, you should be able to use "\r\n". You can also 
>> > > > try
>> > > > the constant PHP_EOL, which is supposed to handle newlines in a
>> > > > cross-platform way.
>> > > >
>> > > > Paul
>> > > >
>> > > > -- 
>> > > > Paul M. Foster
>> > > > http://noferblatz.com
>> > > > http://quillandmouse.com
>> >
>> > Jim
>> >
>> > with the \n, it does work in a textarea. you must put the \n inside
>> > the "", so:
>> >
>> > $q = 'select * from director_records ';
>> > $qrslt = mysql_query($q);
>> > $rows = mysql_num_rows($qrslt);
>> > for ($i = 0; $i < $rows; $i++)
>> > {
>> >  $row = mysql_fetch_array($qrslt);
>> >  echo ($i + 1) .'-'. $row['userid'];
>> >  if ($row['user_priv'] != "")
>> >  echo ' ('. $row['user_priv'] .')';
>> >  echo "\n";
>> > }
>> >
>> >
>> > give that a try
>>
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> 



--- End Message ---
--- Begin Message ---
On Wed, Mar 23, 2011 at 07:46:03AM +0000, Geoff Lane wrote:

> Hi Jim,
> 
> On Wednesday, March 23, 2011, 1:42:18 AM, you wrote:
> 
> > ok - here's the code in question.
> > $q = 'select * from director_records ';
> > $qrslt = mysql_query($q);
> > $rows = mysql_num_rows($qrslt);
> > for ($i=0; $i<$rows; $i++)
> >     {
> >     $j = $i+1;
> >     $row = mysql_fetch_array($qrslt);
> >     echo $j.'-'.$row['userid'];
> >     if ($row['user_priv']<> "")
> >         echo ' ('.$row['user_priv'].')&#13&#10';
> >     else
> >         echo '&#13&#10';
> >     }
> 
> 
> > The output I get is:
> 
> 
> > 1-smith5
> > f-ginerjm (M)
> > g-smith8
> 
> > While the alpha parts are valid, the index is only correct for the first 
> > one 
> > (0) obviously.
> 
> 
> I couldn't understand why you're getting characters, so I thought I'd
> have a go myself. First, some DDL and DML to recreate your data:
> 
>   create table director_records (userid char(16), user_priv char(8));
>   insert into director_records (userid, user_priv) values ('smith5', 
> ''),('ginerjm','M'),('smith8','');
> 
> Now when I ran your code I got:
> 
> 1-smith5&#13&#102-ginerjm (M)&#13&#103-smith8&#13&#10
> 
> That is, all but the first result has &#10x in front of it. These are
> HTML entities that display as characters and it so happens that &#102
> is 'j' and &#103 is 'g'. Strictly, these entities should be terminated
> with a semi-colon (i.e. &#102; and &#103;), but your browser is
> 'obligingly' making sense of the 'bad formatting' and  this is why
> you're getting characters.
> 
> BTW, an alternative to your for construct would be to use a while loop
> to iterate through a data table. e.g. in your case, I'd have used:
> 
>   $q = 'select * from director_records ';
>   $qrslt = mysql_query($q);
>   $i = 1;
>   while ($row = mysql_fetch_array($qrslt)){
>       echo $i++ . '-' . $row['userid'];
>       if ($row['user_priv']<>""){
>           echo " (" . $row['user_priv'] . ")";
>       }
>       echo "<br>\n";
>   }
> 
> HTH,

*Brilliant* catch. Well done.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--- End Message ---
--- Begin Message ---
Jim Giner wrote:

> I am outputting to a <textarea> on an html page.  A <br> doesn't work, nor
> does \n, hence the &#13&#10.  Of course, if I don't need the & then I've
> just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and
> that didn't work either.
> 
> "Paul M Foster" <[email protected]> wrote in message
> news:[email protected]...
>> On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>>
>>> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
>>> wouldn't run.  That's why I created $j.
>>
>> Yes, the substitution creates a syntax error unless surrounded by
>> parentheses or the like.
>>
>>> And just what is wrong with the old cr/lf sequence?  How would you have
>>> done
>>> it?
>>
>> You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
>> use 0x0d and 0x0a instead. If you're running this in a web context, you
>> should use "<br/>" instead of CRLF. At the command line, I'm not
>> familiar with running PHP on Windows. In *nix environments, it's enough
>> to use "\n", just as they do in C. It might even work in Windows; I
>> don't know. If not, you should be able to use "\r\n". You can also try
>> the constant PHP_EOL, which is supposed to handle newlines in a
>> cross-platform way.
>>
>> Paul
>>
>> --
>> Paul M. Foster
>> http://noferblatz.com
>> http://quillandmouse.com

It's possibly worth reinforcing at this stage of the game that &#13 and &#10
are incorrectly formed strings to represent CR and LF, in that they should
have a closing semicolon to delimit the end of the entity. I think this was
pointed out elsewhere but I believe it deserves repeating.


Cheers
-- 
David Robley

Sumo Wrestling: survival of the fattest.
Today is Pungenday, the 10th day of Discord in the YOLD 3177. 


--- End Message ---
--- Begin Message ---
I am not sure I am doing this right,

I have login.php which does:

$ua = $_SERVER['HTTP_USER_AGENT'];
$ua .= rand(0,4200);
$ua = md5($ua);

and upon successful auth, I push them to the main program:

header ("Location: squert.php?id=$ua");

at the beginning of squert.php I have:

if(!isset($_SESSION['sUser']))  { sKill(); }  else { $sUser  =
$_SESSION['sUser'];}
if(!isset($_SESSION['sEmail'])) { sKill(); }  else { $sEmail =
$_SESSION['sEmail'];}
if(!isset($_SESSION['sType']))  { sKill(); }  else { $sType  =
$_SESSION['sType'];}
if(!isset($_SESSION['sTime']))  { sKill(); }  else { $sTime  =
$_SESSION['sTime'];}
if(!isset($_REQUEST['id']))     { sKill(); }  else { $id     = $_REQUEST['id'];}

sKill just does session unset|destroy and redirects to login.php.

Is this right? I am not sure that the id part is.

Thanks.

--- End Message ---
--- Begin Message ---
I am in need of an upload progress meter.  I've seen plenty of tutorials =
on-line requiring installing modules, hooks, patches, etc.  However, my =
Wordpress install accomplished this without me having to make any =
modifications to my PHP install.  So, how is it done?

Thanks!
Floyd

--- End Message ---
--- Begin Message ---
On Wed, 2011-03-23 at 09:59 -0400, Floyd Resler wrote:
> I am in need of an upload progress meter.  I've seen plenty of tutorials =
> on-line requiring installing modules, hooks, patches, etc.  However, my =
> Wordpress install accomplished this without me having to make any =
> modifications to my PHP install.  So, how is it done?
> 
> Thanks!
> Floyd
> 

you can google this...

"jquery upload progress meter"

or:
http://www.nixboxdesigns.com/demos/jquery-uploadprogress.php

http://www.bitrepository.com/uploading-files-with-progress-bar.html



Steve


--- End Message ---
--- Begin Message ---
On Mar 23, 2011, at 10:10 AM, Steve Staples wrote:

> On Wed, 2011-03-23 at 09:59 -0400, Floyd Resler wrote:
>> I am in need of an upload progress meter.  I've seen plenty of tutorials =
>> on-line requiring installing modules, hooks, patches, etc.  However, my =
>> Wordpress install accomplished this without me having to make any =
>> modifications to my PHP install.  So, how is it done?
>> 
>> Thanks!
>> Floyd
>> 
> 
> you can google this...
> 
> "jquery upload progress meter"
> 
> or:
> http://www.nixboxdesigns.com/demos/jquery-uploadprogress.php
> 
> http://www.bitrepository.com/uploading-files-with-progress-bar.html
> 
> 
> 
> Steve
> 

I'll check it out!

Thanks!
Floyd



--- End Message ---
--- Begin Message ---
Hi,
I'm developing a web application using moodle, and I'm trying to create a
PHP object tree to be used in $SESSION. Objects are defined as

class foo {
 private $module_name;
 private $sub_modules = array();
}

I have a main module (object) and I use the following function to add
serialized sub modules to such object:

public function add_sub_module(&$mod) {
   $name = $mod->get_mod_name();
   $this->sub_modules[$name] = serialize(&$mod);
}

where the get_mod_name() function simply returns the $module_name private
field. After adding a sub module to the main module, I always update the
main module in $SESSION using serialize($main_module).
Once returned to the page, i restore the main module with
unserialize($SESSION->$main_module_name), and then I call the following
function to retrieve a sub module:

public function &search_sub_module($name='') {;
       foreach($this->sub_modules as $mod_name => $mod) {
          if ($name == $mod_name) {
             return unserialize($mod);
          }

          $obj_mod_file = $mod_name.".php";
          require_once($obj_mod_file);

          $obj_mod = unserialize($mod);
          $modr =& $obj_mod->search_sub_module($name);
          if ($modr != NULL) {
              return $modr;
          }
       }
       return NULL;
}

I found that sub_modules added to the main_module->sub_modules list are
correctly retrieved, but if I add a sub module to a main_module's sub
module, it cannot be get after the main module has been serialized. What do
I mistake?
Please help.

Thanks

Daniele

--- End Message ---
--- Begin Message ---
Daniele Capuano wrote:
Hi,
I'm developing a web application using moodle, and I'm trying to create a
PHP object tree to be used in $SESSION. Objects are defined as

class foo {
  private $module_name;
  private $sub_modules = array();
}

I have a main module (object) and I use the following function to add
serialized sub modules to such object:

public function add_sub_module(&$mod) {
    $name = $mod->get_mod_name();
    $this->sub_modules[$name] = serialize(&$mod);
}

where the get_mod_name() function simply returns the $module_name private
field. After adding a sub module to the main module, I always update the
main module in $SESSION using serialize($main_module).
Once returned to the page, i restore the main module with
unserialize($SESSION->$main_module_name), and then I call the following
function to retrieve a sub module:

public function&search_sub_module($name='') {;
        foreach($this->sub_modules as $mod_name =>  $mod) {
           if ($name == $mod_name) {
              return unserialize($mod);
           }

           $obj_mod_file = $mod_name.".php";
           require_once($obj_mod_file);

           $obj_mod = unserialize($mod);
           $modr =&  $obj_mod->search_sub_module($name);
           if ($modr != NULL) {
               return $modr;
           }
        }
        return NULL;
}

I found that sub_modules added to the main_module->sub_modules list are
correctly retrieved, but if I add a sub module to a main_module's sub
module, it cannot be get after the main module has been serialized. What do
I mistake?
Please help.

Thanks

Daniele


Is '$SESSION' just a typo?.. s/b '$_SESSION'.

Donovan






--
D Brooke

--- End Message ---
--- Begin Message ---
Hello All,

 

I'm having a problem with this line of code which worked fine for years:

$l_url2 = ".".$_GET[SERVER_NAME];

 

Here is the error:

[Wed Mar 23 13:33:49 2011] [error] [client 16.139.201.61] PHP Notice:  Use
of undefined constant SERVER_NAME - assumed 'SERVER_NAME' in
/home//modules/jack.php on line 322 

 

Thanks!

J

 


--- End Message ---
--- Begin Message ---
On Wed, Mar 23, 2011 at 10:46 AM, Jack <[email protected]> wrote:

> I'm having a problem with this line of code which worked fine for years:
>
> $l_url2 = ".".$_GET[SERVER_NAME];
>

Place quotes around the key.

    $l_url2 = ".".$_GET['SERVER_NAME'];

Normally PHP treats SERVER_NAME as the name of a constant. There's a setting
that allows PHP to treat it as a string if there is no constant with that
name, but using that feature has drawbacks and is not good practice. It's
possible that your PHP was upgraded or the setting was disabled.

Either way, there is no downside to using quotes short of two keystrokes
(one if you use a good editor), and you should get used to quoting your
strings.

Peace,
David

--- End Message ---
--- Begin Message ---
On 23/03/2011 17:46, Jack wrote:
Hello All,



I'm having a problem with this line of code which worked fine for years:

$l_url2 = ".".$_GET[SERVER_NAME];



Here is the error:

[Wed Mar 23 13:33:49 2011] [error] [client 16.139.201.61] PHP Notice:  Use
of undefined constant SERVER_NAME - assumed 'SERVER_NAME' in
/home//modules/jack.php on line 322



Thanks!

J





You need to put the name of the GET data you want to read in brackets. Like so.

$_GET['SERVER_NAME'];

or

$l_url2 = ".".$_GET['SERVER_NAME'];


--- End Message ---
--- Begin Message ---
Jack wrote:
Hello All,



I'm having a problem with this line of code which worked fine for years:

$l_url2 = ".".$_GET[SERVER_NAME];



Here is the error:

[Wed Mar 23 13:33:49 2011] [error] [client 16.139.201.61] PHP Notice:  Use
of undefined constant SERVER_NAME - assumed 'SERVER_NAME' in
/home//modules/jack.php on line 322



Thanks!

J


You need to learn the differences in error reporting levels. My guess is you changed hosts recently. ;-)

Donovan




--
D Brooke

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

I've been having a problem when querying a database with php and the mysql
library  the offending code follows.  If the result is an empty
set, PHP hangs.  I've had to add code to the script to set up a max
execution time to kill the script after 30 seconds if it doesn't
complete.  This is happening on a very busy site and in the past, it
has brought the server to its knees.  The code that follows is actual
code copied and pasted from the script.  I've trie wrapping an
"if ($result_2) {...}: and "if (mysql_num_rows($result_2) >
0) { ..}" around the while loop and it's made no difference.

thanks in advance, 
Curtis


$dbhandle2 = mysql_connect($hostname, $username, $password)
 or
die("Unable to connect to MySQL");
//echo "Connected
to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("database",$dbhandle2)
  or
die("Could not select examples");

        while
($_parent !="0") {
                $result_2 =
mysql_query("SELECT catagory_parent FROM t_catagories where
catagory_ID=" .$_parent);
                $num_rows_2 =
mysql_num_rows($result_2);
                if($num_rows_2 >
"0")
                {
                        while
($row = mysql_fetch_array($result_2)) {
                             
  $_parent= $row{'catagory_parent'};
                               
$_parents[$counter] = $row{'catagory_parent'};
                      
         $counter++;
                        }
               
}
        }
        mysql_close($dbhandle2);


--- End Message ---
--- Begin Message ---
On Wed, 2011-03-23 at 15:34 -0400, Curtis Maurand wrote:
> 
> I've been having a problem when querying a database with php and the mysql
> library  the offending code follows.  If the result is an empty
> set, PHP hangs.  I've had to add code to the script to set up a max
> execution time to kill the script after 30 seconds if it doesn't
> complete.  This is happening on a very busy site and in the past, it
> has brought the server to its knees.  The code that follows is actual
> code copied and pasted from the script.  I've trie wrapping an
> "if ($result_2) {...}: and "if (mysql_num_rows($result_2) >
> 0) { ..}" around the while loop and it's made no difference.
> 
> thanks in advance, 
> Curtis
> 
> 
> $dbhandle2 = mysql_connect($hostname, $username, $password)
>  or
> die("Unable to connect to MySQL");
> //echo "Connected
> to MySQL<br>";
> 
> //select a database to work with
> $selected = mysql_select_db("database",$dbhandle2)
>   or
> die("Could not select examples");
> 
>         while
> ($_parent !="0") {
>                 $result_2 =
> mysql_query("SELECT catagory_parent FROM t_catagories where
> catagory_ID=" .$_parent);
>                 $num_rows_2 =
> mysql_num_rows($result_2);
>                 if($num_rows_2 >
> "0")
>                 {
>                         while
> ($row = mysql_fetch_array($result_2)) {
>                              
>   $_parent= $row{'catagory_parent'};
>                                
> $_parents[$counter] = $row{'catagory_parent'};
>                       
>          $counter++;
>                         }
>                
> }
>         }
>         mysql_close($dbhandle2);
> 

The only obvious thing that I can see is that you're checking if the
number of results is greater than a string, not a number. I believe PHP
automagically converts it into an integer for the comparison, but try
changing it to an actual integer and seeing if that resolves it.

There is one other time you use a zero in quotes like that, but without
seeing the rest of the code it's impossible to tell whether this would
be causing an issue. Check to see if you really do want to compare the
string value. Again, this should be automatically converted by PHP, but
there are cases where the conversion isn't what you might expect.

Lastly, I noticed you're using curly braces instead of square brackets
to reference the $row array values. Was this just a typo or your actual
code? Array elements really should be referenced by square brackets.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




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


> The only obvious thing that I can see is that you're checking
if the
> number of results is greater than a string, not a number.
I believe PHP
> automagically converts it into an integer for the
comparison, but try
> changing it to an actual integer and seeing
if that resolves it.
> 
> There is one other time you use
a zero in quotes like that, but without
> seeing the rest of the
code it's impossible to tell whether this would
> be causing an
issue. Check to see if you really do want to compare the
> string
value. Again, this should be automatically converted by PHP, but
>
there are cases where the conversion isn't what you might expect.
> 
the dropped quote was a typo.  I'm good at that.

> Lastly, I noticed you're using curly braces instead of square
brackets
> to reference the $row array values. Was this just a
typo or your actual
> code? Array elements really should be
referenced by square brackets.
> 

I made the change
from the curly braces.  I didn't actually write the code.  I'm
thinking of re-writing this code using the PEAR MDB2 libraries and
mysqli.  Would that help?

--Curtis


--- End Message ---
--- Begin Message ---
Anyone know of a working Javascript newsgroup?  I googled and tried adding 
several to my OE newsgroups but couldn't find the servers.

comp.lang.javascript
pl.lang.....
mozilla......

All of these (can't remember their names now) came up with the same error 
message.

As part of learning php, I suddenly have a need to learn some js as 
well..... 



--- End Message ---
--- Begin Message ---
[snip]
Anyone know of a working Javascript newsgroup?  I googled and tried
adding 
several to my OE newsgroups but couldn't find the servers.
[/snip]

He jQuery forum also answers JavaScript questions; forum.jquery.com

--- End Message ---
--- Begin Message ---
At 04:20 PM 3/23/2011, Jim Giner wrote:
Anyone know of a working Javascript newsgroup?  I googled and tried adding
several to my OE newsgroups but couldn't find the servers.

I frequent an on-line PHP forum at phpfreaks.com. There is a Javascript section there that seems to be quite active: http://www.phpfreaks.com/forums/index.php?board=6.0

Ken
--- End Message ---
--- Begin Message ---
Let's say I do a query:

$result = mysql_query("select * from tablename");

Is there some way I can manually update the contents of certain columns/records 
in $result? I don't want to actually update MySQL, just the results that I'm 
holding in memory for this script. Can I do it without converting it to a 
regular array?

--- End Message ---
--- Begin Message ---
I should have said "modify the contents of a MySQL resource".

On Mar 23, 2011, at 5:06 PM, Brian Dunning wrote:

> Let's say I do a query:
> 
> $result = mysql_query("select * from tablename");
> 
> Is there some way I can manually update the contents of certain 
> columns/records in $result? I don't want to actually update MySQL, just the 
> results that I'm holding in memory for this script. Can I do it without 
> converting it to a regular array?
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
On Wed, Mar 23, 2011 at 05:12:00PM -0700, Brian Dunning wrote:

> I should have said "modify the contents of a MySQL resource".
> 
> On Mar 23, 2011, at 5:06 PM, Brian Dunning wrote:
> 
> > Let's say I do a query:
> > 
> > $result = mysql_query("select * from tablename");
> > 
> > Is there some way I can manually update the contents of certain 
> > columns/records in $result? I don't want to actually update MySQL, just the 
> > results that I'm holding in memory for this script. Can I do it without 
> > converting it to a regular array?

Resources are, I believe, opaque, thus not directly modifiable (safely).

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--- End Message ---

Reply via email to