php-general Digest 12 Apr 2009 13:33:02 -0000 Issue 6063

Topics (messages 291372 through 291383):

$_GET
        291372 by: Ron Piggott
        291376 by: Mark Kelly

Re: Additional support for your family!
        291373 by: 9el
        291374 by: Daniel Brown

Re: Escape Data In/Out of db [solved]
        291375 by: Shawn McKenzie
        291378 by: Shawn McKenzie

Re: How about a saveXHTML for the DOM?
        291377 by: Raymond Irving
        291380 by: Michael A. Peters
        291381 by: Michael A. Peters

pear mdb2 and null
        291379 by: Michael A. Peters
        291383 by: Phpster

Re: Problems with exec() on windows
        291382 by: henrikolsen.gmail.com

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 am moving my web site to a new host this weekend.  I am working
towards making the code compatible to the structure of the new server.

I am getting a weird response which I don't understand

At the very start of my index.php I have the following lines of code:

foreach($_GET as $key => $val) {
$$key = $_GET[$val];
echo $_GET[$val] . "<br />";
}

What I don't understand is why the output is

<br /><br />

I am not understanding how two "empty" variables are being passed.

index.php is driven off of various mod re-writes contained
within .htaccess .  This is why I am doing the loop above.

RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^page/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&field1=$2 [L]
RewriteRule ^page/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=
$1&field1=$2&field2=$3 [L]

What should I be trying?  What will allow the value of page to be passed
onto $page with the following URL:

http://www.actsministrieschristianevangelism.org/page/home_page/ 

--- End Message ---
--- Begin Message ---
Hi.

On Sunday 12 April 2009, Ron Piggott wrote:
> At the very start of my index.php I have the following lines of code:
>
> foreach($_GET as $key => $val) {
> $$key = $_GET[$val];
> echo $_GET[$val] . "<br />";
> }

Try:

echo $_GET[$key] . "<br />";

HTH

Mark

--- End Message ---
--- Begin Message ---
2009/4/12 Forest Bennett <[email protected]>

> Good day, Dear Mr. or Ms!
>
> Are you in need for money but you don't have the time and nerve for a
> secondary job? Here is your chance to be part of a program that is taking
> traditional marketing research in a brand new direction, with the ease of
> the Internet technologies!
>
> Our participants are always rewarded for their precious opinion.
>
> Here is what amounts you can earn:
>
> - From $5 to $100 per online survey
> - From $50 to $200 for an online focus group discussion
> - From $30 to $120 per product and service evaluation
>
> Please excuse us if this letter is unwanted for you or we have disturbed
> you in some way, but this inquiry is serious and sincere!
>
> Please reply to [email protected] for further information. Join
> us now because the places are limited!
>
> Best regards,
> Consumer Opinion Administration
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------
> This email has been written and proved to be in compliance with the
> recently established can-spam act law in US. We are not provoking or forcing
> any person in any way to participate in our programs. To participate is your
> own decision and you carry the responsibility of taking further part in this
> promotion. Anyway, if you don't want to receive more good offers from us,
> you can simply Unsubscribe by sending us a notification email to
> [email protected] with a mail-subject and text "Unsubscribe me",
> and we will get your email out of our list within 10 days.
>
> This message is STRICTLY CONFIDENTIAL and is solely for the individual or
> organisation to whom it is addressed. It may contain PRIVILEGED and
> CONFIDENTIAL information. If you are not the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication and its contents is strictly prohibited. If you are not the
> intended recipient you should not read, copy, distribute, disclose or
> otherwise use the information in this email. Email may be susceptible to
> data corruption, interception and unauthorised amendment, and we do not
> accept liability for any such corruption, interception or amendment or the
> consequences thereof or your reliance on any information contained therein
> if you are not the intended recipient. If you are not interested in the
> offered promotions, please just don't answer. If you think you have received
> this message and its contents in error, please delete it from your computer,
> or follow the unsubscribing procedure shown above.
> ------------------------------------------------------------------
>

Ah! could you just pay in my paypal? bluh!

--- End Message ---
--- Begin Message ---
On Sat, Apr 11, 2009 at 19:29, 9el <[email protected]> wrote:
>
> Ah! could you just pay in my paypal? bluh!

    For future reference, the general practice on the list is not even
to acknowledge the email.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
tedd wrote:
>> I think you want to look for magic_quotes_gpc
>>
>>
>> -- 
>> Thanks!
>> -Shawn
>
>
> -Shawn:
>
> You were right.
>
> I'll fix it.
>
> Thanks,
>
> tedd

I normally have a prep4display() and prep4store() type function that do
all of the sensitization/prep for either storing or displaying.  So
prep4display() has a check for magic_quotes_gpc for which it does
stripslashes() if they are on and then htmlentities() etc.. and the
prep4store() can do mysql_real_escape_string() and whatever else.

-Shawn

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
> tedd wrote:
>>> I think you want to look for magic_quotes_gpc
>>>
>>>
>>> -- 
>>> Thanks!
>>> -Shawn
>>
>> -Shawn:
>>
>> You were right.
>>
>> I'll fix it.
>>
>> Thanks,
>>
>> tedd
> 
> I normally have a prep4display() and prep4store() type function that do
> all of the sensitization/prep for either storing or displaying.  So
> prep4display() has a check for magic_quotes_gpc for which it does
> stripslashes() if they are on and then htmlentities() etc.. and the
> prep4store() can do mysql_real_escape_string() and whatever else.
> 
> -Shawn

Well, since this last post didn't make a whole lot of sense I thought
I'd clarify and add a little.  So I use the prep4display() in an echo or
when building display output and prep4store() in a query etc.

The addition that I find useful sometimes are clean_from_input() and
clean_for_output() type functions which may use the aforementioned ones.
clean_from_input() you can call like  clean_from_input('some_getvar')
and it will check to see if the $_GET var (or more generally $_REQUEST
or $_GET || $_POST) is set and return after stripping slashes if
magic_quotes_gpc is set and whatever else.  Then the clean_for_output()
does some stuff for output when you need it.  My point is that if you
build a function to retrieve get/post/cookie vars etc, then you can
clean it however you want and also build in the isset() stuff there so
it returns '' or false, etc... and you don't have all kinds of isset()
or !empty() calls in your main code.

So build some general purpose functions or methods that scrub input and
prep output and try and get it to handle as many cases as possible.
Then use those functions.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---

If I remove the \r from the file using preg_replace() then it shows up just 
fine. I was just wondering if there was a way to suppress the \r in the xml 
output.

Another thing that I've observed while looking at your code is that it only 
works best for dynamic web pages. It appears that it would not work well when 
using page caching or page templates.

I really think having a function that generates xhtml (html compatible) output, 
would really eliminate all these workarounds that we will have to do in order 
to get the page to render inside popular web browsers.

A lot of developers produce xhtml web pages that are html 4 compatible, so that 
they can be rendered in browsers that only supports html rendering. This is 
something that I think the PHP DOM should be able to support with ease.



Best regards,
__
Raymond Irving



--- On Fri, 4/10/09, Michael A. Peters <[email protected]> wrote:

> From: Michael A. Peters <[email protected]>
> Subject: Re: [PHP] How about a saveXHTML for the DOM?
> To: "Raymond Irving" <[email protected]>
> Cc: "[email protected]" <[email protected]>
> Date: Friday, April 10, 2009, 6:35 PM
> Raymond Irving wrote:
> > 
> > Thanks for the feedback Michael. I will look into your
> suggesstions.
> > 
> > Is there an option on the DOMDocument that we can set
> to not have saveXML() append 
 to the end of the tags?
> > 
> > This is normally the case if the html content was
> loaded using loadHTMLFile()
> 
> I think I've seen that appear in textarea as well - I
> believe it has to do with the libebreaks of the application
> that created the file (or in case of textarea from a form,
> the line break convention of the browser).
> 
> Does it happen when you run
> 
> sed -i 's/\r//g' file.html
> 
> to remove the DOS carriage return from the line breaks?
> 
> That would be my guess.
> 
> -- PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
Raymond Irving wrote:

If I remove the \r from the file using preg_replace() then it shows up just 
fine. I was just wondering if there was a way to suppress the \r in the xml 
output.

Another thing that I've observed while looking at your code is that it only 
works best for dynamic web pages. It appears that it would not work well when 
using page caching or page templates.

I really think having a function that generates xhtml (html compatible) output, 
would really eliminate all these workarounds that we will have to do in order 
to get the page to render inside popular web browsers.

A lot of developers produce xhtml web pages that are html 4 compatible, so that 
they can be rendered in browsers that only supports html rendering. This is 
something that I think the PHP DOM should be able to support with ease.



If you want to send the same page for everybody than use html 4.01 (or html 5 when it is ready) and the saveHTML() function.

The only reason I don't do that is because I wish html would go away, so I generally send valid xhtml (header and all) and only provide the html as a fall back for inferior browsers.

With respect to templating systems, I don't use them but if you have a DOMDocument orientated template system, I don't see why it couldn't do the same thing - as far as the DOM used to generate xhtml (via saveXML()) or html (via saveHTML()) - the only difference is the DTD and the fact that xhtml sometimes uses namespaced attributes (which may get stripped with saveHTML() anyway)

That's the beauty IMHO of DOMDocument - virtually identical data in the DOM can produce valid html or xhtml - as long as you aren't using xhtml only extensions (like MathML).

So it should work beautifully with a templating system, as long as the templating system is built for DOMDocument consumption.

I think there are a few.

How well they work with caching I don't know.

--- End Message ---
--- Begin Message ---
Michael A. Peters wrote:


With respect to templating systems, I don't use them but if you have a DOMDocument orientated template system, I don't see why it couldn't do the same thing -

As an experiment, I took one of my pages that was a little sluggish due to lots of database calls (sluggish on my home machine anyway) - since the database content rarely changes for the data presented, I made a page I can grab nightly in cron that spits out just the main content div where all the DB calls are made.

-=-
$cached = 'species_cache.php';
$SL = file_get_contents($cached);
$SDOM = new DOMDocument("1.0","UTF-8");
$SDOM->loadXML($SL);
$elements = $SDOM->getElementsByTagName("div");
$imported_div = $elements->item(0);
$contentDiv = $myxhtml->importNode($imported_div,true);
-=-

species_cache.php

is just a text file with a div and all it's children.

Sped up the page considerably on my home machine, and works spledidly regardless of whether or not I am sending it as html or xhtml.

So I think my technique would work with template systems.

--- End Message ---
--- Begin Message ---
I've run into a small issue with mdb2.

I have a mysql database with a field set to longtext not null.

inserting "" into that field works just dandy when using the mysql_ functions.

However, when using mdb2 - it converts "" to NULL which is NOT what I want to have happen, and the result is that the execute() fails because the database table does not accept NULL for that field.

Why does mdb2 turn "" into NULL for a text type when MySQL knows there is a difference? How do I suppress that?
--- End Message ---
--- Begin Message ---


On Apr 11, 2009, at 21:38, "Michael A. Peters" <[email protected]> wrote:

I've run into a small issue with mdb2.

I have a mysql database with a field set to longtext not null.

inserting "" into that field works just dandy when using the mysql_ functions.

However, when using mdb2 - it converts "" to NULL which is NOT what I want to have happen, and the result is that the execute() fails because the database table does not accept NULL for that field.

Why does mdb2 turn "" into NULL for a text type when MySQL knows there is a difference? How do I suppress that?

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


Why not set a default in the field then, as am empty string and let the db handle field properly? Having a Not Null with no default is bad db design.

Bastien
--- End Message ---
--- Begin Message ---
I can confirm the presence of the same issue on my installation, 5.2.9-2 on 
Windows XP. Very annoying bug.

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/11719414.html

--- End Message ---

Reply via email to