OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 8 Jun 2006 18:33:10 -0000 Issue 4174

php-general-digest-helplists.php.net
Date: Thu Jun 08 2006 - 13:33:10 CDT


php-general Digest 8 Jun 2006 18:33:10 -0000 Issue 4174

Topics (messages 237589 through 237644):

Re: Pear Pager
        237589 by: Chris

Re: php sessions and Google
        237590 by: Anthony Ettinger

Re: file from database work local, but not on server
        237591 by: Peter Lauri
        237606 by: Jef Sullivan
        237616 by: tedd
        237640 by: Peter Lauri
        237641 by: tedd

Re: File downloads
        237592 by: kartikay malhotra
        237610 by: tedd

Re: php java intregration
        237593 by: Vedanta Barooah

Restrict uploaded scripts
        237594 by: Mathias Bundgaard Svesson
        237599 by: Chris

Gzinflate on a string that has been base_64 encoded in Windows
        237595 by: Venky

popup window from php page
        237596 by: William Stokes
        237598 by: Rabin Vincent
        237601 by: Mindaugas L
        237602 by: Andrei

XPath avg(), min(), max() functions not found
        237597 by: Alex
        237609 by: Rob Richards

Running Scripts from the Command Line in Linux
        237600 by: OOzy Pal
        237603 by: Dave Goodchild
        237604 by: Rabin Vincent
        237605 by: Brad Bonkoski
        237643 by: Venky

Re: php sessions and Google (Solved)
        237607 by: tedd

Passing variables.
        237608 by: William Stokes
        237612 by: Brad Bonkoski
        237625 by: Barry
        237634 by: tedd

Re: pop-up window in php???
        237611 by: Michelle Konzack

running php method in the background
        237613 by: Nic Appleby
        237628 by: Ben Ramsey
        237631 by: Adam Zey

server sending notifications to clients
        237614 by: kartikay malhotra
        237615 by: Brad Bonkoski
        237617 by: Angelo Zanetti
        237618 by: Jay Blanchard
        237619 by: Jim Moseby
        237621 by: Barry
        237632 by: Adam Zey
        237636 by: kartikay malhotra
        237638 by: Adam Zey

order of elements in $_POST super global
        237620 by: Ben Liu
        237622 by: Dave Goodchild
        237623 by: Barry
        237624 by: Barry
        237626 by: Ben Liu
        237627 by: Ben Liu
        237629 by: Ben Liu
        237633 by: Ron Clark
        237635 by: João Cândido de Souza Neto
        237637 by: Ben Liu
        237639 by: Ben Liu
        237642 by: Ben Liu

Re: file( ) function
        237630 by: Adam Zey

reset a resource?
        237644 by: sam

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


weetat wrote:
> Hi all ,
>
> Thanks all in this newsgroup for your help.
>
> I have question regarding PEAR Pager .

http://pear.php.net/support/lists.php

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

attached mail follows:


On 6/7/06, tedd <teddsperling.com> wrote:
> Can someone shed some light on this for me? How can one do sessions and make Google bots happy?

I think what they're getting at is don't use session id's unless
they're logged in.

--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

attached mail follows:


Thank you for pointing out the security issue, I am aware of that. Was
sloppy not to use %d instead of %s as I did.

The database is exactly the same, and the data is correct in
$Row['filename']. I did create a copy and put it onto an other server, and
there it worked "ok". Some files did work well, while others did not work at
all.

Is there anyone with reference of a small example of binary storage and
retrieval from database? I have performed working solutions for images
before, but this should support any file extensions (with exceptions of
course).

Best regards,
Peter Lauri

-----Original Message-----
From: Chris [mailto:dmagickgmail.com]
Sent: Thursday, June 08, 2006 8:00 AM
To: Peter Lauri
Cc: php-generallists.php.net
Subject: Re: [PHP] file from database work local, but not on server

Peter Lauri wrote:
> Best group member,
>
> This code works fine on my local machine:
>
> $Query = sprintf("SELECT * FROM filestorage WHERE id=%s LIMIT 1",
> $_GET['fileid']);
> $Result = mysql_query($Query);
> if (mysql_num_rows ($Result)>0) {
> $Row = mysql_fetch_array ($Result);
> $file_type = $Row["filetype"];
> $file = $Row["filedata"];
> header ("Content-type: $file_type");
> header("Content-Disposition: attachment;
> filename=fil".substr($Row['filename'], strrpos($Row['filename'], '.')));
> '.')).'"
> print $file;
> }
>
> But when I run it on my server it does not start the download, and the
file
> name is the location of the script instead of what I state as file name.

The first thing you should do is read this site:

http://www.phpsec.org

I could pass all sorts of bad things to $_GET['fileid'] and it will ruin
your database.

At least make it:

(int)$_GET['fileid'];

so if it's non-numeric, it will get converted to 0.

Can we assume the database is exactly the same and it's not that
$row['filename'] has the wrong data in it?

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

attached mail follows:


What happens when you print out the query to the page?
Is the query correct?

Jef

-----Original Message-----
From: Peter Lauri [mailto:listsdwsasia.com]
Sent: Wednesday, June 07, 2006 1:10 PM
To: php-generallists.php.net
Subject: [PHP] file from database work local, but not on server

Best group member,

This code works fine on my local machine:

$Query = sprintf("SELECT * FROM filestorage WHERE id=%s LIMIT 1",
$_GET['fileid']);
$Result = mysql_query($Query);
if (mysql_num_rows ($Result)>0) {
  $Row = mysql_fetch_array ($Result);
  $file_type = $Row["filetype"];
  $file = $Row["filedata"];
  header ("Content-type: $file_type");
  header("Content-Disposition: attachment;
filename=fil".substr($Row['filename'], strrpos($Row['filename'], '.')));
'.')).'"
  print $file;
}

But when I run it on my server it does not start the download, and the
file
name is the location of the script instead of what I state as file name.

Is this a server issue? I run Linux server with Plesk. Is there anyone
with
the same problems?

Best regards,
Peter Lauri

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

attached mail follows:


At 9:03 AM +0700 6/8/06, Peter Lauri wrote:

>Is there anyone with reference of a small example of binary storage and
>retrieval from database? I have performed working solutions for images
>before, but this should support any file extensions (with exceptions of
>course).

Peter:

Storage and retrieval of an image in a dB is the same as any other data *.

The problem I imagine you are having is how to prepare the data for insertion into the dB and how to display the data after you pull it back out.

To prepare for insertion, try this:

$image = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));

(I have magic_quotes set to OFF -- if you have it ON, remove the addslashes().)

To prepare the image file for display after retrieval, try this:

ob_start();

... your dB retrieval code

$fileContent = mysql_result($result, 0, "image");

$image = imagecreatefromstring($fileContent);

imagejpeg($image, null, 100);

ob_end_flush();

---
hth's

tedd

*<please gang -- no holy war about storing images in a dB>
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Hi Tedd,

Thank you for your answer. I have it working for images already, the problem
comes to Excel, PDF's etc. I will do some more testing using your sample,
thanks.

/Peter

-----Original Message-----
From: tedd [mailto:teddsperling.com]
Sent: Thursday, June 08, 2006 9:29 PM
To: Peter Lauri; 'Chris'
Cc: php-generallists.php.net
Subject: RE: [PHP] file from database work local, but not on server

At 9:03 AM +0700 6/8/06, Peter Lauri wrote:

>Is there anyone with reference of a small example of binary storage and
>retrieval from database? I have performed working solutions for images
>before, but this should support any file extensions (with exceptions of
>course).

Peter:

Storage and retrieval of an image in a dB is the same as any other data *.

The problem I imagine you are having is how to prepare the data for
insertion into the dB and how to display the data after you pull it back
out.

To prepare for insertion, try this:

$image = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));

(I have magic_quotes set to OFF -- if you have it ON, remove the
addslashes().)

To prepare the image file for display after retrieval, try this:

ob_start();

... your dB retrieval code

$fileContent = mysql_result($result, 0, "image");

$image = imagecreatefromstring($fileContent);

imagejpeg($image, null, 100);

ob_end_flush();

---
hth's

tedd

*<please gang -- no holy war about storing images in a dB>
--
----------------------------------------------------------------------------
--------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


At 6:22 PM +0700 6/8/06, Peter Lauri wrote:
>Hi Tedd,
>
>Thank you for your answer. I have it working for images already, the problem
>comes to Excel, PDF's etc. I will do some more testing using your sample,
>thanks.
>
>/Peter

Peter:

Excel and PDF's are different critters. I'm sure there are people on this list that can help. Just change the subject line and ask.

tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Thanks to Tedd, Barry, George and others for help over "download file"
problem.

I'm going to receive an ACK if the file downloads correctly. In absence of
such an ACK, a script would quitely remove the temporary files after a fixed
interval of time. Temporary files have unique filenames.

New problem:
Is there a way for the server to notify the client that a new file has
become available for download, provided the client was online in the past X
minutes?

This could be done if

1. The client queries the server after a set interval of time. I DO NOT WANT
THIS FOR SOME SILLY REASON.

2. The connection is kept alive (?). With my current knowledge of PHP, I am
not able to manage this.
Cookies or sessions? Can't find a related example directly dealing with this
issue.

All wild ideas/links/examples are welcome.

What changes would be required in Apache conf file (if any)?

Thanks & Regards
KM

On 6/7/06, tedd <teddsperling.com> wrote:
>
> At 8:42 AM +0000 6/7/06, kartikay malhotra wrote:
> >Dear All,
> >
> >I have a HTTP server + MySQL database. Everytime a file is requested for
> >download, my PHP script loads the content from the database into a
> temporary
> >file (on the server). I then pass a URL to the client, with a link to
> this
> >file. The client can thus download the file at any time.
> >
> >However, I can foresee many problems with this approach. One is, when to
> >delete the temporary file? Also with more than one client, this approach
> >would have to be refined. Security is also an issue: One user may read
> >another's files.
> >
> >Can anyone kindly give me an alternative approach?
> >
> >I reiterate, I cannot supply static URLs as the downloadable file is
> >generated on-demand.
> >
> >Thanks & Regards
> >KM
>
> KM:
>
> Thinking off the top of my head (not always the best for me) -- why not
> give the user a static url AND a key?
>
> The static url would have a php program sitting there waiting for a user
> to come along and provide the correct key. After which, your program would
> then create the file (in a random named folder); provide the user with a
> link; and clean-up after he's done.
>
> That way you have the control over what's happening. The key approach
> handles security and when to clean-up.
>
> hth's
>
> tedd
> --
>
> ------------------------------------------------------------------------------------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


At 7:47 AM +0000 6/8/06, kartikay malhotra wrote:
>New problem:
>Is there a way for the server to notify the client that a new file has
>become available for download, provided the client was online in the past X
>minutes?
>
>This could be done...

kartikay:

First, it's probably best if you start a new thread for a new subject.

Second, it might be better for you to state what you would like to do rather than set the specifics of how it is to be done, understand? Simply put, why are you trying to do?

tedd

--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


hi,
i have not tried it in linux, but the stuff worked for me in windows,
here are my notes:

* PHP 5.1.4
* PECL 5.1.4 (use php_java.dll and php_java.jar from the zip file,
this is an extra download)

here is my php.ini

; configuration to enable php_java.dll
[Java]
extension=php_java.dll
java.class.path = C:\PHP\ext\php_java.jar
java.home = C:\Java\jdk1.5.0_06
java.library = C:\Java\jdk1.5.0_06\jre\bin\server\jvm.dll
java.library.path = C:\PHP\ext

you will need to append more paths to java.class.path directive if you
use any extra jars in you application. the extension works fine except
its kinda slow on my server - i am yet to find out why... let me know
if its any better for you.

thanks,
vedanta

On 6/8/06, Lalit Khairnar <lalit.khairnarin.v2solutions.com> wrote:
> Hi Vedanta
>
> We re also trying to use Bridge for the same.
> but we are stucked while configuring the .jar file on WINDOWS
> could u please send us the procedure to do in perfect way
>
> We are using Xampp installer and php 5.1.1 ,apache , and jdk 1.5
>
> please reply soon
>
> --
> Lalit P.Khairnar
> V2Solutions
> A New Vision to Solution
> Cell:09969131384
> India:+91-22-56733201 Ext:642 / 643
> US:1-408-253-2838
> http://www.v2solutions.com
>
>
>

--
*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*
Vedanta Barooah
YM! - vedanta2006
Skype - vedanta2006

attached mail follows:


Hi!
I'm trying to create a CMS where it should be posible to upload script
modules. Those modules should mostly be made by myself, but it is
posible for others to create scripts too. My question is, is it posible
to restrict the modules to their own directory so they don't overwrite
some of the other modules or the CMS itself?
The php scripts should prefeable be used through require or similar, not
by a direct web request to the script.

Mathias Bundgaard Svensson

attached mail follows:


On 6/8/06, Mathias Bundgaard Svesson <freakenfreaken.dk> wrote:
> Hi!
> I'm trying to create a CMS where it should be posible to upload script
> modules. Those modules should mostly be made by myself, but it is
> posible for others to create scripts too. My question is, is it posible
> to restrict the modules to their own directory so they don't overwrite
> some of the other modules or the CMS itself?

Restrict them to do what exactly?

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

attached mail follows:


Greetings!

I have a long piece of string that is apparently a PNG image which has been
base_64 decoded in an XML file. I can retreive this string without problem.
The string is in $mystra

$pngdata = base64_decode($mystra);
$pngdata = gzinflate($pngdata);

When i try to gzinflate it , i get a warning that says "data error" and if i
write pngdata to a binary file using fopen, there is 0 bytes (because of the
warning).

If i just write the base_64 decoded data to a binary file, then I can't open
the file as a gziped file. (it is not a valid gzip'ed file)

From the person who sent me the XML file, what I was told

the base_64 decoded data will give me the deflated binary array for the
image, which I would need to inflate using an InflaterInputStream, and as a
result, I will get the PNG file that is represented in $mystra.

I probably need to add some PNG headers to it and/or explode the base_64
decoded data and then add headers to it.

I am getting quite lost here. Can anyone provide some hints please?

Regards

Venky

attached mail follows:


Hello,

How do I open a popup window from php code when a web page is loaded? Does
it require javascript usage?

Thanks
-Will

attached mail follows:


On 6/8/06, William Stokes <kallesoperamail.com> wrote:
> How do I open a popup window from php code when a web page is loaded? Does
> it require javascript usage?

Yes, this needs to be done with Javascript. Google will
help you on this.

Rabin

attached mail follows:


Yeah, just echo JavaScript, which opens popup page. Remember php is
server side language.

On 6/8/06, William Stokes <kallesoperamail.com> wrote:
> Hello,
>
> How do I open a popup window from php code when a web page is loaded? Does
> it require javascript usage?
>
> Thanks
> -Will
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Mindaugas

attached mail follows:


        What PHP does is it outputs HTML code as result. Any other
functionality regarding browser commands (such as opening popups) are
done using javascript.

        Andy

William Stokes wrote:
> Hello,
>
> How do I open a popup window from php code when a web page is loaded? Does
> it require javascript usage?
>
> Thanks
> -Will
>

attached mail follows:


Hi all. I'm trying to use XPath avg(), min() and max() functions
without success. Others functions like count() or sum() works correctly.

Here is the code I'm using (PHP 5.1):

<?php

$xml_str = '
<stats>
  <cards>
    <card name="My card">
      <type name="visits">25</type>
      <type name="clicks">7</type>
    </card>
    <card name="My other card">
      <type name="visits">50</type>
      <type name="clicks">3</type>
    </card>
  </cards>
</stats>
';

$xml_doc = new DOMDocument();
$xml_doc->loadXML($xml_str);

$xpath = new DOMXPath($xml_doc);

$cards_avg = $xpath->evaluate("avg(//card/type[name='visits'])");
var_dump($cards_avg);

$cards_sum = $xpath->evaluate("sum(//card/type[name='visits'])");
var_dump($cards_sum);

?>

I receive the following output:

asterixapenguin:/tmp$ php test.php
PHP Warning:  DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not
found in /tmp/test.php on line 23

Warning: DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not found
in /tmp/test.php on line 23
PHP Warning:  DOMXPath::evaluate(): Unregistered function in /tmp/test.php
on line 23

Warning: DOMXPath::evaluate(): Unregistered function in /tmp/test.php on
line 23
object(DOMNodeList)#5 (0) {
}
float(75)
asterixapenguin:/tmp$

Someone can help me?

Thanks in advance

Alex

attached mail follows:


Hi Alex,

Alex wrote:
> Hi all. I'm trying to use XPath avg(), min() and max() functions
> without success. Others functions like count() or sum() works correctly.
>
> Here is the code I'm using (PHP 5.1):
>
> <?php
>
> $xml_str = '
> <stats>
> <cards>
> <card name="My card">
> <type name="visits">25</type>
> <type name="clicks">7</type>
> </card>
> <card name="My other card">
> <type name="visits">50</type>
> <type name="clicks">3</type>
> </card>
> </cards>
> </stats>
> ';
>
> $xml_doc = new DOMDocument();
> $xml_doc->loadXML($xml_str);
>
> $xpath = new DOMXPath($xml_doc);
>
> $cards_avg = $xpath->evaluate("avg(//card/type[name='visits'])");
> var_dump($cards_avg);
>
> $cards_sum = $xpath->evaluate("sum(//card/type[name='visits'])");
> var_dump($cards_sum);
>
> ?>

min(), max() and avg() don't exist in XPath 1.0 which is the version
implemented in libxml2. You need to calculate these yourself. For example:

/* Find the average */
$cards_avg = $xpath->evaluate("sum(//card/type[name='visits']) div
count(//card/type[name='visits'])");
var_dump($cards_avg);

$cards_sum = $xpath->evaluate("sum(//card/type[name='visits'])");
var_dump($cards_sum);

/* Find lowest visits */
$cards_min_nodes = $xpath->query("//card/type[name='visits']/text()");
$min = NULL;
foreach ($cards_min_nodes AS $node) {
        $val = (int)$node->nodeValue;
        if (is_null($min) || $min > $val) {
                $min = $val;
        }
}
print 'Minimum Visits: '.$min."\n";

/* Find maximum visits */
$cards_max_nodes = $xpath->query("//card/type[name='visits']/text()");
$max = NULL;
foreach ($cards_max_nodes AS $node) {
        $val = (int)$node->nodeValue;
        if (is_null($min) || $max < $val) {
                $max = $val;
        }
}
print 'Maximum Visits: '.$max."\n";

Rob

--
rrichardsctindustries.net
author of Pro PHP XML and Web Services from Apress

attached mail follows:


How can I run a .php script from the command in Linux?

--
OOzy
Kubuntu-Dapper

attached mail follows:


On 08/06/06, OOzy Pal <oozypalgmail.com> wrote:
>
> How can I run a .php script from the command in Linux?
>
> 1. run /usr/local/bin/php (or wherever the php binary is, run which php to
> find out) scriptname

2. add the hash bang to the start of the script and run it by typing the
scriptname.

--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!

attached mail follows:


On 6/8/06, OOzy Pal <oozypalgmail.com> wrote:
> How can I run a .php script from the command in Linux?

$ php yourscript.php

Rabin

attached mail follows:


$ php script.php

OOzy Pal wrote:

> How can I run a .php script from the command in Linux?
>

attached mail follows:


Even better... if you want to use GET/POST, and access PHP scripts thru the
web server, it is recommended to use wget ....very useful tool, supports
http auth, etc.

Regards

Venky

On 08/06/06, Brad Bonkoski <bbonkoskimediaguide.com> wrote:
>
> $ php script.php
>
>
> OOzy Pal wrote:
>
> > How can I run a .php script from the command in Linux?
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


At 12:47 PM +1000 6/8/06, Chris wrote:
>tedd wrote:
>>At 10:56 AM +1000 6/8/06, Chris wrote:
>>>tedd wrote:
>>>>Hi gang:
>>>>
>>>>I've read that php sessions can create problems for Google bots.

-snip-

>>Chris:
>>
>>Thanks -- after your lead, I found that my site's session.use_trans_sid was turned off by default.
>>
>>So, it wasn't the problem I thought it might have been.
>
>So your page urls don't automatically append the session id to the end? I might have the wrong variable name so if you're still seeing them, I obviously have it wrong...

No, you're right and my url's are clean of SID's -- they always have been, that was the default.

The "problem" I was trying to figure out was how the use of SID's cause SE's to fail and how that works. I figured that once I understand how that worked, then I could keep from doing it. I just needed to "see for myself" what it was. You know, one of my "wonder why this works" studies.

While the problem wasn't present for me, which at the start of this I wasn't sure about, I did learn how it works and why SE's have problems with indexing url's that have "?" in them.

For those interested in this thread, this is what I believe is happening.

If you have a web page that uses SID's in it's url, then it appears to a SE as something like this (using one of my sites as an example):

http://ancientstones.com?PHPSESSID=1234

and not like:

http://ancientstones.com/

So the SE grabs the page with the SID. The next time it travels your site, it see's:

http://ancientstones.com?PHPSESSID=5678

and grabs that page. After a while, Google has numerous duplicate pages and has to pick one to be representative of your site and store all the others into it's supplemental index.

Now when Google determines PageRank for your site, it does so by calculating how many sites link to your site (simple version). If Google has picked:

http://ancientstones.com?PHPSESSID=5678

to be THE representative for your site, then you're sunk because no one uses a SID in their link to your site. Your site will always have a PR of 0 -- as it is with the referenced site. While the site ranks very high (currently #1) in a Google search for "Custom Tile Medallions", it has a PR of 0. I was trying to figure out what was happening and if there was something I was doing in using php caused the low PR. I found that PHP wasn't the problem -- and now I know that.

At least, that's the way I understand what's going on -- if I'm mistaken, please correct me.

tedd

--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Hello,

I've used like 3 hours to get this done but I can't figure this out. Hope
someone here can help.

I have a form that a user can use to edit www pages. Page content is stored
in DB as a HTML code. First user has to select, from <select> menu, which
page to edit. Then the selected page content html is retrieved to a
<textarea> where it can be edited with tinyMCE editor. Then there's two
buttons. Publish to save the edited content back to DB (no problems there)
and Preview to open the full page layout in a popup window. The problem is
that I can't pass the edited data from the <textarea> to the popup window.
Here's last (desperate) attempt:

<table width="800" border="0">
<tr>
<td colspan="2">Edit</td>
</tr>
<tr>
<td colspan="2">
<textarea name="Edited" cols="100" rows="40" id="<? echo $tinymcestatus; ?>"
>
<?php
$result=mysql_query("SELECT ContentData FROM x_pages WHERE id = '$ID'");
$ContentData = mysql_fetch_row($result);
print $ContentData[0];
?>
</textarea>
</td>
</tr>
<tr>
<td>
<script language="JavaScript">
function Preview() {
window.open('preview.php?page=<?php echo $ContentData[0] ?>', 'popup',
'width=900, height=900, top=0, left=0, menubar=0, scrollbars=1, location=1,
toolbar=0, resizable=1, status=0');
}
</script>
<input type="submit" name="Submit" value="Publish">
<input type="button" onclick="Preview(''); return false;" value="Preview" />
</td>
</tr>
</table>

When I echo $page at the preview.php window it prints some of the data to
page and some to address line??? And this is not even the edited data. I
should pass The variable $Edited but I can't get it to work

Thanks a LOT
-Will

attached mail follows:


My Humble suggestion is possibly:

upon preview, actually post the edited data to a temp table, and then
pull the HTML from the temp table to display the preview page.

Currently you are passing the original content to the preview page.
And You might want to look to see if javascript has any functions for
escaping html entities for your GET variable..
To get the edited content you will need to get the contents of the text
area in the javascript, not pass the original PHP variable (as this will
be the original content)

-Brad

William Stokes wrote:

>Hello,
>
>I've used like 3 hours to get this done but I can't figure this out. Hope
>someone here can help.
>
>I have a form that a user can use to edit www pages. Page content is stored
>in DB as a HTML code. First user has to select, from <select> menu, which
>page to edit. Then the selected page content html is retrieved to a
><textarea> where it can be edited with tinyMCE editor. Then there's two
>buttons. Publish to save the edited content back to DB (no problems there)
>and Preview to open the full page layout in a popup window. The problem is
>that I can't pass the edited data from the <textarea> to the popup window.
>Here's last (desperate) attempt:
>
><table width="800" border="0">
><tr>
><td colspan="2">Edit</td>
></tr>
><tr>
><td colspan="2">
><textarea name="Edited" cols="100" rows="40" id="<? echo $tinymcestatus; ?>"
> >
><?php
>$result=mysql_query("SELECT ContentData FROM x_pages WHERE id = '$ID'");
>$ContentData = mysql_fetch_row($result);
>print $ContentData[0];
>?>
></textarea>
></td>
></tr>
><tr>
><td>
><script language="JavaScript">
>function Preview() {
>window.open('preview.php?page=<?php echo $ContentData[0] ?>', 'popup',
>'width=900, height=900, top=0, left=0, menubar=0, scrollbars=1, location=1,
>toolbar=0, resizable=1, status=0');
>}
></script>
><input type="submit" name="Submit" value="Publish">
><input type="button" onclick="Preview(''); return false;" value="Preview" />
></td>
></tr>
></table>
>
>When I echo $page at the preview.php window it prints some of the data to
>page and some to address line??? And this is not even the edited data. I
>should pass The variable $Edited but I can't get it to work
>
>Thanks a LOT
>-Will
>
>
>

attached mail follows:


William Stokes schrieb:
> Hello,
>
> I've used like 3 hours to get this done but I can't figure this out. Hope
> someone here can help.
>
> I have a form that a user can use to edit www pages. Page content is stored
> in DB as a HTML code. First user has to select, from <select> menu, which
> page to edit. Then the selected page content html is retrieved to a
> <textarea> where it can be edited with tinyMCE editor. Then there's two
> buttons. Publish to save the edited content back to DB (no problems there)
> and Preview to open the full page layout in a popup window. The problem is
> that I can't pass the edited data from the <textarea> to the popup window.
> Here's last (desperate) attempt:
>
Hint: Fool around with the "target" property of HTML ;)

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


At 4:44 PM +0300 6/8/06, William Stokes wrote:
>I have a form that a user can use to edit www pages. Page content is stored
>in DB as a HTML code. First user has to select, from <select> menu, which
>page to edit. Then the selected page content html is retrieved to a
><textarea> where it can be edited with tinyMCE editor. Then there's two
>buttons. Publish to save the edited content back to DB (no problems there)
>and Preview to open the full page layout in a popup window. The problem is
>that I can't pass the edited data from the <textarea> to the popup window.
>Here's last (desperate) attempt:

-snip-

>When I echo $page at the preview.php window it prints some of the data to
>page and some to address line??? And this is not even the edited data. I
>should pass The variable $Edited but I can't get it to work

My opinion is that you're running into the classic problem of how to get javascript variables into php variables.

As I see it, you have three ways to do this (anyone think I'm wrong, please correct me):

1. You place them into your dB with js and then pull them back out in php:

<http://www.devshed.com/c/a/MySQL/Loading-JavaScript-Arrays-with-MySQL-Data/>

2. You use ajax and plug the js variables values into like php variables. If you want to go this route, it's not complicated -- I can demonstrate. Please let me know.

3. You can try in your html using an id="Edited" for js and a name="Edited" for php -- it worked for a previous like-problem posted on this list. But I don't know if it's applicable in your case.

hth's

tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Am 2006-05-29 11:56:43, schrieb siavash1979telus.net:
> ok, maybe I didn't make my question too clear. I was mostly wondering
> if there
> is a way to do it in PHP rather than Javascript. I would prefer only
> using php.

Maybe it can be done, like,

    1) Client fill out a form
    2) Client klick the Submit Button
    3) The php script on the server get the data
        and store it temporary
    4) The php script on the server send back a HTML page
        which open a new (popup) window with the question
    5) Client must confirm
    6) The php script on the server get the confirmation
        and do something wit the previously sored data

Greetings
    Michelle Konzack

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
                   50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

attached mail follows:


Hi there

I have a php web script which communicates with a server using sockets.
There is a method in which the client listens for messages from the
server, and this blocks the client.
I need a way to 'fork' a process or to get this method to run in the
background so that i can process user input while not interrupting the
protocol.

I have searched all over the web with no luck, can anyone point me in
the right direction?

thanks
nic

All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm

attached mail follows:


On 6/8/06 10:10 AM, Nic Appleby wrote:
> I have a php web script which communicates with a server using sockets.
> There is a method in which the client listens for messages from the
> server, and this blocks the client.
> I need a way to 'fork' a process or to get this method to run in the
> background so that i can process user input while not interrupting the
> protocol.

Have you looked at pcntl_fork()?
http://www.php.net/pcntl-fork

--
Ben Ramsey
http://benramsey.com/

attached mail follows:


Nic Appleby wrote:
> Hi there
>
> I have a php web script which communicates with a server using sockets.
> There is a method in which the client listens for messages from the
> server, and this blocks the client.
> I need a way to 'fork' a process or to get this method to run in the
> background so that i can process user input while not interrupting the
> protocol.
>
> I have searched all over the web with no luck, can anyone point me in
> the right direction?
>
> thanks
> nic
>
>
>
> ------------------------------------------------------------------------
>
> All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm

You may be able to do this with asynchronous sockets without forking.
With them, you can poll the sockets for new data in between processing
user input requests. It might not be quite as fast, but it'll be a lot
easier to work with.

Regards, Adam Zey.

attached mail follows:


Hi All,

Is there a way for the server to notify the client about an event, provided
the client was online in the past X minutes?

To elaborate:

A client comes online. A script PHP executes (serves the client), and
terminates. Now if a new event occurs, how can the server notify the client
about that event?

Thanks
KM

attached mail follows:


kartikay malhotra wrote:

> Hi All,
>
> Is there a way for the server to notify the client about an event,
> provided
> the client was online in the past X minutes?
>
> To elaborate:
>
> A client comes online. A script PHP executes (serves the client), and
> terminates. Now if a new event occurs, how can the server notify the
> client
> about that event?
>
Don't think it can....
But you can have the client (think AJAX) continuously 'poll' the server,
and then the server can send updates back if necessary.
-Brad

> Thanks
> KM
>

attached mail follows:


kartikay malhotra wrote:
> Hi All,
>
> Is there a way for the server to notify the client about an event, provided
> the client was online in the past X minutes?
>
> To elaborate:
>
> A client comes online. A script PHP executes (serves the client), and
> terminates. Now if a new event occurs, how can the server notify the client
> about that event?
>
> Thanks
> KM
>

what kind of event??

attached mail follows:


[snip]
Is there a way for the server to notify the client about an event,
provided
the client was online in the past X minutes?

To elaborate:

A client comes online. A script PHP executes (serves the client), and
terminates. Now if a new event occurs, how can the server notify the
client
about that event?
[/snip]

You would need a connection with state to do that, web server
connections are stateless. The client would have to have a 'listener'
waiting for some event to be pushed to them and then the listener would
take an action.

attached mail follows:


>
> Hi All,
>
> Is there a way for the server to notify the client about an
> event, provided
> the client was online in the past X minutes?
>
> To elaborate:
>
> A client comes online. A script PHP executes (serves the client), and
> terminates. Now if a new event occurs, how can the server
> notify the client
> about that event?
>

Short answer: It can't.

Longer answer: There are probably 100 ways to get close to the result you
are looking for. For instance, you could have each page on your site look
for a flag in a DB, or a file in the filesystem, or some other clue. Then
when the user loads a new page, the page discovers the event, and notifies
him.

PHP is server side. So everything it generates, it does so on page load.

There are PHP/Javascript solutions (like AJAX) that may be able to get
closer to what you want.

We would need more detail for a more detailed answer.

JM

attached mail follows:


Angelo Zanetti schrieb:
> kartikay malhotra wrote:
>> Hi All,
>>
>> Is there a way for the server to notify the client about an event,
>> provided
>> the client was online in the past X minutes?
>>
>> To elaborate:
>>
>> A client comes online. A script PHP executes (serves the client), and
>> terminates. Now if a new event occurs, how can the server notify the
>> client
>> about that event?
>>
>> Thanks
>> KM
>>
>
>
> what kind of event??

Server bored and fooling around with the neighbor servers hardware :P

But Ajax would be the best method using.

Anyway else isn't possible (well refreshing would be one way)

But since you don't want php files to execute forever you will have to
stick to AJAX.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


Barry wrote:
> Angelo Zanetti schrieb:
>> kartikay malhotra wrote:
>>> Hi All,
>>>
>>> Is there a way for the server to notify the client about an event,
>>> provided
>>> the client was online in the past X minutes?
>>>
>>> To elaborate:
>>>
>>> A client comes online. A script PHP executes (serves the client), and
>>> terminates. Now if a new event occurs, how can the server notify the
>>> client
>>> about that event?
>>>
>>> Thanks
>>> KM
>>>
>>
>>
>> what kind of event??
>
> Server bored and fooling around with the neighbor servers hardware :P
>
> But Ajax would be the best method using.
>
> Anyway else isn't possible (well refreshing would be one way)
>
> But since you don't want php files to execute forever you will have to
> stick to AJAX.
>

You can do it without polling. I've seen web applications that open a
neverending GET request in order to get updates to the browser
instantaneously.

Regards, Adam.

attached mail follows:


Dear Adam,

"You can do it without polling. I've seen web applications that open a
neverending GET request in order to get updates to the browser
instantaneously.

Regards, Adam."

Kindly elaborate on "neverending GET request". Shall I call the script from
within itself?

Regards
KM

On 6/8/06, Adam Zey <azeynit.ca> wrote:
>
> Barry wrote:
> > Angelo Zanetti schrieb:
> >> kartikay malhotra wrote:
> >>> Hi All,
> >>>
> >>> Is there a way for the server to notify the client about an event,
> >>> provided
> >>> the client was online in the past X minutes?
> >>>
> >>> To elaborate:
> >>>
> >>> A client comes online. A script PHP executes (serves the client), and
> >>> terminates. Now if a new event occurs, how can the server notify the
> >>> client
> >>> about that event?
> >>>
> >>> Thanks
> >>> KM
> >>>
> >>
> >>
> >> what kind of event??
> >
> > Server bored and fooling around with the neighbor servers hardware :P
> >
> > But Ajax would be the best method using.
> >
> > Anyway else isn't possible (well refreshing would be one way)
> >
> > But since you don't want php files to execute forever you will have to
> > stick to AJAX.
> >
>
> You can do it without polling. I've seen web applications that open a
> neverending GET request in order to get updates to the browser
> instantaneously.
>
> Regards, Adam.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


kartikay malhotra wrote:
> Dear Adam,
>
>
> "You can do it without polling. I've seen web applications that open a
> neverending GET request in order to get updates to the browser
> instantaneously.
>
> Regards, Adam."
>
> Kindly elaborate on "neverending GET request". Shall I call the script from
> within itself?
>
> Regards
> KM
>
> On 6/8/06, Adam Zey <azeynit.ca> wrote:
>>
>> Barry wrote:
>> > Angelo Zanetti schrieb:
>> >> kartikay malhotra wrote:
>> >>> Hi All,
>> >>>
>> >>> Is there a way for the server to notify the client about an event,
>> >>> provided
>> >>> the client was online in the past X minutes?
>> >>>
>> >>> To elaborate:
>> >>>
>> >>> A client comes online. A script PHP executes (serves the client), and
>> >>> terminates. Now if a new event occurs, how can the server notify the
>> >>> client
>> >>> about that event?
>> >>>
>> >>> Thanks
>> >>> KM
>> >>>
>> >>
>> >>
>> >> what kind of event??
>> >
>> > Server bored and fooling around with the neighbor servers hardware :P
>> >
>> > But Ajax would be the best method using.
>> >
>> > Anyway else isn't possible (well refreshing would be one way)
>> >
>> > But since you don't want php files to execute forever you will have to
>> > stick to AJAX.
>> >
>>
>> You can do it without polling. I've seen web applications that open a
>> neverending GET request in order to get updates to the browser
>> instantaneously.
>>
>> Regards, Adam.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

I refer to having the javascript code open a GET request that never ends
and streaming data from the server back to the client. The server-side
PHP process, which stays running, streams back data whenever it becomes
available. This of course uses a lot of memory. I have never done this
myself in a web application, so I suggest you google for examples of
other people who have actually implemented it.

Regards, Adam Zey.

attached mail follows:


Hello All,

I'm using a form (method="POST") to collect 30 boolean values from the
end user using a series of checkboxes in the form. The form is
arranged in a table so that the 30 check boxes are not a long list but
rather three columns (with related items columnized). The problem is
when I iterate through the $_POST results:

The order in which I wish to present the checkboxes to the end user is
different than the order I want to have in the $_POST super global and
subsequently when I dump that information out to a text file.

What would be the best way to solve this?

1) Is there a way to present the checkboxes in a certain order, yet
have the data transmitted into the $_POST super global in a different
order?

2) Does it make more sense to process the $_POST super global array
and reorder the items within the array?

3) Some other method?

Thanks for any advice.

- Ben

attached mail follows:


On 08/06/06, Ben Liu <blzabub8gmail.com> wrote:
>
> Hello All,
>
> I'm using a form (method="POST") to collect 30 boolean values from the
> end user using a series of checkboxes in the form. The form is
> arranged in a table so that the 30 check boxes are not a long list but
> rather three columns (with related items columnized). The problem is
> when I iterate through the $_POST results:
>
> The order in which I wish to present the checkboxes to the end user is
> different than the order I want to have in the $_POST super global and
> subsequently when I dump that information out to a text file.
>
> What would be the best way to solve this?
>
> 1) Is there a way to present the checkboxes in a certain order, yet
> have the data transmitted into the $_POST super global in a different
> order?
>
> 2) Does it make more sense to process the $_POST super global array
> and reorder the items within the array?
>
> 3) Some other method?
>
> Thanks for any advice.
>
> - Ben

You can access the values in the $_POST array in any order, so if you know
the checkbox names why not output them in the order you want? Or I am being
dumb here?

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

--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!

attached mail follows:


Ben Liu schrieb:
> Hello All,
>
> I'm using a form (method="POST") to collect 30 boolean values from the
> end user using a series of checkboxes in the form. The form is
> arranged in a table so that the 30 check boxes are not a long list but
> rather three columns (with related items columnized). The problem is
> when I iterate through the $_POST results:
>
> The order in which I wish to present the checkboxes to the end user is
> different than the order I want to have in the $_POST super global and
> subsequently when I dump that information out to a text file.
>
> What would be the best way to solve this?
>
> 1) Is there a way to present the checkboxes in a certain order, yet
> have the data transmitted into the $_POST super global in a different
> order?
>
> 2) Does it make more sense to process the $_POST super global array
> and reorder the items within the array?
>
> 3) Some other method?
>
> Thanks for any advice.
>
> - Ben
1. Use Keys in your form like a[1],a[2]
2. order the array by usort (alphabetically or whatever u prefer)

that way => 2: yes it is.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


Ben Liu schrieb:
> Hello All,
>
> I'm using a form (method="POST") to collect 30 boolean values from the
> end user using a series of checkboxes in the form. The form is
> arranged in a table so that the 30 check boxes are not a long list but
> rather three columns (with related items columnized). The problem is
> when I iterate through the $_POST results:
>
> The order in which I wish to present the checkboxes to the end user is
> different than the order I want to have in the $_POST super global and
> subsequently when I dump that information out to a text file.
>
> What would be the best way to solve this?
>
> 1) Is there a way to present the checkboxes in a certain order, yet
> have the data transmitted into the $_POST super global in a different
> order?
>
> 2) Does it make more sense to process the $_POST super global array
> and reorder the items within the array?
>
> 3) Some other method?
>
> Thanks for any advice.
>
> - Ben
1. Use Keys in your form like a[1],a[2]
2. order the array by usort (alphabetically or whatever u prefer)

that way => 2: yes it is.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


Hi Dave,

No, that is definitely a possibility. Right now I am using a foreach
loop to iterate over the $_POST array and determine if each checkbox
is checked or not, if it is checked, than a related piece of data is
written into the text file. This makes for pretty compact code. I
could as you suggest, simply check each element in the array manually
using the associative keys rather than using a loop, that way I could
do it in any order I wished, but the code gets rather long with a line
for each checkbox. I anticipate this set of checkboxes/boolean
responses may increase in the future also, so having the loop allows
for some future-proofing.

- Ben

On 6/8/06, Dave Goodchild <buddhamagnetgmail.com> wrote:
>
>
>
> On 08/06/06, Ben Liu <blzabub8gmail.com> wrote:

> You can access the values in the $_POST array in any order, so if you know
> the checkbox names why not output them in the order you want? Or I am being
> dumb here?

attached mail follows:


I probably should add some more details to my question:

The names of the form checkboxes could be changed from ie:
bool_careers, bool_speaking, bool_internship, etc. to a single array
bool_questions[], for instance. The problem with that is that I am
using the form checkbox names later to process related data.
Specifically, I am building a user-input based query. So if the form
checkbox names are the same as the names of the variables in the
database, it makes for easy creating of the query, since the names
become associative keys in the $_POST array. I iterate through the
$_POST array, checking each for true/false state. If the checkbox is
checked, I add the associative key name to the query. Eliminating the
checkbox names in favor of a numerical key only would make this more
complicated.

- Ben

On 6/8/06, Barry <barryflyerheaven.de> wrote:

> 1. Use Keys in your form like a[1],a[2]
> 2. order the array by usort (alphabetically or whatever u prefer)
>
> that way => 2: yes it is.

attached mail follows:


Also, I need to re-order the elements in a custom manner, not simply
alphabetical or reverse alphabetical or some logical way like that,
more like how the original form is presented, by related fields. More
specifically, the form is for a membership system, the system collects
typical demographic information like home street address, home zip
code, business street address, business zip code. So the form presents
related fields together: business with business fields and home with
home fields (in columns). The problem is the POST method writes these
response into the $_POST array in a certain order: not top-to-bottom,
then left-to-right as a person would read the form, but left-to right,
then top-to-bottom. The simple solution would be to reorder the form
checkboxes so that they matched the desired output order of the text
file, but then the user is presented with a disorganized, illogical
form. I could eliminate the table and just list all the checkboxes in
one big list, but again that makes for an ugly, user-unfriendly form.
I could perhaps use some divs to make columns and float them, I'm not
sure how the $_POST method would order the responses in the $_POST
array.

attached mail follows:


Ben Liu wrote:
> Hi Dave,
>
> No, that is definitely a possibility. Right now I am using a foreach
> loop to iterate over the $_POST array and determine if each checkbox
> is checked or not, if it is checked, than a related piece of data is
> written into the text file. This makes for pretty compact code. I
> could as you suggest, simply check each element in the array manually
> using the associative keys rather than using a loop, that way I could
> do it in any order I wished, but the code gets rather long with a line
> for each checkbox. I anticipate this set of checkboxes/boolean
> responses may increase in the future also, so having the loop allows
> for some future-proofing.
>
> - Ben
>
> On 6/8/06, Dave Goodchild <buddhamagnetgmail.com> wrote:
>
>>
>>
>>
>> On 08/06/06, Ben Liu <blzabub8gmail.com> wrote:
>
>
>> You can access the values in the $_POST array in any order, so if you
>> know
>> the checkbox names why not output them in the order you want? Or I am
>> being
>> dumb here?
>
>

why not create an array with the keys in the order you want ( $array=
array(value1,value2,....). Then loop through the array and use the
values as keys to the $_POST variable and perform your processing that way.

foreach ($array as $value) {
    if (isset($_POST[$value]) {
          do something;
    }
}

--
Ron Clark
System Administrator
Armstrong Atlantic State University

attached mail follows:


Since i remember, when a for POST is sent and a checkbox is not checked, php
not receive this $_POST variable.

That is, i think you don´t need to use a foreach to know if checkbox was
checked or not.

Am i wrong?

""Ben Liu"" <blzabub8gmail.com> escreveu na mensagem
news:8931758b0606080759u3d49932bqd4bdfb6dae436da1mail.gmail.com...
> Hello All,
>
> I'm using a form (method="POST") to collect 30 boolean values from the
> end user using a series of checkboxes in the form. The form is
> arranged in a table so that the 30 check boxes are not a long list but
> rather three columns (with related items columnized). The problem is
> when I iterate through the $_POST results:
>
> The order in which I wish to present the checkboxes to the end user is
> different than the order I want to have in the $_POST super global and
> subsequently when I dump that information out to a text file.
>
> What would be the best way to solve this?
>
> 1) Is there a way to present the checkboxes in a certain order, yet
> have the data transmitted into the $_POST super global in a different
> order?
>
> 2) Does it make more sense to process the $_POST super global array
> and reorder the items within the array?
>
> 3) Some other method?
>
> Thanks for any advice.
>
> - Ben

attached mail follows:


Der...of course. Thanks Ron! I knew the answer was simple. :-)

-Ben

On 6/8/06, Ron Clark <ronarmstrong.edu> wrote:

> why not create an array with the keys in the order you want ( $array=
> array(value1,value2,....). Then loop through the array and use the
> values as keys to the $_POST variable and perform your processing that way.
>
> foreach ($array as $value) {
> if (isset($_POST[$value]) {
> do something;
> }
> }
>
>
> --
> Ron Clark
> System Administrator
> Armstrong Atlantic State University

attached mail follows:


Hello João,

You are right that the $_POST variable does not receive anything for
unchecked boxes. I didn't realize that. But I still need the foreach
loop for other reasons:

So it looks like this:

        foreach ($_POST as $key => $data) {
                $query.="$key, ";
        }

Instead of this:

        foreach ($_POST as $key => $data) {
                if ($data) $query.="$key, ";
        }

Thanks,

Ben

On 6/8/06, João Cândido de Souza Neto <joaocuritibaonline.com.br> wrote:
> Since i remember, when a for POST is sent and a checkbox is not checked, php
> not receive this $_POST variable.
>
> That is, i think you don´t need to use a foreach to know if checkbox was
> checked or not.
>
> Am i wrong?

attached mail follows:


yes, as I said in an earlier post, I used to have 30 if ($key)
statements, one for each checkbox, in the order I wanted to write them
in. This is not optimal because: (a) it is a ton of code, (b) the
checkboxes could in the future increase in number, change order, etc.
and then I would have to recode this section to match. The solution I
used to solve this was to remove the table, put all the checkboxes
into <div> elements, float them into columns and now they appear in
the same order as before when they were in a table, but they write to
the $_POST variable in the order that I want.

- Ben

On 6/8/06, João Cândido de Souza Neto <joaocuritibaonline.com.br> wrote:
> I don´t test, but it can works fine:
>
> foreach ($_POST as $key => $data) {
> switch ($key) {
> case "aaa"
> $query.="$key, ";
> break;
> case "bbb"
> $query.="$key, ";
> break;
> case "ccc"
> $query.="$key, ";
> break;
> }
> }
>
> In switch you can order by ordening the cases.
>
> Hope help.
>
> ----- Original Message -----
> From: "Ben Liu" <blzabub8gmail.com>
> To: "João Cândido de Souza Neto" <joaocuritibaonline.com.br>
> Cc: <php-generallists.php.net>
> Sent: Thursday, June 08, 2006 1:14 PM
> Subject: Re: [PHP] Re: order of elements in $_POST super global
>
>
> Hello João,
>
> You are right that the $_POST variable does not receive anything for
> unchecked boxes. I didn't realize that. But I still need the foreach
> loop for other reasons:
>
> So it looks like this:
>
> foreach ($_POST as $key => $data) {
> $query.="$key, ";
> }
>
> Instead of this:
>
> foreach ($_POST as $key => $data) {
> if ($data) $query.="$key, ";
> }
>
> Thanks,
>
> Ben
>
> On 6/8/06, João Cândido de Souza Neto <joaocuritibaonline.com.br> wrote:
> > Since i remember, when a for POST is sent and a checkbox is not checked,
> > php
> > not receive this $_POST variable.
> >
> > That is, i think you don´t need to use a foreach to know if checkbox was
> > checked or not.
> >
> > Am i wrong?
>
>

attached mail follows:


Mayank Maheshwary wrote:
> Hi,
>
> I am facing some trouble with the file( ) function. I understand that it
> returns the contents of the file in an array. Also, I am able to print the
> lines using the echo function. However, whenever I try to compare the
> contents of an array using strcmp, or ==, the page simply keeps 'loading',
> instead of printing results.
>
> The following is the code that I try:
>
> $name = $_POST["filename"];
> $lines = file($name);
> $i = 0;
> $len = sizeof($lines);
> //echo $i;
> while($i < $len) {
> //echo $lines[$i];
> $temp = $lines[$i];
> $temp = trim($temp);
> //echo $temp;
> if($temp1 == '--------------------------------------') {
> echo $i;
> return $i;
> }
> else
> $i++;
> }
>
> I think that the way the lines of the file are stored in the array may be
> the problem, but I do not know what I am supposed to change. Any help would
> be appreciated.
>
> Thanks.
>
> MM.
>

You might want to reexamine the need for your code. It appears that all
your code does is searches through a file for a certain line. Do you
need to do this manually? array_search() will replace your entire for
loop with a single function call, and it'll almost certainly be faster
to boot.

Regards, Adam Zey.

attached mail follows:


After I've looped through a resource do I have to run the query again
to load up 'mysql_fetch_assoc' or is there some kind of reset
function I can't find?

$q = "SELECT * FROM table;
$s = mysql_query($q, $pe) or die(mysql_error());
while ($row_s = mysql_fetch_assoc($s)) {
        echo $i++;
}

outputs "12345..." for each row of table

while ($row_s2 = mysql_fetch_assoc($q)) {
        ...
}

outputs ""

Thanks