php-general Digest 9 Nov 2004 11:13:40 -0000 Issue 3102
Topics (messages 201580 through 201605):
Arrays
201580 by: Ben
201581 by: Ben
201582 by: Greg Donald
201587 by: Zareef Ahmed
201590 by: Ligaya Turmelle
201591 by: Ben
201594 by: Klaus Reimer
Re: User's language settings
201583 by: Skippy
201589 by: Zareef Ahmed
Re: upload via FTP
201584 by: raditha dissanayake
201600 by: Alessandro Rosa
201601 by: raditha dissanayake
201605 by: Alessandro Rosa
Fping problem
201585 by: mwestern.sola.com.au
201599 by: Jason Wong
Meta refresh best answer ??
201586 by: Michael Gale
201592 by: Michael Gale
201596 by: Ing. Ivo F.A.C. Fokkema
Re: Syntax Limitation - dynamic static member access
201588 by: Jake Press
Re: PHP Accelerator
201593 by: Klaus Reimer
201595 by: raditha dissanayake
201597 by: Klaus Reimer
in_array not operating as 'expected'
201598 by: Ing. Ivo F.A.C. Fokkema
201603 by: Marek Kilimajer
201604 by: Bogdan Stancescu
Re: Sub selects vs nested loop
201602 by: electroteque
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 hope this is not a stupid question, but I am learning how to work with
Arrays, and am having trouble figuring out how to move array values from
page to page and/or store in a db. Once again, I am new to arrays (and
fairly new to PHP for that matter), so please don't get too technical in
replies. Thanks so much for help.
ben
--- End Message ---
--- Begin Message ---
edit
I hope this is not a stupid question, but I am learning how to work with
Arrays, and am having trouble figuring out how to move array values [the
whole array and all of it's values] from
page to page and/or store in a db. Once again, I am new to arrays (and
fairly new to PHP for that matter), so please don't get too technical in
replies. Thanks so much for help.
ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Mon, 8 Nov 2004 16:01:16 -0700, Ben <[EMAIL PROTECTED]> wrote:
> I hope this is not a stupid question, but I am learning how to work with
> Arrays, and am having trouble figuring out how to move array values from
> page to page and/or store in a db. Once again, I am new to arrays (and
> fairly new to PHP for that matter), so please don't get too technical in
> replies. Thanks so much for help.
Where is you (broken) PHP code that you have written so far?
What is it not doing that you are expecting it to do?
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--- End Message ---
--- Begin Message ---
Hi Ben,
Welcome to the wonderful world of PHP.
Working with array in PHP is very easy. A large number of functions are
there.
Please visit the manual
http://www.phpcertification.com/manual.php/ref.array.html
You can move values ( including Arrays) from page to page in session
variables.
But you need to do serialize and unserialize in case of array or object.
Do ::
$val_ar=array("one","two","three");
$_SESSION['val_ar_store']=serialize($val_ar);
Now you can get your array in any page simply
$val_ar=unserialize($_SESSION['val_ar_store']);
Print_r($val_ar);
This process is very simple. Please see manual
http://www.phpcertification.com/manual.php/function.serialize.html
http://www.phpcertification.com/manual.php/function.unserialize.html
Revert back with any other problem.
Zareef ahmed
-----Original Message-----
From: Ben [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 09, 2004 4:31 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Arrays
I hope this is not a stupid question, but I am learning how to work with
Arrays, and am having trouble figuring out how to move array values from
page to page and/or store in a db. Once again, I am new to arrays (and
fairly new to PHP for that matter), so please don't get too technical in
replies. Thanks so much for help.
ben
------------------------------------------------------------------------
--
Zareef Ahmed :: A PHP develoepr in Delhi ( India )
Homepage :: http://www.zasaifi.com
--- End Message ---
--- Begin Message ---
There are a couple of ways to pass arrays (and their values) between
pages. I personally would put the array into a session variable
($_SESSION - see reference) and access the various parts as needed.
Another option is sending the whole array or it's parts as hidden fields
in a form (access with the $_GET and $_POST - again see reference), but
that means the user has to click a submit button.
If you are trying to store the array in a Database I would suggest you
make each element of the array into it's own column of the database.
Databases generally should only have 1 piece of information being saved
per cell (think excel). If you would like a link to database design,
let me know and I will send it.
If all you really were asking was how to iterate through an array - then
I would recommend looking at the manual's page on arrays (
http://www.php.net/manual/en/language.types.array.php ).
Respectfully,
Ligaya Turmelle
References:
http://www.php.net/language.variables.predefined
Ben wrote:
I hope this is not a stupid question, but I am learning how to work with
Arrays, and am having trouble figuring out how to move array values from
page to page and/or store in a db. Once again, I am new to arrays (and
fairly new to PHP for that matter), so please don't get too technical in
replies. Thanks so much for help.
ben
--- End Message ---
--- Begin Message ---
Thank you to all for help with this. Once I have a general idea of which
path to head down, I can figure it out pretty well from there, and you have
all given me a pretty good road map. Anyway, thanks again. It is greatly
appreciated. I'll let you know hot it all comes out.
Ben
-----Original Message-----
From: Ligaya Turmelle [mailto:[EMAIL PROTECTED]
Sent: Monday, November 08, 2004 10:03 PM
To: Ben
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Arrays
There are a couple of ways to pass arrays (and their values) between
pages. I personally would put the array into a session variable
($_SESSION - see reference) and access the various parts as needed.
Another option is sending the whole array or it's parts as hidden fields
in a form (access with the $_GET and $_POST - again see reference), but
that means the user has to click a submit button.
If you are trying to store the array in a Database I would suggest you
make each element of the array into it's own column of the database.
Databases generally should only have 1 piece of information being saved
per cell (think excel). If you would like a link to database design,
let me know and I will send it.
If all you really were asking was how to iterate through an array - then
I would recommend looking at the manual's page on arrays (
http://www.php.net/manual/en/language.types.array.php ).
Respectfully,
Ligaya Turmelle
References:
http://www.php.net/language.variables.predefined
Ben wrote:
> I hope this is not a stupid question, but I am learning how to work with
> Arrays, and am having trouble figuring out how to move array values from
> page to page and/or store in a db. Once again, I am new to arrays (and
> fairly new to PHP for that matter), so please don't get too technical in
> replies. Thanks so much for help.
>
> ben
>
--- End Message ---
--- Begin Message ---
Zareef Ahmed wrote:
But you need to do serialize and unserialize in case of array or object.
Do ::
$val_ar=array("one","two","three");
$_SESSION['val_ar_store']=serialize($val_ar);
Serialization is done automatically. You don't need to do it yourself.
You can even store simple value-objects in the session witout manual
serialization.
So you can do:
$val_ar = array("one", "two", "three");
$_SESSION['val_ar_store'] = $val_ar;
serialize/unserialize are useful if you want to store complex data in a
file or in a database.
--- End Message ---
--- Begin Message ---
On Mon, 08 Nov 2004 22:37:41 +0100 Marek Kilimajer <[EMAIL PROTECTED]>
wrote:
>> How can I determine user's primary language?
>
> $_SERVER["HTTP_ACCEPT_LANGUAGE"] - string with user's language
> preferences. However only a fraction of users willingly set it, so many
> times it will be on its default value, english even for russian speaking
> visitors.
Perhaps try to advertise it somewhere on your site, how to set it in
various browsers. People will use this once they realise the setting is
there. It's very nice to go to a website without doing anything special and
be greeted by your mother tongue. Once they experience this they will like
it.
HTTP_ACCEPT_LANGUAGE will look like this: ro,en-us;q=0.7,en;q=0.3
Comma is the main delimiter, separating languages. The "q" signifies
precedence among similar languages, such as en-us vs en. Otherwise, the
order in which the languages were given sets precedence.
--
Skippy - Romanian Web Developers - http://ROWD.ORG
--- End Message ---
--- Begin Message ---
Hi,
You may try a ip locator and then guess for users country.
IN this way you can design your programme to treat users from Russia to
Russian language etc.
Visit
http://zareef.users.phpclasses.org/browse/package/1477.html
Zareef Ahmed
-----Original Message-----
From: Daniel Schierbeck [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 09, 2004 1:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: User's language settings
Dmitri Pissarenko wrote:
> Hello!
>
> I have a web-site, part of which is in Russian and another part in
> English.
>
> English and Russian parts are located in different directories. The
> web-site is static.
>
> I want to create a PHP file, which redirects the user from /index.php
> to
> /ru/index.html, when his primary language is Russian and to
> /en/index.html, when his primary language is non-Russian.
>
> In other words:
>
> <?php
>
> if ($languageRussian)
> {
> header("Location: http://dapissarenko.com/ru/index.html");
> }
> else
> {
> header("Location: http://dapissarenko.com/en/index.html");
> }
>
> exit;
> ?>
>
> How can I determine user's primary language?
>
> Thanks!
>
> dap
I don't think it's possible. You can, however, ask the user to select
which language he wishes to see, then store that option in a cookie so
he doesn't have to do it every time he visits the site.
--
Daniel Schierbeck
Help spread Firefox (www.getfirefox.com):
http://www.spreadfirefox.com/?q=user/register&r=6584
--
------------------------------------------------------------------------
--
Zareef Ahmed :: A PHP develoepr in Delhi ( India )
Homepage :: http://www.zasaifi.com
--- End Message ---
--- Begin Message ---
Alessandro Rosa wrote:
Dear all subscribers,
I'm coding a send-mail form, also including
edit boxes keeping the path of files to be uploaded
from the remote host onto an FTP server.
Is there the possibility (and if so, which ones) to
manage FTP permissions to have a file including
the variable with ID and PSW (for FTP access)
and which is usable
by the code running on the server exclusively but
cannot be accessed by any other user?
Alessandro
Your question is not very clear. Do you mean to say you only want your
FTP server to be accessible by your php scripts? If so the trick is to
listen only on localhost and not on the public ip.
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
> Your question is not very clear. Do you mean to say you only want your
> FTP server to be accessible by your php scripts? If so the trick is to
> listen only on localhost and not on the public ip.
>
No, only some of the scripts shall be
accessible by other scripts in the FTP server.
Alessandro Rosa
--- End Message ---
--- Begin Message ---
Alessandro Rosa wrote:
Your question is not very clear. Do you mean to say you only want your
FTP server to be accessible by your php scripts? If so the trick is to
listen only on localhost and not on the public ip.
No, only some of the scripts shall be
accessible by other scripts in the FTP server.
That's even more confusing. You run php scripts off a web server and not
an FTP server.
Alessandro Rosa
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
> That's even more confusing. You run php scripts off a
> web server and not an FTP server.
Ok ... the server I'm dealing with works for both services.
But let me re-explain the question in new terms.
I have a bunch of php scripts on a web server.
I just wanted to know if it is possible to deny access
permissions for some of such scripts to a public user
but not to other scripts staying on the same server.
Alessandro Rosa
--- End Message ---
--- Begin Message ---
Hi All,
I have written a simple page that uses fping and was working perfectly just
shelling out to it using the backtick.
The server it was on crapped out and I'm trying to get it going again on our
new server. I have installed fping, given permissions to everyone to run
it and copied it to the places where it was before. /usr/local/bin /bin
/sbin
And it will not return the input I give it.
Anybody in the house got an ideas? Idiot me didn't document what I did to
get it going in the first place...
Thanks
Matthew
--- End Message ---
--- Begin Message ---
On Tuesday 09 November 2004 01:54, [EMAIL PROTECTED] wrote:
> I have written a simple page that uses fping and was working perfectly just
> shelling out to it using the backtick.
>
> The server it was on crapped out and I'm trying to get it going again on
> our new server. I have installed fping, given permissions to everyone to
> run it and copied it to the places where it was before. /usr/local/bin
> /bin /sbin
>
> And it will not return the input I give it.
And what, exactly, does that mean?
- what did you do?
- what did you expect to happen?
- what actually happened?
- any logs and error messages?
Not all of us are certified mindreaders, so some basic info would help.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Life is to you a dashing and bold adventure.
*/
--- End Message ---
--- Begin Message ---
Hello,
I am working on a site where people will be updating information in a
database and should have up to date info. Now since HTTP is stateless
the user will not know about any new information until they click on a
link or hit a button on the page.
My question is -- if I want to keep a user up to date about changes to
any information they might want to know would it be best to create a
hidden frame of some sort which does a mete-refresh to a page looking
for updates, and if found display a java popup window with a small FYI ?
If so would a meta-refresh of 3-5 seconds be to aggressive ? What about
server load ?
Is there a better way ?
Hope I was clear, thanks.
Michael.
--- End Message ---
--- Begin Message ---
Hello,
I really wanted to know if there was a better way to do this using PHP
? That is why I e-mailed the list.
Michael.
Michael Gale wrote:
Hello,
I am working on a site where people will be updating information in
a database and should have up to date info. Now since HTTP is stateless
the user will not know about any new information until they click on a
link or hit a button on the page.
My question is -- if I want to keep a user up to date about changes to
any information they might want to know would it be best to create a
hidden frame of some sort which does a mete-refresh to a page looking
for updates, and if found display a java popup window with a small FYI ?
If so would a meta-refresh of 3-5 seconds be to aggressive ? What about
server load ?
Is there a better way ?
Hope I was clear, thanks.
Michael.
--- End Message ---
--- Begin Message ---
Hi Michael,
I always use
header('Refresh: 2; url=' . $_SERVER['PHP_SELF']);
to reload the current page every 2 seconds. You may want to pass $_GET
variables, depending on your needs. Also make sure you call this function
_before_ any other output has gone to the browser.
HTH,
Ivo
On Mon, 08 Nov 2004 22:26:53 -0700, Michael Gale wrote:
> Hello,
>
> I really wanted to know if there was a better way to do this using PHP
> ? That is why I e-mailed the list.
>
>
> Michael.
>
>
>
> Michael Gale wrote:
>> Hello,
>>
>> I am working on a site where people will be updating information in
>> a database and should have up to date info. Now since HTTP is stateless
>> the user will not know about any new information until they click on a
>> link or hit a button on the page.
>>
>> My question is -- if I want to keep a user up to date about changes to
>> any information they might want to know would it be best to create a
>> hidden frame of some sort which does a mete-refresh to a page looking
>> for updates, and if found display a java popup window with a small FYI ?
>>
>> If so would a meta-refresh of 3-5 seconds be to aggressive ? What about
>> server load ?
>>
>> Is there a better way ?
>>
>> Hope I was clear, thanks.
>>
>> Michael.
>>
--- End Message ---
--- Begin Message ---
Hi all,
Just to let everyone know - I've reported this as a bug.
http://bugs.php.net/bug.php?id=30716
Fingers crossed :)
Yours Sincerely
Jake Press
--- End Message ---
--- Begin Message ---
Adrian Madrid wrote:
I've been running Turck for some time now on PHP5 and haven't had
segfault problems yet. I must say I'm running the latest CVS and using
file sessions (Turck's would give you segfaults).
I also tried latest CVS and I don't use Turcks cache. Maybe Turck has
problems with Objects in PHP5 (because there were the great changes)
while normal Non-OO-Scripts are running flawlessly.
--- End Message ---
--- Begin Message ---
Klaus Reimer wrote:
Adrian Madrid wrote:
I've been running Turck for some time now on PHP5 and haven't had
segfault problems yet. I must say I'm running the latest CVS and using
file sessions (Turck's would give you segfaults).
I also tried latest CVS and I don't use Turcks cache. Maybe Turck has
problems with Objects in PHP5 (because there were the great changes)
while normal Non-OO-Scripts are running flawlessly.
I am also running turck with php5 without too many problems and that's
why i recommended it to the OP. However none of the scripts that run on
it make use of any of the new features of php5.
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
raditha dissanayake wrote:
I am also running turck with php5 without too many problems and that's
why i recommended it to the OP. However none of the scripts that run on
it make use of any of the new features of php5.
One example: I'm using osCommerce, which is not using any new
PHP5-features (It's PHP4 software) but it is using general OO. And the
results if MMCache is enabled are very unstable. Most of the time the
HTML output is corrupted. Sometimes it segfaults. These problemse go
away if I disable MMCache. On PHP4 everything works fine with MMCache.
--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)
signature.asc
Description: OpenPGP digital signature
--- End Message ---
--- Begin Message ---
Hi guys and gals,
I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:
var_dump(in_array('test', array(0)));
What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs
Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :
var_dump('test' == 0);
also returns bool(true). But my logic tells me, that if 'test' == 0, then :
if (0) {
...
}
should do the same as
if ('test') {
...
}
but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?
Thanks for your thoughts.
Ivo Fokkema
--- End Message ---
--- Begin Message ---
Ing. Ivo F.A.C. Fokkema wrote:
Hi guys and gals,
I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:
var_dump(in_array('test', array(0)));
What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs
Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :
var_dump('test' == 0);
'test' and 0 are not of the same type (string vs int), so string is
converted to int, 0. In the examples below no type casting is needed.
also returns bool(true). But my logic tells me, that if 'test' == 0, then :
if (0) {
...
}
should do the same as
if ('test') {
...
}
but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?
Thanks for your thoughts.
Ivo Fokkema
--- End Message ---
--- Begin Message ---
Apart from Marek's reply, you should probably check the in_array()
documentation (look at the third, optional parameter) and search for
type casting on php.net.
Cheers,
Bogdan
Ing. Ivo F.A.C. Fokkema wrote:
Hi guys and gals,
I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:
var_dump(in_array('test', array(0)));
What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs
Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :
var_dump('test' == 0);
also returns bool(true). But my logic tells me, that if 'test' == 0, then :
if (0) {
...
}
should do the same as
if ('test') {
...
}
but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?
Thanks for your thoughts.
Ivo Fokkema
--- End Message ---
--- Begin Message ---
Hi guys and girls, while we are on this topic, has anyone got a good
senario of a sub select query which can remove the nested loops ? I
have been wanting to get rid of nested loops for a good while and now
Mysql 4.1 is out I would like to start using it. So the usual scenario
for nested loops to to get data out of a 1 to many relationship. Please
put me on the right path, I had asked the Mysql list but no success.
Daniel
On 09/11/2004, at 5:45 AM, Greg Donald wrote:
On Mon, 08 Nov 2004 21:57:41 +0600, raditha dissanayake
<[EMAIL PROTECTED]> wrote:
Sorry no benchmarks, i am talking from personal experience where I
converted some code from a php nested loop to mysql. I was rather
surprised by the results. I will concede that I may not have optimized
the query properly or that I may not have had the correct indexes, but
since I have been doing this for quite a few years i like to think i
got
the query right. (feel free to deflate my ego :-) )
Well yeah.. It's hard to believe a well written MySQL sub select query
with proper indexing would be slower than looping through the results
with PHP scripting.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---