[PHP] Problem with IE 6.0

2008-06-25 Thread juanmanuel . vilela

Hello and thanks in advance,

I have a problem with the cache in Internet Explorer version 6.0

When I put these lines in the page

header ("Expires: Mon, 1 Jan 1997 01:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");

Internet explorer stills make the cache to the page, is there any  
solution to these problem and how is it?


Thanks and regards


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



RE: [PHP] Re: exec() Error

2008-06-25 Thread Wei, Alice J.
Hi, Shawn and all:

   I tried to run the script using the method you suggested for Windows, but it 
gives me this:

   'http' is not recognized as an internal or external command, operable 
program or batch file.

I could telnet and ping to the server using #80 to where the script 
calculate.php is located, though. Do you or anyone else on the list might tell 
me why I cannot execute the script through this method?

  Here is my  calculate.php, if it is of any help to you for troubleshooting:

http://www.mysite.com/lung.txt";;
$handle = fopen("lung.txt", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
$count = count(explode(" ", $contents));
echo "There are " . $count. " words in " . $file . "";
?>

Thanks in advance.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Shawn McKenzie [EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 10:43 PM
To: php-general@lists.php.net
Subject: [PHP] Re: exec() Error

Wei, Alice J. wrote:
> Hi,
>
> I have got a task from my client asking me to build something that 
> allows the variables in the PHP file passed to another PHP file or a file in 
> a different computer language to perform some operations on another remote 
> machine. According to my client, he calls this behind the scenes to avoid 
> users screw up the front end, and I am hoping that I can produce one single 
> script, and have it execute some script without the user pushing any button. 
> Has anyone tried using exec() successfully in PHP to execute files from PHP 
> or other programming languages? For example, C, Python, or Perl.
>
> I have tried this by putting in
>
>   exec("http://www.mysite.com/calculate.php";);
>
>This is the error I got:
>
>  Warning: exec() [function.exec]: Unable to fork 
> [http://www.mysite.com/calculate.php] in C:\Inetpub\wwwroot\read.php on line 
> 31
>
>I have checked my permissions, and I have set it to 755.
>Does anyone know how I might be able to correct this error?
>
> Thanks in advance.
>
> Alice
> ==
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]

Well, whatever OS you use, try typing that at the command line and see
if it works.  That's what exec does in effect.

Linux:
$ http://www.mysite.com/calculate.php

Windows:
C:\> http://www.mysite.com/calculate.php

-Shawn

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

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



RE: [PHP] Re: exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 9:02 AM
> To: Shawn McKenzie; php-general@lists.php.net
> Subject: RE: [PHP] Re: exec() Error
> 
> Hi, Shawn and all:
> 
>I tried to run the script using the method you suggested for
> Windows, but it gives me this:
> 
>'http' is not recognized as an internal or external command,
> operable program or batch file.
> 
> I could telnet and ping to the server using #80 to where the
script
> calculate.php is located, though. Do you or anyone else on the list
> might tell me why I cannot execute the script through this method?
> 
>   Here is my  calculate.php, if it is of any help to you for
> troubleshooting:
> 
>  // For PHP 5 and up
> $file="http://www.mysite.com/lung.txt";;
> $handle = fopen("lung.txt", "rb");
> $contents = stream_get_contents($handle);
> fclose($handle);
> $count = count(explode(" ", $contents));
> echo "There are " . $count. " words in " . $file .
> "";
> ?>

Alice,

exec() is for executing binary commands over an interface that your
operating system inherently understands, such as its own file system. I
seriously doubt either machine in question is equipped to handle URLs
from the command line without invoking a web browser.

As I said before, you should investigate cURL or AJAX to push the info
to your remote script, and then use exec() from the remote machine to
execute the client's program which is, as I understand it, housed on the
remote script's machine.


Todd Boyd
Web Programmer




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



RE: [PHP] Re: exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 9:10 AM
> To: Wei, Alice J.
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Re: exec() Error
> 
> > -Original Message-
> > From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 25, 2008 9:02 AM
> > To: Shawn McKenzie; php-general@lists.php.net
> > Subject: RE: [PHP] Re: exec() Error
> >
> > Hi, Shawn and all:
> >
> >I tried to run the script using the method you suggested for
> > Windows, but it gives me this:
> >
> >'http' is not recognized as an internal or external command,
> > operable program or batch file.
> >
> > I could telnet and ping to the server using #80 to where the
> script
> > calculate.php is located, though. Do you or anyone else on the list
> > might tell me why I cannot execute the script through this method?
> >
> >   Here is my  calculate.php, if it is of any help to you for
> > troubleshooting:
> >
> >  > // For PHP 5 and up
> > $file="http://www.mysite.com/lung.txt";;
> > $handle = fopen("lung.txt", "rb");
> > $contents = stream_get_contents($handle);
> > fclose($handle);
> > $count = count(explode(" ", $contents));
> > echo "There are " . $count. " words in " . $file .
> > "";
> > ?>
> 
> Alice,
> 
> exec() is for executing binary commands over an interface that your
> operating system inherently understands, such as its own file system.
I
> seriously doubt either machine in question is equipped to handle URLs
> from the command line without invoking a web browser.
> 
> As I said before, you should investigate cURL or AJAX to push the info
> to your remote script, and then use exec() from the remote machine to
> execute the client's program which is, as I understand it, housed on
> the
> remote script's machine.

http://www.mysite.com/script.php?param=value');
curl_exec($curl_handle);
curl_close($curl_handle);
?>

-



HTH,


Todd Boyd
Web Programmer

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



RE: [PHP] Problem with IE 6.0

2008-06-25 Thread Edward Kay
> I have a problem with the cache in Internet Explorer version 6.0
>
> When I put these lines in the page
>
> header ("Expires: Mon, 1 Jan 1997 01:00:00 GMT");
> header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header ("Cache-Control: no-cache, must-revalidate");
> header ("Pragma: no-cache");
>
> Internet explorer stills make the cache to the page, is there any
> solution to these problem and how is it?

These are the headers I send when I want to prevent any caching:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0");
header("Pragma: no-cache");

These work fine for me in all browsers.

HTH,
Edward


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



[PHP] How to check if $string contains Hebrew characters?

2008-06-25 Thread Nitsan Bin-Nun
Hi,
I have a $string and i want to know if it contains Hebrew characters in it,
I wrote the following:


> function containHebrewChars ($string)
> {
> $chars = "אבגדהוזחטיכלמנסעפצקרשת"; // ABC of hebrew chars (AlefBet)
> $chars =
> preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
> convert it to UTF8
> if (preg_match("/[".$chars."]/", $string)) return true;
> return false;
> }
>

I'm pretty sure there is a better way to do this (regex is overkill), any
ideas?

Regards,
Nitsan


RE: [PHP] How to check if $string contains Hebrew characters?

2008-06-25 Thread Will Fitch

If your goal is to eventually convert Hebrew chars to something else, you could 
just use str_replace or stri_replace and have each Hebrew char as an array 
element, replaced by another array element as a match.

Example in English:

str_replace(array('a','b','c'),array('t','u','v'),$string);

This will replace all instances of a,b and c with t, u, and v respectively. 
This removes the regex resource.


-Original Message-
From: Nitsan Bin-Nun [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 25, 2008 10:33 AM
To: php php
Subject: [PHP] How to check if $string contains Hebrew characters?

Hi,
I have a $string and i want to know if it contains Hebrew characters in it,
I wrote the following:


> function containHebrewChars ($string)
> {
> $chars = "אבגדהוזחטיכלמנסעפצקרשת"; // ABC of hebrew chars (AlefBet)
> $chars =
> preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
> convert it to UTF8
> if (preg_match("/[".$chars."]/", $string)) return true;
> return false;
> }
>

I'm pretty sure there is a better way to do this (regex is overkill), any
ideas?

Regards,
Nitsan


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



Re: [PHP] How to check if $string contains Hebrew characters?

2008-06-25 Thread M. Sokolewicz

or do the same but with strtr()

Will Fitch wrote:

If your goal is to eventually convert Hebrew chars to something else, you could 
just use str_replace or stri_replace and have each Hebrew char as an array 
element, replaced by another array element as a match.

Example in English:

str_replace(array('a','b','c'),array('t','u','v'),$string);

This will replace all instances of a,b and c with t, u, and v respectively. 
This removes the regex resource.


-Original Message-
From: Nitsan Bin-Nun [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 25, 2008 10:33 AM

To: php php
Subject: [PHP] How to check if $string contains Hebrew characters?

Hi,
I have a $string and i want to know if it contains Hebrew characters in it,
I wrote the following:



function containHebrewChars ($string)
{
$chars = "אבגדהוזחטיכלמנסעפצקרשת"; // ABC of hebrew chars (AlefBet)
$chars =
preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
convert it to UTF8
if (preg_match("/[".$chars."]/", $string)) return true;
return false;
}



I'm pretty sure there is a better way to do this (regex is overkill), any
ideas?

Regards,
Nitsan




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



RE: [PHP] How to check if $string contains Hebrew characters?

2008-06-25 Thread Will Fitch
The strtr will be better as he's not looking to actually replace the 
characters.  

Looping through each character and running strtr will work, but you should run 
a timer on both the regex and strstr.  See which is faster.

-Original Message-
From: M. Sokolewicz [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 25, 2008 12:46 PM
To: Will Fitch
Cc: 'Nitsan Bin-Nun'; PHP - General list
Subject: Re: [PHP] How to check if $string contains Hebrew characters?

or do the same but with strtr()

Will Fitch wrote:
> If your goal is to eventually convert Hebrew chars to something else, you 
> could just use str_replace or stri_replace and have each Hebrew char as an 
> array element, replaced by another array element as a match.
> 
> Example in English:
> 
> str_replace(array('a','b','c'),array('t','u','v'),$string);
> 
> This will replace all instances of a,b and c with t, u, and v respectively. 
> This removes the regex resource.
> 
> 
> -Original Message-
> From: Nitsan Bin-Nun [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 25, 2008 10:33 AM
> To: php php
> Subject: [PHP] How to check if $string contains Hebrew characters?
> 
> Hi,
> I have a $string and i want to know if it contains Hebrew characters in it,
> I wrote the following:
> 
> 
>> function containHebrewChars ($string)
>> {
>> $chars = "אבגדהוזחטיכלמנסעפצקרשת"; // ABC of hebrew chars (AlefBet)
>> $chars =
>> preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
>> convert it to UTF8
>> if (preg_match("/[".$chars."]/", $string)) return true;
>> return false;
>> }
>>
> 
> I'm pretty sure there is a better way to do this (regex is overkill), any
> ideas?
> 
> Regards,
> Nitsan
> 


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



[PHP] Re: How to check if $string contains Hebrew characters?

2008-06-25 Thread Al

PEAR Text_LanguageDetect

Nitsan Bin-Nun wrote:

Hi,
I have a $string and i want to know if it contains Hebrew characters in it,
I wrote the following:



function containHebrewChars ($string)
{
$chars = "×�×‘×’×“×”×•×–×—×˜×™×›×œ×ž× ×¡×¢×¤×¦×§×¨×©×ª"; // ABC of hebrew chars 
(AlefBet)
$chars =
preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
convert it to UTF8
if (preg_match("/[".$chars."]/", $string)) return true;
return false;
}



I'm pretty sure there is a better way to do this (regex is overkill), any
ideas?

Regards,
Nitsan


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



RE: [PHP] Re: exec() Error

2008-06-25 Thread Wei, Alice J.
Thanks, Todd.
I will be starting to use cURL based on your explanations.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 10:10 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: RE: [PHP] Re: exec() Error

> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 9:02 AM
> To: Shawn McKenzie; php-general@lists.php.net
> Subject: RE: [PHP] Re: exec() Error
>
> Hi, Shawn and all:
>
>I tried to run the script using the method you suggested for
> Windows, but it gives me this:
>
>'http' is not recognized as an internal or external command,
> operable program or batch file.
>
> I could telnet and ping to the server using #80 to where the
script
> calculate.php is located, though. Do you or anyone else on the list
> might tell me why I cannot execute the script through this method?
>
>   Here is my  calculate.php, if it is of any help to you for
> troubleshooting:
>
>  // For PHP 5 and up
> $file="http://www.mysite.com/lung.txt";;
> $handle = fopen("lung.txt", "rb");
> $contents = stream_get_contents($handle);
> fclose($handle);
> $count = count(explode(" ", $contents));
> echo "There are " . $count. " words in " . $file .
> "";
> ?>

Alice,

exec() is for executing binary commands over an interface that your
operating system inherently understands, such as its own file system. I
seriously doubt either machine in question is equipped to handle URLs
from the command line without invoking a web browser.

As I said before, you should investigate cURL or AJAX to push the info
to your remote script, and then use exec() from the remote machine to
execute the client's program which is, as I understand it, housed on the
remote script's machine.


Todd Boyd
Web Programmer




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



Re: [PHP] exec() Error

2008-06-25 Thread Per Jessen
Wei, Alice J. wrote:

> I have got a task from my client asking me to build something
> that allows the variables in the PHP file passed to another
> PHP file or a file in a different computer language to perform
> some operations on another remote machine. According to my
> client, he calls this behind the scenes to avoid users screw
> up the front end, and I am hoping that I can produce one
> single script, and have it execute some script without the
> user pushing any button. Has anyone tried using exec()
> successfully in PHP to execute files from PHP or other
> programming languages? For example, C, Python, or Perl.

Yeah, that's no big deal.  That's what exec() does. 

> I have tried this by putting in
> 
> exec("http://www.mysite.com/calculate.php";);

Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
this instead: 

exec("php /calculate.php");


/Per Jessen, Zürich


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



RE: [PHP] exec() Error

2008-06-25 Thread Wei, Alice J.
___
From: Per Jessen [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 3:47 PM
To: php-general@lists.php.net
Subject: Re: [PHP] exec() Error

Wei, Alice J. wrote:

> I have got a task from my client asking me to build something
> that allows the variables in the PHP file passed to another
> PHP file or a file in a different computer language to perform
> some operations on another remote machine. According to my
> client, he calls this behind the scenes to avoid users screw
> up the front end, and I am hoping that I can produce one
> single script, and have it execute some script without the
> user pushing any button. Has anyone tried using exec()
> successfully in PHP to execute files from PHP or other
> programming languages? For example, C, Python, or Perl.

Yeah, that's no big deal.  That's what exec() does.

> I have tried this by putting in
>
> exec("http://www.mysite.com/calculate.php";);

Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
this instead:

exec("php /calculate.php");

I just found out that using cURL in my script allows me to call script from 
machine to machine. It turned out perfectly. Thanks to all who have been 
helping me with this!

Alice

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


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



[PHP] array_diff()?

2008-06-25 Thread Thiago H. Pojda
Guys,

Perhaps I'm missing something or just trying with the wrong tools...

But the thing is, I have two arrays and want to know what values are in one
that aren't in the other.

They're very long arrays (label files for translation)



-- 
Thiago Henrique Pojda


Re: [PHP] array_diff()?

2008-06-25 Thread Wolf

Thiago H. Pojda wrote:

Guys,

Perhaps I'm missing something or just trying with the wrong tools...

But the thing is, I have two arrays and want to know what values are in one
that aren't in the other.

They're very long arrays (label files for translation)


You know, in the manual array_diff is an actual function...

http://us2.php.net/array

So, where is your code that isn't working right?

Wolf


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



[PHP] array_diff()?

2008-06-25 Thread Thiago H. Pojda
*accidentally sent*

Guys,

Perhaps I'm missing something or just trying with the wrong tools...

But the thing is, I have two arrays and want to know what values are in one
that aren't in the other.

They're very long arrays (label files for translation) and the array_diff()
is returning null, even if I force a difference.

What's up?



-- 
Thiago Henrique Pojda

-- 
Thiago Henrique Pojda


RE: [PHP] array_diff()?

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Thiago H. Pojda [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 3:10 PM
> To: php-general@lists.php.net
> Subject: [PHP] array_diff()?
> 
> *accidentally sent*
> 
> Guys,
> 
> Perhaps I'm missing something or just trying with the wrong tools...
> 
> But the thing is, I have two arrays and want to know what values are
in
> one
> that aren't in the other.
> 
> They're very long arrays (label files for translation) and the
> array_diff()
> is returning null, even if I force a difference.
> 
> What's up?
> 
>  $file1 = 'label_es.ini';
> $file2 = 'label_pt.ini';
> 
> $fh1 = fopen ($file1,'r');
> $fh2 = fopen ($file2,'r');
> 
> $file1 = array();
> $file2 = array();
> 
> while (($line = fgets($fh1))) {
> $label = explode("=",$line);
> $array1[] = $label[0];
> }
> 
> while (($line = fgets($fh2))) {
>   $label = explode("=",$line);
>   $array2[] = $label[0];
> }
> 
> 
> $missingLabels= array_diff($array1,$array2);
> 
> 
> var_dump($labelsFaltantes); // returns nothing
> var_dump($array1); // returns a lot of stuff
> var_dump($array2); // returns a lot of stuff
> ?>

Umm...

Is $missingLabels supposed to be what you're var_dump()ing later in the
code? Cuz you call it $labelsFaltantes almost immediately after, which
has not been defined (by what I can see).


Todd Boyd
Web Programmer

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



Re: [PHP] array_diff()?

2008-06-25 Thread Daniel Brown
On Wed, Jun 25, 2008 at 4:08 PM, Wolf <[EMAIL PROTECTED]> wrote:
>
> So, where is your code that isn't working right?

Yeah, come on, Thiago, show code.  You know better than that!  ;-P

And by the way, I *believe* that as long as your arrays are <=
65,355 entries - while it will be slow and may time out - it should
work.  So don't necessarily worry about "very long" arrays.

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] array_diff()?

2008-06-25 Thread Thiago H. Pojda
Actually that was a miss when I was "translating" var names.

Here follows the code again, untouched this time:



File _pt has ~2300 lines while file _es has ~1700. Not a chance of them
having the same labels :)

On Wed, Jun 25, 2008 at 5:18 PM, Boyd, Todd M. <[EMAIL PROTECTED]> wrote:

> > -Original Message-
> > From: Thiago H. Pojda [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 25, 2008 3:10 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] array_diff()?
> >
> > *accidentally sent*
> >
> > Guys,
> >
> > Perhaps I'm missing something or just trying with the wrong tools...
> >
> > But the thing is, I have two arrays and want to know what values are
> in
> > one
> > that aren't in the other.
> >
> > They're very long arrays (label files for translation) and the
> > array_diff()
> > is returning null, even if I force a difference.
> >
> > What's up?
> >
> >  > $file1 = 'label_es.ini';
> > $file2 = 'label_pt.ini';
> >
> > $fh1 = fopen ($file1,'r');
> > $fh2 = fopen ($file2,'r');
> >
> > $file1 = array();
> > $file2 = array();
> >
> > while (($line = fgets($fh1))) {
> > $label = explode("=",$line);
> > $array1[] = $label[0];
> > }
> >
> > while (($line = fgets($fh2))) {
> >   $label = explode("=",$line);
> >   $array2[] = $label[0];
> > }
> >
> >
> > $missingLabels= array_diff($array1,$array2);
> >
> >
> > var_dump($labelsFaltantes); // returns nothing
> > var_dump($array1); // returns a lot of stuff
> > var_dump($array2); // returns a lot of stuff
> > ?>
>
> Umm...
>
> Is $missingLabels supposed to be what you're var_dump()ing later in the
> code? Cuz you call it $labelsFaltantes almost immediately after, which
> has not been defined (by what I can see).
>
>
> Todd Boyd
> Web Programmer
>



-- 
Thiago Henrique Pojda


Re: [PHP] array_diff()?

2008-06-25 Thread Thiago H. Pojda
I just hit tab and space at once and gmail just sent it ;)

Well, I'm not reaching that size, hehe.

Btw, PHP Version 5.2.6

On Wed, Jun 25, 2008 at 5:19 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 25, 2008 at 4:08 PM, Wolf <[EMAIL PROTECTED]> wrote:
> >
> > So, where is your code that isn't working right?
>
> Yeah, come on, Thiago, show code.  You know better than that!  ;-P
>
>And by the way, I *believe* that as long as your arrays are <=
> 65,355 entries - while it will be slow and may time out - it should
> work.  So don't necessarily worry about "very long" arrays.
>
> --
> 
> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
> $59.99/mo. with no contract!
> Dedicated servers, VPS, and hosting from $2.50/mo.
>



-- 
Thiago Henrique Pojda


RE: Re: [PHP] exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 2:48 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] exec() Error
> 
> Wei, Alice J. wrote:
> 
> > I have got a task from my client asking me to build something
> > that allows the variables in the PHP file passed to another
> > PHP file or a file in a different computer language to
> perform
> > some operations on another remote machine. According to my
> > client, he calls this behind the scenes to avoid users screw
> > up the front end, and I am hoping that I can produce one
> > single script, and have it execute some script without the
> > user pushing any button. Has anyone tried using exec()
> > successfully in PHP to execute files from PHP or other
> > programming languages? For example, C, Python, or Perl.
> 
> Yeah, that's no big deal.  That's what exec() does.
> 
> > I have tried this by putting in
> >
> > exec("http://www.mysite.com/calculate.php";);
> 
> Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
> this instead:
> 
> exec("php /calculate.php");

I still don't think this is how exec() should be used when executing remote PHP 
scripts via HTTP, since the web server is not going to give you the underlying 
code simply because you're calling the URL from PHP and not your web browser. 
User-Agent tags do not a secure connection make.

Perhaps doing a wget and directing it to /dev/null (if you're on *nix) would be 
appropriate to invoke a remote script and pass it parameters. Hell, even wget 
to standard output if you want, and use that as your "result code." It's 
basically doing what cURL does, but outside of the PHP script itself.

Anyway, I digress. My point is that exec("php http://mysite.com/script.php";) 
will fail, since it will be reading the remote script's OUTPUT, and not the 
remote script's SOURCE CODE.

HTH,


Todd Boyd
Web Programmer





Re: [PHP] array_diff()?

2008-06-25 Thread Thiago H. Pojda
Ok, forget everything... it was just a user (programmer) problem..

while in translation process, labels_es became a copy of labels_pt :P

Sorry about the noise.

PS: Hoorray: again in list _o/

On Wed, Jun 25, 2008 at 5:24 PM, Thiago H. Pojda <[EMAIL PROTECTED]>
wrote:

> I just hit tab and space at once and gmail just sent it ;)
>
> Well, I'm not reaching that size, hehe.
>
> Btw, PHP Version 5.2.6
>
>
> On Wed, Jun 25, 2008 at 5:19 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
>> On Wed, Jun 25, 2008 at 4:08 PM, Wolf <[EMAIL PROTECTED]> wrote:
>> >
>> > So, where is your code that isn't working right?
>>
>> Yeah, come on, Thiago, show code.  You know better than that!  ;-P
>>
>>And by the way, I *believe* that as long as your arrays are <=
>> 65,355 entries - while it will be slow and may time out - it should
>> work.  So don't necessarily worry about "very long" arrays.
>>
>> --
>> 
>> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
>> $59.99/mo. with no contract!
>> Dedicated servers, VPS, and hosting from $2.50/mo.
>>
>
>
>
> --
> Thiago Henrique Pojda




-- 
Thiago Henrique Pojda


RE: Re: [PHP] exec() Error

2008-06-25 Thread Wei, Alice J.

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 4:25 PM
To: Per Jessen; php-general@lists.php.net
Subject: RE:  Re: [PHP] exec() Error

> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 2:48 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] exec() Error
>
> Wei, Alice J. wrote:
>
> > I have got a task from my client asking me to build something
> > that allows the variables in the PHP file passed to another
> > PHP file or a file in a different computer language to
> perform
> > some operations on another remote machine. According to my
> > client, he calls this behind the scenes to avoid users screw
> > up the front end, and I am hoping that I can produce one
> > single script, and have it execute some script without the
> > user pushing any button. Has anyone tried using exec()
> > successfully in PHP to execute files from PHP or other
> > programming languages? For example, C, Python, or Perl.
>
> Yeah, that's no big deal.  That's what exec() does.
>
> > I have tried this by putting in
> >
> > exec("http://www.mysite.com/calculate.php";);
>
> Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
> this instead:
>
> exec("php /calculate.php");

I still don't think this is how exec() should be used when executing remote PHP 
scripts via HTTP, since the web server is not going to give you the underlying 
code simply because you're calling the URL from PHP and not your web browser. 
User-Agent tags do not a secure connection make.

Perhaps doing a wget and directing it to /dev/null (if you're on *nix) would be 
appropriate to invoke a remote script and pass it parameters. Hell, even wget 
to standard output if you want, and use that as your "result code." It's 
basically doing what cURL does, but outside of the PHP script itself.

Anyway, I digress. My point is that exec("php http://mysite.com/script.php";) 
will fail, since it will be reading the remote script's OUTPUT, and not the 
remote script's SOURCE CODE.

   I dont' know how come his code works either. I figured that exec() is not 
going to get me anywhere when I have it stored remotely.
   I am now using cURL instead of using exec(), since it is doing a lot closer 
to what I initiated. I am not sure if I should have a new thread for this, but 
I found that things start to get a little weird when I tried to do cURL with 
Perl files inside. The PHP only brings me back Perl code and not the processed 
content. Is this something I should not be doing with cURL? It seems to do 
quite a bit of powerful processing when I wrote everything in PHP and have it 
stored remotely.

Alice




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



Re: [PHP] array_diff()?

2008-06-25 Thread Daniel Brown
On Wed, Jun 25, 2008 at 4:31 PM, Thiago H. Pojda <[EMAIL PROTECTED]> wrote:
>
> PS: Hoorray: again in list _o/

Yeah, I noticed your softpartech address was closed out.

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] array_diff()?

2008-06-25 Thread Wolf



Thiago H. Pojda wrote:

Ok, forget everything... it was just a user (programmer) problem..

while in translation process, labels_es became a copy of labels_pt :P

Sorry about the noise.

PS: Hoorray: again in list _o/

On Wed, Jun 25, 2008 at 5:24 PM, Thiago H. Pojda <[EMAIL PROTECTED]>
wrote:


I just hit tab and space at once and gmail just sent it ;)

Well, I'm not reaching that size, hehe.

Btw, PHP Version 5.2.6


On Wed, Jun 25, 2008 at 5:19 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:


On Wed, Jun 25, 2008 at 4:08 PM, Wolf <[EMAIL PROTECTED]> wrote:

So, where is your code that isn't working right?

Yeah, come on, Thiago, show code.  You know better than that!  ;-P

   And by the way, I *believe* that as long as your arrays are <=
65,355 entries - while it will be slow and may time out - it should
work.  So don't necessarily worry about "very long" arrays.



See, two programmer issues fixed in one day, your work is done, go home 
now!  ;)


And we learned a new quick sending technique for gmail.  How cool is that?

Playing with it, my array_diff was working fine, but I figured I had 
something screwed up somewhere.  ;)


Welcome back!


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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 3:31 PM
> To: Boyd, Todd M.; Per Jessen; php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error

---8<--- snip

> > Well, "http://www.mysite.com/calculate.php"; is not an executable.
> Try
> > this instead:
> >
> > exec("php /calculate.php");
> 
> I still don't think this is how exec() should be used when executing
> remote PHP scripts via HTTP, since the web server is not going to give
> you the underlying code simply because you're calling the URL from PHP
> and not your web browser. User-Agent tags do not a secure connection
> make.
> 
> Perhaps doing a wget and directing it to /dev/null (if you're on *nix)
> would be appropriate to invoke a remote script and pass it parameters.
> Hell, even wget to standard output if you want, and use that as your
> "result code." It's basically doing what cURL does, but outside of the
> PHP script itself.
> 
> Anyway, I digress. My point is that exec("php
> http://mysite.com/script.php";) will fail, since it will be reading the
> remote script's OUTPUT, and not the remote script's SOURCE CODE.
> 
>I dont' know how come his code works either. I figured that exec()
> is not going to get me anywhere when I have it stored remotely.
>I am now using cURL instead of using exec(), since it is doing a
lot
> closer to what I initiated. I am not sure if I should have a new
thread
> for this, but I found that things start to get a little weird when I
> tried to do cURL with Perl files inside. The PHP only brings me back
> Perl code and not the processed content. Is this something I should
not
> be doing with cURL? It seems to do quite a bit of powerful processing
> when I wrote everything in PHP and have it stored remotely.

Alice,

If it's returning the code instead of the processed content, then it
means that the webserver which houses the Perl script is not
executing/parsing it. You should check with the administrator of the
remote webserver to see if they have a Perl module installed, and if it
is configured properly for your web app.

HTH,


Todd Boyd
Web Programmer




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



[PHP] prepared statement

2008-06-25 Thread ctx2002

Hi all:

We are use PHP PDO's Prepared statement to send SQL query to Mysql server.
According to PHP PDO doc, Prepared statement are fast for executing multiple
SQL queries with same parameters. "by using prepared statement you avoid
repeating the analyze/compile/optimize cycle"

Our application is a web application, each request will have a new Prepared
statement handler generated by PDO Lib. so prepared statement actually
slower than non-prepared statement.

I just want to know how can we cache  Prepared statement handler, So we can
re use it in later http request.

for example:

we have a query to pull out all product information from mysql db, each
query just has a different product id , all other parts are same. 
   
-- 
View this message in context: 
http://www.nabble.com/prepared-statement-tp18123270p18123270.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] PHP4 vs PHP5 Memcache compatibility issue

2008-06-25 Thread Bob Fisher
I am running a hybrid environment.

Box A: PHP 4.3.9

Box B: PHP 5.1.6

Box C: Memcached 1.2.2

When I set a key in memcache(Box C) from Box A, I am unable to read
it from Box B and vice versa.

I did not see any such issues mentioned in the PHP documentation.

Has anyone seen something similar? Does anyone know how to get over this?

Thanks,

-Bob


  

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



Re: [PHP] prepared statement

2008-06-25 Thread Chris
ctx2002 wrote:
> Hi all:
> 
> We are use PHP PDO's Prepared statement to send SQL query to Mysql server.
> According to PHP PDO doc, Prepared statement are fast for executing multiple
> SQL queries with same parameters. "by using prepared statement you avoid
> repeating the analyze/compile/optimize cycle"
> 
> Our application is a web application, each request will have a new Prepared
> statement handler generated by PDO Lib. so prepared statement actually
> slower than non-prepared statement.
> 
> I just want to know how can we cache  Prepared statement handler, So we can
> re use it in later http request.
> 
> for example:
> 
> we have a query to pull out all product information from mysql db, each
> query just has a different product id , all other parts are same. 

The query is the same.

It works out to be:

select * from products where id='X';


So you can just do something like this:

$product_query = $dbh->prepare('SELECT * from products where id=?');

$ids = array(1,2,3,4,5);

foreach ($ids as $product_id) {
  $product_query->execute(array($product_id));
  $product_details = $product_query->FetchAll();
  print_r($product_details);
}

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

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



Re: [PHP] prepared statement

2008-06-25 Thread ctx2002


I mean for each different requests/connection how can i use same prepared
statements object that was 
generated by PDO lib/mysql Server.

is Mysql server cache prepared statement plan?

for example:

client one connect to our site, and send a prepared statement  to our mysql
DB, now the DB will compile that prepared statement and save it somewhere in
Server. now client two connect to our site and send same prepared statement
except has a different ID to our DB, does PHP pdo / mysql server will re use
that compiled prepared statement or the php PDO/mysql server will  re
compile prepared statement for client 2? 

regards
-- 
View this message in context: 
http://www.nabble.com/prepared-statement-tp18123270p18124675.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] prepared statement

2008-06-25 Thread Chris
ctx2002 wrote:
> 
> I mean for each different requests/connection how can i use same prepared
> statements object that was 
> generated by PDO lib/mysql Server.

You can't.

Resources/connections are done per request and can't be shared - it's
done that way by design.

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

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



Re: [PHP] prepared statement

2008-06-25 Thread ctx2002

so only benefit for use prepared statement in Web environment is to prevent
SQL 
injection?

regards
 

chris smith-9 wrote:
> 
> ctx2002 wrote:
>> 
>> I mean for each different requests/connection how can i use same prepared
>> statements object that was 
>> generated by PDO lib/mysql Server.
> 
> You can't.
> 
> Resources/connections are done per request and can't be shared - it's
> done that way by design.
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/prepared-statement-tp18123270p18124946.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] prepared statement

2008-06-25 Thread Larry Garfield
On Wednesday 25 June 2008 8:24:06 pm ctx2002 wrote:
> so only benefit for use prepared statement in Web environment is to prevent
> SQL
> injection?
>
> regards

It's somewhat more complicated than that.  (The following is based on my own 
experiences with PDO and a conversation with PDO's original author, Wez 
Furlong.)

A normal query is taken as a single string, parsed, executed, and returned.  
End of story.  A prepared statement is taken as a template string, parsed, 
and cached.  It then has variables passed into it, almost like a function 
call.

Caching the query once tends to cost a little bit more than just executing it 
straight.  The savings come in later calls, when you skip the compilation 
step.  You save per repeated query the amount of the compilation.

As Chris said, you can't save compiled queries between requests.  However, 
they can still be a performance benefit in certain circumstances.  With MySQL 
in particular, those circumstances are weird.

First of all, MySQL's query compiler is actually pretty damned fast to start 
with, especially with the fairly simple queries that tend to predominate in 
web applications.  So if you save the cost of a repeated compilation but the 
compilation itself is already cheap, you won't really notice much 
improvement.  Databases with slower compile engines (eg, Oracle) or queries 
that are considerably more complex (lots of joins that the compiler has to 
figure out how to optimally order, for instance) will see more of a benefit.  
You'll also, of course, see more benefit on queries that are run many many 
many times, but for anything but insert queries if you're smart you're 
already designing your app to avoid repeating the same query anyway. :-)

Secondly, MySQL's native prepared statement support is somewhat braindead, as 
it bypasses the query cache entirely.  So you can have prepared statements or 
the query cache, but not both.  For that reason, you may get better 
performance by using PDO's emulated prepared statements instead.  (Check the 
manual for how to enable that.)  That way PDO will do the prepared statement 
work and MySQL will still use the query cache.  Experiment to see if this 
helps in your case.

Also remember that PDO itself adds some overhead with its database 
abstraction.  It's far less than doing the same abstraction in userspace, but 
it is there.  A straight PDO-based query will not be as fast as, say, the 
same query run directly through ext/mysqli.  However, PDO does give you all 
of the nice things PDO gives you. :-)  

In my testing while working to port Drupal from ext/mysql[i] to PDO, I have 
found that by removing all of our userspace prepared statement code and using 
PDO instead, we're getting about a wash on performance.  We're OK with that, 
however, due to the increased security and flexibility that PDO offers.

So the answer is that PDO is not going to get you a big performance boost on 
MySQL in a typical web app, but you can probably break even on performance 
overall while adding flexibility, additional features, and a nice API.

-- 
Larry Garfield
[EMAIL PROTECTED]

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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Per Jessen
Boyd, Todd M. wrote:

>> 
>> Well, "http://www.mysite.com/calculate.php"; is not an executable. 
>> Try this instead:
>> 
>> exec("php /calculate.php");
> 
> I still don't think this is how exec() should be used when executing
> remote PHP scripts via HTTP, since the web server is not going to give
> you the underlying code simply because you're calling the URL from PHP
> and not your web browser. User-Agent tags do not a secure connection
> make.

That's not what Alice asked for though.  She did mention that a remote
call would be made somewhere, but her question was:

>Has anyone tried using exec() successfully in PHP to execute files from
>PHP or other programming languages? For example, C, Python, or Perl. 

And that works just fine using exec(). 


/Per Jessen, Zürich


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