php-general Digest 18 Jan 2008 08:34:18 -0000 Issue 5242

Topics (messages 267507 through 267531):

Re: Count
        267507 by: Mike Smith

Re: SMTP vs mail()
        267508 by: Richard Lynch
        267514 by: Manuel Lemos

Re: New years resolution: To get serious with my programming! Anyone wanna 
help? :)
        267509 by: Richard Lynch
        267511 by: Daniel Brown

Re: PHP array entries max limit
        267510 by: Richard Lynch

Re: snmp_set_valueretrieval depends on what?
        267512 by: Richard Lynch

Re: system command runs application, but application doesn't work correctly
        267513 by: Richard Lynch
        267521 by: Apple7777

Re: Function-return-array idea
        267515 by: Eric Butera
        267516 by: Nathan Nobbe
        267522 by: Jim Lucas

Foreach
        267517 by: Pastor Steve
        267518 by: Nathan Nobbe
        267519 by: Eric Butera
        267520 by: mike
        267525 by: David Giragosian
        267526 by: Jim Lucas
        267527 by: Nathan Nobbe

A stupid question?
        267523 by: Shelley Shyan
        267524 by: Jim Lucas
        267528 by: David Wonderly

Looks like a bug with Smarty
        267529 by: GoWtHaM NaRiSiPaLli
        267530 by: clive

Re: Encryption failing
        267531 by: Zoltán Németh

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 ---
Steve,

Check out the while loop
(http://us.php.net/manual/en/control-structures.while.php). It'll do
what you need.

--
Mike

--- End Message ---
--- Begin Message ---
On Thu, January 17, 2008 3:50 am, Richard Heyes wrote:
>> You can easily make a mail queue in php yourself with a daemon that
>> checks the queue and sends waiting mail in batches of say 200 per
>> minute. (provided you have access to the cli on the server)
>
> Why when there MTAs?

Your shared host may provide no access to config an MTA, but will shut
you down automatically if you send either more then 75 emails per
minute, or more than 1000 per hour.

I worked on such a setup, and crafted a PHP DB queue of emails to make
100% sure their mailing list never got their site shut down.

I am confident other examples abound.

-- 
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?

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

on 01/17/2008 06:57 PM Richard Lynch said the following:
> On Thu, January 17, 2008 3:50 am, Richard Heyes wrote:
>>> You can easily make a mail queue in php yourself with a daemon that
>>> checks the queue and sends waiting mail in batches of say 200 per
>>> minute. (provided you have access to the cli on the server)
>> Why when there MTAs?
> 
> Your shared host may provide no access to config an MTA, but will shut
> you down automatically if you send either more then 75 emails per
> minute, or more than 1000 per hour.
> 
> I worked on such a setup, and crafted a PHP DB queue of emails to make
> 100% sure their mailing list never got their site shut down.
> 
> I am confident other examples abound.

You are right. After all that is an "MTA" too. It is an awkward solution
but tt least you will be able work around your ISP constraints.

Some time ago an user published a class that does precisely that:

http://www.phpclasses.org/newsletter


In the past, I used also an unsual solution to send newsletters to the
PHPClasses site users.

Instead of a database, I used to send e-mail messages that contained
newsletter contents and subscriber addresses.

Then I used my desktop machine to pop the messages and distribute the
newsletters. When it exceeded my ISP limits, I used servers borrowed
from kind users, until I finally used a VPS.

The distribution system via e-mail still exists and works as a charm,
although for now it is not needed to work distributedly.

In this blog post you can read all the details.

http://www.phpclasses.org/blog/post/65-8-defensive-programming-best-practices-to-prevent-breaking-your-sites.html

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
On Thu, January 17, 2008 2:06 am, Jochem Maas wrote:
> Richard Lynch schreef:
>> On Wed, January 16, 2008 9:57 am, Daniel Brown wrote:
>>> echo($h."\n".$i."\n"); // echo is a construct, but as expected, can
>>> use parentheses()
>>
>> Just to be picuyane:
>>
>> echo isn't using the parens.
>>
>> The parens are forcing PHP to evaluate the concatenation of the
>> strings FIRST, and then echo them.
>>
>> And since the concatenation operator takes precedence over the
>> language construct, the parens are basically useless cruft.
>
> not to mention that it should be written as (spaces are optional ;-)):
>
> echo $h, "\n", $i, "\n";
>
> which avoids any concat operation and dumps the result of each
> expression
> direct to the buffer :-)

I wanted to avoid the whole concat versus multi-arg performance
thread, since it usually takes about a week before somebody posts the
definitive answer, showing the actual PHP opcodes generated...

And I don't recall the answer, and don't give a [bleep] since it's
almost never the bottleneck in an application in the first place...

-- 
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?

--- End Message ---
--- Begin Message ---
On Jan 17, 2008 4:01 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> And I don't recall the answer, and don't give a [bleep] since it's
> almost never the bottleneck in an application in the first place...

    You swore.  I'm tellin' Mom.

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].

--- End Message ---
--- Begin Message ---
On Wed, January 16, 2008 11:02 pm, Prabath Kumarasinghe wrote:
> I would like to know how many entries does PHP associative array can
> handle.

As far as I know, the answer is:

How much RAM do you have?

-- 
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?

--- End Message ---
--- Begin Message ---
fumble-fingers!

http://lxr.php.net/

On Wed, January 16, 2008 9:18 pm, Dotan Cohen wrote:
> On 16/01/2008, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> You can check at http://xlr.php.net but I suspect that it's too
>> "new"
>> to be in your version of PHP.
>>
>> You are on 5.2.1 and php.net is offering 5.2.5, so you're just
>> enough
>> behind for this to be very plausible.
>>
>> Maybe get Ubuntu to catch up? :-)
>>
>
> Thanks, Richard. That link seems broken, are you sure that it is
> correct?
>
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-×
-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>


-- 
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?

--- End Message ---
--- Begin Message ---
Try writing a 2-line .sh (shell) script that does what you want, and
call that 2-liner from exec().

On Thu, January 17, 2008 6:46 am, Apple7777 wrote:
> Daniel Brown <parasane <at> gmail.com> writes:
>
>>     Try replacing system() with die() and letting it print out the
>> information full command string.  That may give you an idea of a
>> variable that's either incorrect or undefined.  If you copy and
>> paste
>> it and run the command from the command line and it works, then it
>> may
>> be permissions issues.
>
> Daniel,
>
> This doesn't display anything:
> die($first);
> die($second);
>
> Full commands are:
> first: /usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9
> -of lavf
> -ovc lavc -lavcopts
> vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=1
> -frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0
> -channels 1
> -srate 22050 -of lavf -lavfopts format=flv -o /home/re/video/2/16.flv
> /home/re/ff/logo7.avi /home/re/video/2/16temp
>
> second:
> /usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9 -of
> lavf -ovc
> lavc -lavcopts
> vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=1
> -frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0
> -channels 1
> -srate 22050 -of lavf -lavfopts format=flv -o /home/re/video/2/16.flv
> /home/re/ff/logo7.avi /home/re/video/2/16temp
>
>
> I've set permissions of all test files and directories to 777. But
> still my
> script doesn't work.
>
>
>
>
>>
>>     One part of the snipped content that I noticed kept repeating is
>> the following (and actually ending with this line):
>>         'VDecoder init failed :( Read DOCS/HTML/en/codecs.html'
>>
>>     Did you follow the advice and read that document?
>
> Yes. It's just describes codecs. But I know mencoder support those
> codecs,
> because it encodes videos when it's called from SSH.
>
>
>>     Beyond that, it's a question that should probably instead be
>> asked
>> on a mencoder mailing list, since PHP's system() function is working
>> correctly, but apparently isn't getting the information it needs to
>> pass stuff back-and-forth with the system.
>>
>
>
>
>
> I've already asked this question in Mencoder group, by noone replied.
>
> I thinkit's because mencoder works fine and it doesn't work only when
> I call it
> from PHP.
>
> The thing is when I copy/paste commands above to SSH, everything works
> fine.
>
> Do you have any thoughts?
>
> --
> 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?

--- End Message ---
--- Begin Message ---
Richard Lynch <ceo <at> l-i-e.com> writes:

> 
> Try writing a 2-line .sh (shell) script that does what you want, and
> call that 2-liner from exec().


Thanks for idea, Richard. But it doesn't work.

I wrote code as you said:

--------------------
$first = "/usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9 -of
lavf -ovc lavc -lavcopts
vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=1
-frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0 -channels 1
-srate 22050 -of lavf -lavfopts format=flv -o ".$outputFile."
/home/re/ff/logo7.avi ".$inputFile."\n";
$second = "/usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9 -of
lavf -ovc lavc -lavcopts
vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=2
-frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0 -channels 1
-srate 22050 -of lavf -lavfopts format=flv -o ".$outputFile."
/home/re/ff/logo7.avi ".$inputFile;

$fp = fopen("/home/re/video/enc", "w");
fwrite($fp, $first);
fwrite($fp, $second);
fclose($fp);

exec("/bin/bash /home/re/video/enc");
--------------------


I've also tried system() instead of exec(), and it displayed same output text as
I posted above.

The strangest thing is when I run this script from shell, everything works fine!
Video encodes well. But when I call that script from PHP, nothing works.

Another strange thing is I run ImageMajick with system() in a lot of scripts on
the same server and everything works fine.

What is the problem? Do you have any idea?











> 
> On Thu, January 17, 2008 6:46 am, Apple7777 wrote:
> > Daniel Brown <parasane <at> gmail.com> writes:
> >
> >>     Try replacing system() with die() and letting it print out the
> >> information full command string.  That may give you an idea of a
> >> variable that's either incorrect or undefined.  If you copy and
> >> paste
> >> it and run the command from the command line and it works, then it
> >> may
> >> be permissions issues.
> >
> > Daniel,
> >
> > This doesn't display anything:
> > die($first);
> > die($second);
> >
> > Full commands are:
> > first: /usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9
> > -of lavf
> > -ovc lavc -lavcopts
> > vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=1
> > -frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0
> > -channels 1
> > -srate 22050 -of lavf -lavfopts format=flv -o /home/re/video/2/16.flv
> > /home/re/ff/logo7.avi /home/re/video/2/16temp
> >
> > second:
> > /usr/local/bin/mencoder -vf scale=448:-3,expand=448:336 -sws 9 -of
> > lavf -ovc
> > lavc -lavcopts
> > vcodec=flv:vbitrate=250:trell:v4mv:mv0:mbd=2:cbp:aic:cmp=3:subcmp=3:vpass=1
> > -frames 800 -ofps 24000/1001 -oac mp3lame -lameopts abr:br=64:mode=0
> > -channels 1
> > -srate 22050 -of lavf -lavfopts format=flv -o /home/re/video/2/16.flv
> > /home/re/ff/logo7.avi /home/re/video/2/16temp
> >
> >
> > I've set permissions of all test files and directories to 777. But
> > still my
> > script doesn't work.
> >
> >
> >
> >
> >>
> >>     One part of the snipped content that I noticed kept repeating is
> >> the following (and actually ending with this line):
> >>         'VDecoder init failed :( Read DOCS/HTML/en/codecs.html'
> >>
> >>     Did you follow the advice and read that document?
> >
> > Yes. It's just describes codecs. But I know mencoder support those
> > codecs,
> > because it encodes videos when it's called from SSH.
> >
> >
> >>     Beyond that, it's a question that should probably instead be
> >> asked
> >> on a mencoder mailing list, since PHP's system() function is working
> >> correctly, but apparently isn't getting the information it needs to
> >> pass stuff back-and-forth with the system.
> >>
> >
> >
> >
> >
> > I've already asked this question in Mencoder group, by noone replied.
> >
> > I thinkit's because mencoder works fine and it doesn't work only when
> > I call it
> > from PHP.
> >
> > The thing is when I copy/paste commands above to SSH, everything works
> > fine.
> >
> > Do you have any thoughts?
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 

--- End Message ---
--- Begin Message ---
On Jan 16, 2008 6:32 PM, Stijn Leenknegt <[EMAIL PROTECTED]> wrote:
> Hello
>
> I've an idea for PHP6. Let's kickoff with an example.
>
> <?php
> $info = getUserInformation($id); //return an array with all the information
> of an user.
> echo $info['naam'];
> ?>
>
> This is nice, but when I want one element of the returned array, I have to
> store the returned array into a variable and then call the variable.
> The next code example is my idea.
>
> <?php
> echo getUserInformation($id)['naam'];
> ?>
>
> Let's look further then this small example.
>
> <?php
> echo $object->fetchObjects()[0]->method();
> ?>
>
> This example is more realistic when you use OO. This code style is faster
> for developing applications. This code style is available in Java,
> Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
> more on my blog.
>
> http://www.eos-team.org/2007/09/06/php6-function-return-array-idea.html
>
> I hope for good response and also response from php-dev team.
>
> Greetings
> Stijn Leenknegt
>

My reply is a bit pointless as I'd never do/rely on this.  But
nonetheless it was an interesting test.

function testObj() {
        $arr = array();
        $arr['key1'] = array(1, 2, 3);
        $arr['key3'] = array('a','b','c');
        return (object)$arr;
}

echo '<pre>';

echo "Key1: \n";
print_r(testObj()->key1);
echo "Key3: \n";
print_r(testObj()->key3);


--- output ----
Key1:
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)
Key3:
Array
(
    [0] => a
    [1] => b
    [2] => c
)

--- End Message ---
--- Begin Message ---
On Jan 16, 2008 6:32 PM, Stijn Leenknegt <[EMAIL PROTECTED]> wrote:

> Hello
>
> I've an idea for PHP6. Let's kickoff with an example.
>
> <?php
> $info = getUserInformation($id); //return an array with all the
> information
> of an user.
> echo $info['naam'];
> ?>
>
> This is nice, but when I want one element of the returned array, I have to
> store the returned array into a variable and then call the variable.
> The next code example is my idea.
>
> <?php
> echo getUserInformation($id)['naam'];
> ?>
>
> Let's look further then this small example.
>
> <?php
> echo $object->fetchObjects()[0]->method();
> ?>
>
> This example is more realistic when you use OO. This code style is faster
> for developing applications. This code style is available in Java,
> Javascript, C, C++, Perl, Python, ... So why not in PHP(6)? You can read
> more on my blog


i think this is pretty much a dup of a thread from about a week ago;
http://www.nabble.com/Why-is-some_function()-some_index--invalid-syntax--td14749459.html

-nathan

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
I think this would be an easier/quicker fix for you then requesting that the PHP developers re-write a large portion of the way PHP currently works.


Here is the reference that I have been looking for.

http://en.wikipedia.org/wiki/Message_passing

Jim

--- End Message ---
--- Begin Message ---
Here is my code:

 $name = $_POST['name'];
  if ($name) {
 foreach ($name as $t) {
     
        echo "$t";
    }
    
    $order = $_POST['order'];
    if ($order) {
    foreach ($order as $i) {
    
    
            //Update the table in MySQL
        $update_data = "UPDATE sections SET `order` = '$i' WHERE name =
'$t'";
        $response = mysql_query( $update_data, $cnx );
        if(mysql_error()) die ('database error<br>'. mysql_error());
        
        echo "$i";
    }

}

} 

I am trying to get the information in name and order to update the database.
So far, I can only get one or the other. Is there a way to do this?

Thanks for your help.

--
Steve M.

--- End Message ---
--- Begin Message ---
On Jan 17, 2008 5:49 PM, Pastor Steve <[EMAIL PROTECTED]> wrote:

> Here is my code:
>
>  $name = $_POST['name'];
>  if ($name) {
>  foreach ($name as $t) {
>
>        echo "$t";
>    }
>
>    $order = $_POST['order'];
>    if ($order) {
>    foreach ($order as $i) {
>
>
>            //Update the table in MySQL
>        $update_data = "UPDATE sections SET `order` = '$i' WHERE name =
> '$t'";
>        $response = mysql_query( $update_data, $cnx );
>        if(mysql_error()) die ('database error<br>'. mysql_error());
>
>        echo "$i";
>    }
>
> }
>
> }
>
> I am trying to get the information in name and order to update the
> database.
> So far, I can only get one or the other. Is there a way to do this?


there are a few different issues here; first of all; are you sure
$_POST['name']
and $_POST['order'] are even arrays?

-nathan

--- End Message ---
--- Begin Message ---
On Jan 17, 2008 5:57 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> there are a few different issues here; first of all; are you sure
> $_POST['name']
> and $_POST['order'] are even arrays?

To check try this right above your saving code block:

echo '<pre>';
print_r($_POST);

After you figure out if your data is right we're going to have to talk
about input validation and sql injection.

--- End Message ---
--- Begin Message ---
On 1/17/08, Nathan Nobbe <[EMAIL PROTECTED]> wrote:

> >  $name = $_POST['name'];
> >  if ($name) {
> >  foreach ($name as $t) {
> >
> >        echo "$t";
> >    }

> >    $order = $_POST['order'];
> >    if ($order) {
> >    foreach ($order as $i) {

>
> there are a few different issues here; first of all; are you sure
> $_POST['name']
> and $_POST['order'] are even arrays?

hint:

if(isset($_POST['name']) && is_array($_POST['name']))

:)

--- End Message ---
--- Begin Message ---
On 1/17/08, mike <[EMAIL PROTECTED]> wrote:

> On 1/17/08, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> > >  $name = $_POST['name'];
> > >  if ($name) {
> > >  foreach ($name as $t) {
> > >
> > >        echo "$t";
> > >    }
>
> > >    $order = $_POST['order'];
> > >    if ($order) {
> > >    foreach ($order as $i) {
>
> >
> > there are a few different issues here; first of all; are you sure
> > $_POST['name']
> > and $_POST['order'] are even arrays?
>
> hint:
>
> if(isset($_POST['name']) && is_array($_POST['name']))


Steve,

// Do you have several html form elements such as <input type="text"
name="name[]"> in your html?
// Mike's suggestion...
if( isset( $_POST['name'] ) && is_array( $_POST['name'] ) ) {

 // you'll never get in here if you don't...
 $name = $_POST['name'];

         // foreach expects an array, as Nathan states. Even if $name is an
array, $t
         // will hold only the last value in the array when the foreach loop
is exited
         // because $t is being overwritten with each iteration.
         foreach ($name as $t) {

                 echo "$t";

         } // end foreach ($name)

         $order = $_POST['order'];

         if ($order) {

                 // see above about arrays and foreach
                 foreach ($order as $i) {

                        //Update the table in MySQL

                        $i = mysql_real_escape_string($i, $cnx); // One of
Eric's suggestions

                        $update_data = "UPDATE sections SET `order` = '$i'
WHERE name = '$t'";

                        $response = mysql_query( $update_data, $cnx );

                        if(mysql_error()) die ('database error<br>'.
mysql_error());

                        echo "$i";

                 } //end foreach ($order)

         }

}

 Assuming both $_POST['name'] and $_POST['order'] are arrays, the way your
code is now structured, the table `sections` will have the record(s) where
name equals the last value in the $names array updated multiple times, once
for each value in the $order array, but all you will see is that
the record(s) will have the last value in the $order array.

See if this makes any sense and then ask more questions.

David

--- End Message ---
--- Begin Message ---
Pastor Steve wrote:
Here is my code:

 $name = $_POST['name'];
  if ($name) {
 foreach ($name as $t) {
echo "$t";
    }
$order = $_POST['order'];
    if ($order) {
    foreach ($order as $i) {
//Update the table in MySQL
        $update_data = "UPDATE sections SET `order` = '$i' WHERE name =
'$t'";
        $response = mysql_query( $update_data, $cnx );
        if(mysql_error()) die ('database error<br>'. mysql_error());
echo "$i";
    }

}

}
I am trying to get the information in name and order to update the database.
So far, I can only get one or the other. Is there a way to do this?

Thanks for your help.

--
Steve M.


Your example

http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php

My solution

http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0002.php

Notice the differences

Pay close attention to the form and see how I am nesting the fields in the input name attribute.

Jim

--- End Message ---
--- Begin Message ---
On Jan 17, 2008 11:40 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:

> Pastor Steve wrote:
> > Here is my code:
> >
> >  $name = $_POST['name'];
> >   if ($name) {
> >  foreach ($name as $t) {
> >
> >         echo "$t";
> >     }
> >
> >     $order = $_POST['order'];
> >     if ($order) {
> >     foreach ($order as $i) {
> >
> >
> >             //Update the table in MySQL
> >         $update_data = "UPDATE sections SET `order` = '$i' WHERE name =
> > '$t'";
> >         $response = mysql_query( $update_data, $cnx );
> >         if(mysql_error()) die ('database error<br>'. mysql_error());
> >
> >         echo "$i";
> >     }
> >
> > }
> >
> > }
> >
> > I am trying to get the information in name and order to update the
> database.
> > So far, I can only get one or the other. Is there a way to do this?
> >
> > Thanks for your help.
> >
> > --
> > Steve M.
> >
>
> Your example
>
>
> http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php
>
> My solution
>
>
> http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0002.php
>
> Notice the differences
>
> Pay close attention to the form and see how I am nesting the fields in
> the input name attribute.


the topic of external variables, including the ability to create arrays from
outside php,
such as in GET and POST requests can be found here:
http://www.php.net/manual/en/language.variables.external.php

-nathan

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

Maybe this is a somehow stupid question.

I want to know how php could know whether session_start() has been called, that 
is, whether session has been started.

I Googled, but got little help.

Thank you for help!
Any tip is greatly appreciated.

Regards,
Shelley


--- End Message ---
--- Begin Message ---
Shelley Shyan wrote:
Hi all,

Maybe this is a somehow stupid question.

I want to know how php could know whether session_start() has been called, that 
is, whether session has been started.

I Googled, but got little help.

Thank you for help!
Any tip is greatly appreciated.

Regards,
Shelley


http://us3.php.net/session_id

is what you are looking for.

Look at the notes for the "Return Values" section

"session_id() returns the session id for the current session or the empty string ("") if there is no current session (no current session id exists)."

So, something like this will do.

<?php

$sid = session_id();
if ( $sid == '' ) {
        // No session started yet.
} else {
        // Session has been started.
}
?>

Jim

--- End Message ---
--- Begin Message ---
On Fri, 2008-01-18 at 10:54 +0800, Shelley Shyan wrote:
> Hi all,
> 
> Maybe this is a somehow stupid question.
> 
> I want to know how php could know whether session_start() has been called, 
> that is, whether session has been started.
> 
> I Googled, but got little help.
> 
> Thank you for help!
> Any tip is greatly appreciated.
> 
> Regards,
> Shelley
> 

Hey Shelley, maybe I can help you understand Sessions. When you start a
Sessions PHP creates a Session ID. This is then used to create/Store
information in a file or in a database. The configuration of this is in
your php.ini file. If this file you can change where the session is
saved as well as other options. A simple way to use Sessions is with
cookies with the session.use_cookie = 1 in the php.ini file. However, if
the client doesn't allow cookies there is a second way;
session.use_trans_sid = 0 there are a few problems however, it creates a
security risk.

Anyway, I hope this opens a little on how sessions works. If you wish to
learn more about sessions go to http://us2.php.net/session or
http://w3schools.com/php/php_sessions.asp

David Wonderly
WebGenero

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

I using html_options smarty tag to output an associative array in select
drop down.
Here a sample associative array:

array(5) {
  ["CN-PEK-KEJ"]=>
  array(1) {
    [198]=>
    string(7) "TechTst"
  }
  ["IE-DUB-GAS"]=>
  array(2) {
    [177]=>
    string(10) "store room"
    [39]=>
    string(10) "TechStop 2"
  }
  ["UK-LON-BEL"]=>
  array(1) {
    [88]=>
    string(16) "TechStop-LON-BEL"
  }
  ["IE-DUB-GOR"]=>
  array(1) {
    [159]=>
    string(10) "TechStop 1"
  }
  ["US-NYC-9TH"]=>
  array(1) {
    [194]=>
    string(12) "TestTechStop"
  }
}


and the syntax I have used to output this was:
{html_options name='locationId' options=$locations
selected=$selectedLocation}
where in I assign $selectedLocation with one of the options after selecting
them.

Even after everything being right, the option thats been selected is not set
but it again goes back to show the first option after submit.

Looks like either smarty misinterprets this selected option or is there
something wrong from my end.

Cheers
-- 
Mark is on the way to make a Mark in your hearts

--- End Message ---
--- Begin Message ---
if  ($question == 'php')
   domail('phplist',$question);

if  ($question == 'smarty')
   domail('smartylist',$question);


Hi All,

I using html_options smarty tag to output an associative array in select
drop down.
Here a sample associative array:

array(5) {
  ["CN-PEK-KEJ"]=>
  array(1) {
    [198]=>
    string(7) "TechTst"
  }
  ["IE-DUB-GAS"]=>
  array(2) {
    [177]=>
    string(10) "store room"
    [39]=>
    string(10) "TechStop 2"
  }
  ["UK-LON-BEL"]=>
  array(1) {
    [88]=>
    string(16) "TechStop-LON-BEL"
  }
  ["IE-DUB-GOR"]=>
  array(1) {
    [159]=>
    string(10) "TechStop 1"
  }
  ["US-NYC-9TH"]=>
  array(1) {
    [194]=>
    string(12) "TestTechStop"
  }
}


and the syntax I have used to output this was:
{html_options name='locationId' options=$locations
selected=$selectedLocation}
where in I assign $selectedLocation with one of the options after selecting
them.

Even after everything being right, the option thats been selected is not set
but it again goes back to show the first option after submit.

Looks like either smarty misinterprets this selected option or is there
something wrong from my end.

Cheers

--- End Message ---
--- Begin Message ---
2008. 01. 17, csütörtök keltezéssel 12.14-kor Ken Kixmoeller -- reply to
[EMAIL PROTECTED] ezt írta:
> (forgot to copy the list)
> 
> On Jan 16, 2008, at 5:08 PM, Richard Lynch wrote:
> 
> 
> > Is it possible that 4% of the time, you have spaces on the start/end
> > of the string, which get trimmed before encryption?
> >
> 
> In this case, no. In trying to simplify the situation to narrow the  
> possibilities of error, I am generating "random" character strings of  
> only alphanumeric (or numeric-only) characters. Each is exactly 16  
> characters.
> 
> 
> 
> > And if rijndael is one of the algorithms which requires a fixed-size
> > input, that also would be "bad" to trim it.
> >
> 
> No documentation that I was able to find suggests that requirement.
> 
> 
> 
> 
> > Actually, I'd suggest that the encryption function has no business
> > trimming the text anyway.
> >
> 
> Philosophically I agree with you, but mCrypt has this nasty habit of  
> appending bunches of nulls to the decrypted string. So philosophical  
> purity gives way to practical application.


yeah, I just ran into the same thing yesterday evening with mcrypt and
rijndael_256.
encrypting went fine, decrypted string had a lot of nulls at the end. so
I too had to use trim() on it.

greets
Zoltán Németh

> 
> Good ideas, as usual. Thank you.
> 
> Ken
> 
> 

--- End Message ---

Reply via email to