php-general Digest 29 Aug 2008 07:53:34 -0000 Issue 5651
Topics (messages 278915 through 278939):
Re: Regex for email validation
278915 by: tedd
www.yfrindia.com
278916 by: YFR India
Re: concatenating with "." or ","
278917 by: tedd
Re: Manual Coding vs. CMS Systems OT
278918 by: Jochem Maas
Re: grab the complete commandline used ...
278919 by: Jochem Maas
278920 by: Jochem Maas
278928 by: Micah Gersten
278933 by: Jochem Maas
278935 by: Robert Cummings
A better XSS trap (Feedback wanted)
278921 by: Christopher Vogt
Problems sending $_POST vairable to an ASP page
278922 by: shaun thornburgh
278923 by: Jay Blanchard
278924 by: Ólafur Waage
278925 by: shaun thornburgh
278926 by: Jay Blanchard
278930 by: shaun thornburgh
278937 by: Stut
ASCII Captcha
278927 by: Ólafur Waage
278932 by: tedd
Re: Manual Coding vs. CMS Systems
278929 by: Lester Caine
278931 by: Larry Garfield
278934 by: Jochem Maas
Re: Variable name as a string
278936 by: ioannes
278939 by: Bren Norris
Is this a bug?
278938 by: Catalin Zamfir Alexandru, DATAGRAM SRL
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 ---
At 9:34 AM +0200 8/28/08, Per Jessen wrote:
Yeti wrote:
That Rx.com domain name is really great stuff, but how do you expect
the average user to type it in?
Sorry, I don't understand the problem. The average user will obviously
have a suitable keyboard, such as this for instance:
http://en.wikipedia.org/wiki/Image:KB_Swiss.svg
/Per Jessen, Zürich
I hope you're right.
However, it's one thing to have a keyboard
designed for a specific language and another to
be able to enter code-points that aren't
associated with any specific language (i.e.,
Dingbats and Math Symbols).
For example, note that Rx,com is not associated
with any language, which is the same as many of
my other domains, as you can see some here:
http://symboldomains.com/symbol-domains-for-sale.html
I bought most of these eight years ago hoping
that someone would see things the way I do. But
despite all my time, effort, and cost -- the only
thing I have received is being called a goofy
nitwit -- which I probably am -- but I would like
to think of myself as an entertaining nitwit. :-)
I have grandiose plans, but unfortunately I'm the only one who see's them.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
http://www.yfrindia.com/
Take FREE online TEST, read FREE articles, download FREE presentation, use
FREE source code, useful links, competition updates, free ONLINE TEST TESTS,
http://www.yfrindia.com/resources/Tests
free APTITUDE TEST, English Test, Computer Test, Mechanical Test,
Electronics Test, Electrical Test, GATE preparation, CAT preparation, Job
preparation, resume.
http://www.yfrindia.com
--
View this message in context:
http://www.nabble.com/www.yfrindia.com-tp19208138p19208138.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
At 5:44 PM +0100 8/28/08, Ford, Mike wrote:
Santa Monica, CA.
I moved from Missouri to California when I was 12 just after the Feds
paid my father a visit and my father took-off for parts unknown --
apparently they frown on embezzling. I didn't see my father again
until I turned 30.
I lived in the San Fernando Valley until after graduating from CSUN
in 1975. Then I went to Michigan where I met my wife and received my
MSc from MSU.
Michigan is like big minnow trap -- once you swim in, you're caught.
But, I don't miss California -- nice weather, but too much crime and
too many people. At least Michigan is green and if you stay away from
Detroit, there's not much crime either.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Carlos Medina schreef:
Watch him go... there is Carloooooos, the man infront of all the
others. He
is WAY ahead, and he is gaining more and more speed. He is an adult,
and he
is sooooooo adult that he can't even take a laugh... see him run from the
humor! Faster and faster he runs... and there it is: the goal: an open
casket for the people going through life without having a good laugh
every
now and then :o))))
Aaaaaaanyhow... *grabs his coffee and keeps working while shaking his
head
because of the stupid comment posted by Carlos*
Cheers :o))))
:-) Kids
yes I have one, so? did he build your website per chance? :-P
btw:
I have two handcoded cmses that I use to build sites with,
a bunch of code 'snippets' used to handcode very small odd-ball sites
with and I sometimes use an out of the box CMS if it suits me
(but not Joomla) ... and I always end up having to hack some
customization into them.
as a developer it's not just about getting a quick result but
aquiring a level of expertise that allows one to understand and create
things at a professional level, things like CMSes (somebody actually
writes them!) using validating, tableless xHTML layouts, valid CSS,
secure server-side code, unobtrusive (and sometimes even gracefully
degrading) javascript, etc, etc.
the pond is getting smaller and smaller, eventually there won't be
any room for people who can just about run the installer script of
CMS X[tm] and barely hack out HTML. I plan to be getting paid still
when that happens ... rewriting the installer script of CMS X[tm] perhaps.
Carlos
--- End Message ---
--- Begin Message ---
Robert Cummings schreef:
On Thu, 2008-08-28 at 10:22 -0500, Micah Gersten wrote:
Does this work?
$command = implode(' ', $argv);
no syntax errors, so in that sense it works.
but it doesn't answer my question (check the body of the post as
well as the subject and that might become clear).
Only do it that way if it's for a log of general output. If you're going
to punt any of those parts back to the OS in another command you'll need
to properly escape them.
true, and yes it's for a log and no join(' ', $argv); doesn't cut it :-)
Cheers,
Rob.
--- End Message ---
--- Begin Message ---
David Otton schreef:
2008/8/28 Jochem Maas <[EMAIL PROTECTED]>:
anyone know if it's possible to grab the entire commandline
that was used to start up a php script on the CLI, an example
of what I'm looking to grab from within the script (test.php in
this example):
"php -qC -ddisplay_errors=1 ./test.php -o -d -e [EMAIL PROTECTED] -f
./last.log | grep Exception"
of course I know what the script name and arguments are but I'd rather like
the
whole enchilada (php binary and it's args + the pipe to grep).
possible? bad idea? down boy?
Not possible, I'm afraid. Certainly not portably. The command line is
manipulated quite heavily before your script gets run. (eg shell
wildcard expansions).
I have a feeling I'm out of luck - probably security issues that keep
you from doing such a thing as well.
I did have the idea of grabbing the PID and then grepping the output of
ps via exec() ... that would do it, but I reckon it smells. :-)
A quick Google suggests that it is possible under VMS, but I doubt
that's much use to you.
STW wasn't giving me any joy either, it's for linux only (although it
would be nice if it worked on my Mac)
--- End Message ---
--- Begin Message ---
I suggest creating a shell wrapper for PHP that will write the command
to a file for you and then call PHP with the appropriate arguments. PHP
won't even see most of the command that you originally posted.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
Jochem Maas wrote:
> Robert Cummings schreef:
>> On Thu, 2008-08-28 at 10:22 -0500, Micah Gersten wrote:
>>> Does this work?
>>> $command = implode(' ', $argv);
>
> no syntax errors, so in that sense it works.
> but it doesn't answer my question (check the body of the post as
> well as the subject and that might become clear).
>
>> Only do it that way if it's for a log of general output. If you're going
>> to punt any of those parts back to the OS in another command you'll need
>> to properly escape them.
>
> true, and yes it's for a log and no join(' ', $argv); doesn't cut it :-)
>
>>
>> Cheers,
>> Rob.
--- End Message ---
--- Begin Message ---
Micah Gersten schreef:
I suggest creating a shell wrapper for PHP that will write the command
to a file for you and then call PHP with the appropriate arguments. PHP
won't even see most of the command that you originally posted.
which wouldn't catch the pipe to grep now would it. nevermind, I don't think
you ge what I was looking for, not worry I can hack together a 'solution'
using exec() ... by grepping the output of ps.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
Jochem Maas wrote:
Robert Cummings schreef:
On Thu, 2008-08-28 at 10:22 -0500, Micah Gersten wrote:
Does this work?
$command = implode(' ', $argv);
no syntax errors, so in that sense it works.
but it doesn't answer my question (check the body of the post as
well as the subject and that might become clear).
Only do it that way if it's for a log of general output. If you're going
to punt any of those parts back to the OS in another command you'll need
to properly escape them.
true, and yes it's for a log and no join(' ', $argv); doesn't cut it :-)
Cheers,
Rob.
--- End Message ---
--- Begin Message ---
On Fri, 2008-08-29 at 04:48 +0200, Jochem Maas wrote:
> Micah Gersten schreef:
> > I suggest creating a shell wrapper for PHP that will write the command
> > to a file for you and then call PHP with the appropriate arguments. PHP
> > won't even see most of the command that you originally posted.
>
> which wouldn't catch the pipe to grep now would it. nevermind, I don't think
> you ge what I was looking for, not worry I can hack together a 'solution'
> using exec() ... by grepping the output of ps.
I doubt it. The ps command sees what the script sees. If I do mplayer
*.avi, ps shows me the expanded file list that was given to mplayer.
Remember, shell gets first dibs before anything happens. BTW your
subject line does not imply that you wanted the EXACT command line
used :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
Hej everybody,
I built something I'd like to have feedback on. Looking at all the
template engines out there made me think.
I have two main requirements:
- use PHP as the template language
- effective XSS prevention without betting on discipline
Plain PHP only satisfies the first. I also couldn't find a PHP template
engine that satisfies both. (Savant doesn't.)
So here is my own minimal solution and I would like to know your
opinion. Also, if anybody has seen something like it out there, please
point me to it.
The Idea:
Automatically wrap every output string into a Decorator object, which
offers filtering methods like htmlentities. This also means intercepting
access to strings contained in Arrays and Objects in order to decorate them.
The code:
http://code.google.com/p/cvphplib/source/browse/trunk/cvphplib/
svn checkout http://cvphplib.googlecode.com/svn/trunk/cvphplib/
Example usage:
// first a simple string
<? $string = CV_OutputFilter::filter( '<marquee>evil</marquee>' ); ?>
<?=$string?> triggers an error
<?=$string->htmlentities()?> works fine
<?=$string->urlencode()?> works fine
<?=$string->raw()?> outputs the unfiltered value
// extracting a bunch of filtered variables into the local scope
<?php
$vars = array( 'x'=>5, 'o'=>new O(), 'array' => array('<i>'=>'<b>') );
extract( CV_OutputFilter::filter($vars)->toArray() );
?>
// access to object members
<?=$o->var?> triggers an error
<?=$o->method()?> triggers an error
<?=$o->var->htmlentities()?> works fine
<?=$o->method()->htmlentities()?> works fine
// access to array elements
<?=$array['<i>']?> triggers an error
<?=$array['<i>']->htmlentities()?> works fine
// Iterating over an array
<? foreach( $array as $value ){} ?> works fine
<? foreach( $array as $key => $value ){} ?> throws an exception, because
$key would not be filtered in this case
// decorating array keys requires some iterator magic
<? foreach( $array->key_as($key) as $value ): ?>
<?=$key->htmlentities()?>: <?=$value->htmlentities()?> <br/>
<? endforeach; ?>
Problems:
- potentially slow (due to many object instantiations and reflection)
Benefits:
- effective XSS prevention without betting on discipline
- template-engine-like variable extraction into local scope
- clean and short syntax
- very little to learn
Functionality already implemented, but not shown in the example:
- register custom filter methods
- enable __toString() with custom default filter
- use tuple array(key,value) for $value instead of 'key_as'-magic
- register custom filter applied on keys in ->toArray()
- decoration of multidimensional arrays and webs of object references
More example code:
http://code.google.com/p/cvphplib/source/browse/trunk/cvphplib/examples/exampleOutputFilter.php
http://code.google.com/p/cvphplib/source/browse/trunk/cvphplib/tests/CV/Test_OutputFilter.php
So what do you think?
Best regards
Christopher
--- End Message ---
--- Begin Message ---
Hi guys,
I need to send post variables to an ASP page. I have the following code which
isn't producing any errors but isn't working either:
foreach($_POST['newsletter-group'] as $key => $value){ $_POST['addressbookid']
= $value; $out = "POST /signup.ashx"; $fp = fsockopen("dmtrk.net", 80, $errno,
$errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else {
fputs($fp, $out . "\r\n"); } fclose($fp); }
Can anyone tell me what I am doing wrong please?
_________________________________________________________________
Get Hotmail on your mobile from Vodafone
http://clk.atdmt.com/UKM/go/107571435/direct/01/
--- End Message ---
--- Begin Message ---
[snip]
I need to send post variables to an ASP page. I have the following code
which isn't producing any errors but isn't working either:
foreach($_POST['newsletter-group'] as $key => $value){
$_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp =
fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo
"$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); }
fclose($fp); }
Can anyone tell me what I am doing wrong please?
[/snip]
http://www.php.net/curl
there was just a thread on this within the past week.
--- End Message ---
--- Begin Message ---
IIRC ASP cant recive PHP $_POST variables but it can recive HTML post
from forms.
If you want to send variables to another language. You can try via a
get variable. Dont know if the items you want to send are safe to send
over though.
Ólafur Waage
2008/8/28 shaun thornburgh <[EMAIL PROTECTED]>:
> Hi guys,
> I need to send post variables to an ASP page. I have the following code which
> isn't producing any errors but isn't working either:
>
> foreach($_POST['newsletter-group'] as $key => $value){
> $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp =
> fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr
> ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); } fclose($fp); }
>
> Can anyone tell me what I am doing wrong please?
> _________________________________________________________________
> Get Hotmail on your mobile from Vodafone
> http://clk.atdmt.com/UKM/go/107571435/direct/01/
--- End Message ---
--- Begin Message ---
> Date: Thu, 28 Aug 2008 16:21:19 -0500> From: [EMAIL PROTECTED]> To: [EMAIL
> PROTECTED]; [EMAIL PROTECTED]> Subject: RE: [PHP] Problems sending $_POST
> vairable to an ASP page> > [snip]> I need to send post variables to an ASP
> page. I have the following code> which isn't producing any errors but isn't
> working either:> > foreach($_POST['newsletter-group'] as $key => $value){>
> $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp =>
> fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo> "$errstr
> ($errno)<br />\n"; } else { fputs($fp, $out . "\r\n"); }> fclose($fp); }> >
> Can anyone tell me what I am doing wrong please?> [/snip]> >
> http://www.php.net/curl> > > there was just a thread on this within the past
> week.> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe,
> visit: http://www.php.net/unsub.php>
Hi Jay,
Unfortunately I don't have curl installed on my server.
_________________________________________________________________
Make a mini you on Windows Live Messenger!
http://clk.atdmt.com/UKM/go/107571437/direct/01/
--- End Message ---
--- Begin Message ---
[snip]
Unfortunately I don't have curl installed on my server.
[/snip]
Unless you can open a socket or a curl session you will not be able to
post values to a remote page. Curl is your best bet, can it be
installed?
--- End Message ---
--- Begin Message ---
> Date: Thu, 28 Aug 2008 16:24:58 -0500> From: [EMAIL PROTECTED]> To: [EMAIL
> PROTECTED]; [EMAIL PROTECTED]> Subject: RE: [PHP] Problems sending $_POST
> vairable to an ASP page> > [snip]> Unfortunately I don't have curl installed
> on my server.> [/snip]> > Unless you can open a socket or a curl session you
> will not be able to> post values to a remote page. Curl is your best bet, can
> it be> installed?> > -- > PHP General Mailing List (http://www.php.net/)> To
> unsubscribe, visit: http://www.php.net/unsub.php>
It appears I was wrong, I do have cURL installed!
_________________________________________________________________
Win New York holidays with Kellogg’s & Live Search
http://clk.atdmt.com/UKM/go/107571440/direct/01/
--- End Message ---
--- Begin Message ---
On 28 Aug 2008, at 22:17, shaun thornburgh wrote:
Hi guys,
I need to send post variables to an ASP page. I have the following
code which isn't producing any errors but isn't working either:
foreach($_POST['newsletter-group'] as $key => $value)
{ $_POST['addressbookid'] = $value; $out = "POST /signup.ashx"; $fp
= fsockopen("dmtrk.net", 80, $errno, $errstr, 30); if (!$fp) { echo
"$errstr ($errno)<br />\n"; } else { fputs($fp, $out . "\r
\n"); } fclose($fp); }
Can anyone tell me what I am doing wrong please?
<?php
$result = false;
// I can't see in your example where you're building the POST data,
but here's an example
$postdata = 'var='.urlencode($value);
$fp = fsockopen('dmtrk.net', 80, $errno, $errstr, 30);
if (!$fp)
{
$result = 'Connection failed: ['.$errno.'] '.$errstr;
}
else
{
fwrite($fp, "POST /signup.ashx HTTP/1.1\n");
fwrite($fp, "Connection: close\n");
fwrite($fp, "Host: dmtrk.net\n");
fwrite($fp, "Content-Length: ".strlen($postdata)."\n");
fwrite($fp, "Content-Type: application/x-www-form-urlencoded\n");
fwrite($fp, "\n".$postdata."\n");
// Get the status
$response = fgets($fp);
$result = (strpos($response, ' 200 ') !== false);
// Read the rest of the response
while (!feof($fp))
{
$response .= fgets($fp);
}
@fclose($fp);
if (!$result) $result = $response;
}
// At this point $result will either be === true or it will contain an
error message
// Please don't ask a question again without doing a reasonable amount
of research first. In this case that would be the HTTP spec and the
PHP socket function documentation. This was not difficult!
?>
-Stut
--
http://stut.net
--- End Message ---
--- Begin Message ---
Has anyone tried a ASCII Captcha method. To use a similar method like
this ASCII generator (http://www.network-science.de/ascii/)
Or even gone the next level and have an ASCII based simple math question?
I know this isnt strictly a PHP question but spam free sites are very
dear to us.
Ólafur Waage
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
At 9:27 PM +0000 8/28/08, Ólafur Waage wrote:
Has anyone tried a ASCII Captcha method. To use a similar method like
this ASCII generator (http://www.network-science.de/ascii/)
Or even gone the next level and have an ASCII based simple math question?
I know this isnt strictly a PHP question but spam free sites are very
dear to us.
Ólafur Waage
[EMAIL PROTECTED]
These are what I've come up with:
http://webbytedd.com/aa/assorted-captcha/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Auto-Deppe, C. Haensel wrote:
Hahaha.. THAT one told exactly what I feel! Thanks!!!! :o)))
Also a big thanks to the others who already replied. Waiting for more on
that.... Great one Jochem!!
If they only want a simple set of pages, then it's probably not worth the
hassle of configuring a CMS framework. The second you want to add 'customer
login' so that their clients can view private things like their log book or
next flight booking then you need a CMS with a good user management and
security system. Event diary and other automated functions then come free with
any decent framework.
With bitweaver I can add my own special functions while still retaining all of
the core functions of styling, themes, user management and security.
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
You're not really a PHP developer until you've written your own CMS from
scratch. It's a right of passage to roll your own, realize what a bad idea
it is, and move on to using a full on general CMS that will do 10x what you
can do on you own in 1/10 the effort on your parts.
My own bias is for Drupal, since that's the system I work on, but most will
work well enough depending on your needs. (Drupal will work better, though!
<g>) The bragging rights of doing it youself don't actually carry as much
weight as you'd think; the bragging rights of knowing how to leverage a
tier-one system that has major name recognition is even more valuable. The
bragging rights of being a developer on that system is even more valuable.
There's educational value to writing your own, but it will take longer and
result in fewer features than using an existing system. Most major CMSes
have tens of thousands of hours of work put into them; 60 hours won't even
get you a really good blog.
On Thursday 28 August 2008 4:17:03 am Auto-Deppe, C. Haensel wrote:
> Hi all!
>
> And again, a slightly off topic subject for you all from yours truly :o)
>
> I have a "customer" (helicopter company) who is willing to give me some
> free flights for a small website.
>
> Now, I have been talking to my sister in law who is a designer (note:
> designer, not coder). She said I should be using Joomla or something of
> that sort and change it to fit my needs.
>
> I, on the other hand, am more into using my own code, starting with the
> first "Hello World" and ending up being a full fledged CMS with just the
> functions the customer needs. I have a lot of code in my code database
> already, so it would be a lot of copy and paste and a bit of coding. I
> think the whole thing will take about 60 work hours.
>
> I am into hand coding, to be honest. Using Joomla or other CMS systems is
> fine, but I want this to be a nice point on my CV if I ever need to get a
> new job. And, most important to me, it _feels_ much better to have it done
> from scratch all by yourself, doesn't it?
>
> So, I would love to hear your opinion on this. Sorry for being a bit off
> topic here as this is not 100% coding related, but I _had_ to get some
> feedback to backup my position ;o)
>
> Cheers!
>
>
> Chris
--
Larry Garfield
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Lester Caine schreef:
Auto-Deppe, C. Haensel wrote:
Hahaha.. THAT one told exactly what I feel! Thanks!!!! :o)))
Also a big thanks to the others who already replied. Waiting for more on
that.... Great one Jochem!!
If they only want a simple set of pages, then it's probably not worth
the hassle of configuring a CMS framework. The second you want to add
'customer login' so that their clients can view private things like
their log book or next flight booking then you need a CMS with a good
user management and security system. Event diary and other automated
functions then come free with any decent framework.
ah, Lester's banging the bitweaver drum :-) ... actually I quite
like it, but then I am biased towards firebird :-)
With bitweaver I can add my own special functions while still retaining
all of the core functions of styling, themes, user management and security.
--- End Message ---
--- Begin Message ---
In writing the script, though, there are two points. I don't always use
checkboxes, sometimes I just want to update all the records on the
form. Eg I have a series of images and related text each with their ID
in the database table, on clicking update all the form elements get
submitted and I need to relate the relevant image, text, etc with the
table ID. So I can't rely on checkboxes which only get posted if
ticked. So again I have to iterate through all possible IDs. Which
normally can be done but it is longer, eg because the images on the page
in the first place may not be the result of a simple select query. So I
suppose the solution there is to have a hidden field with all the IDs as
a string, explode that and then iterate through that. Eg
<input type=hidden value="1_2_3" name="all_IDs">
$IDs=explode("_",$_POST['all_IDs']);
and that gives me the table IDs to do update queries on etc.
John
ioannes wrote:
Actually, you are right, as you just put the checkbox index in the
POST and get the value from there. So you just need the number of
checkboxes...sorry.
ioannes wrote:
Yes, Tedd, this does however incur the overhead of find out what i
is, because it could be a range of IDs from the database, not
necessarily a count of the checkboxes on the page:
"
for ($i = 1; $i <= 4; $i++)
{
$a = 'a' . $i;
$b = 'whatever' . $i;
if($_POST[$a] == 'on')
{
my_array[] = $_POST[$b]
}
}
"
John
--- End Message ---
--- Begin Message ---
That solution would probably work just nicely.
That being said however, If you want to be sophisticated about this you
would make good use of JSON and php's corresponding functions
json_decode/encode which is common way to transport arrays as strings - and
much more.
-----Original Message-----
From: ioannes [mailto:[EMAIL PROTECTED]
Sent: Friday, 29 August 2008 1:22 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Variable name as a string
In writing the script, though, there are two points. I don't always use
checkboxes, sometimes I just want to update all the records on the
form. Eg I have a series of images and related text each with their ID
in the database table, on clicking update all the form elements get
submitted and I need to relate the relevant image, text, etc with the
table ID. So I can't rely on checkboxes which only get posted if
ticked. So again I have to iterate through all possible IDs. Which
normally can be done but it is longer, eg because the images on the page
in the first place may not be the result of a simple select query. So I
suppose the solution there is to have a hidden field with all the IDs as
a string, explode that and then iterate through that. Eg
<input type=hidden value="1_2_3" name="all_IDs">
$IDs=explode("_",$_POST['all_IDs']);
and that gives me the table IDs to do update queries on etc.
John
ioannes wrote:
> Actually, you are right, as you just put the checkbox index in the
> POST and get the value from there. So you just need the number of
> checkboxes...sorry.
>
> ioannes wrote:
>> Yes, Tedd, this does however incur the overhead of find out what i
>> is, because it could be a range of IDs from the database, not
>> necessarily a count of the checkboxes on the page:
>>
>> "
>> for ($i = 1; $i <= 4; $i++)
>> {
>> $a = 'a' . $i;
>> $b = 'whatever' . $i;
>> if($_POST[$a] == 'on')
>> {
>> my_array[] = $_POST[$b]
>> }
>> }
>> "
>>
>> John
>>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello guys,
I've been stalking on the list for some time. Didn't have
anything to report/talk, until now. I have a code like this, maybe you guys
can reproduce it, with output buffering started:
Echo 'something';
Echo 'another thing';
Echo 'something <br />'\;
What happens is that ANYTHING that was echo'ed until that \,
will not reach the buffer. Although, this should actually be a Parse Error,
it isn't, it just echoes what was echoed after the god damned \. It took me
two hours to find this typo in the code .
Can you guys reproduce the error? I can actually give you a
link to the server where this code runs.
--- End Message ---