RE: [PHP] Further help for PHP, SQL syntax, and register_globals
| From: | Ford, Mike | Date: | Tue, 26 Oct 2004 12:20:40 +0000 |
| Subject: | RE: [PHP] Further help for PHP, SQL syntax, and register_globals | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-200335@lists.php.net to get a copy of this message | ||
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 26 October 2004 12:01, John Holmes wrote:
> Sugimoto wrote:
> > Bad query: You have an error in your SQL syntax near 'and Tit like
> > and Aut like and Auty like ' at line 4
> [snip]
> > foreach ($_GET as $value) {
> > if (empty($value)) $value = "%";
>
> You have an issue here. You're looping through $_GET and attempting to
> set a default value (which is good), but you're not making
> any changes
> to $_GET at all, just resetting the same $value variable to '%'.
>
> foreach($_GET as $key=>$value)
> {
> if(empty($value))
> { $_GET[$key] = '%'; }
> }
Or, if I've been paying attention properly (which I might easily not have!
;), in PHP 5 you can do:
foreach ($_GET as &$value) {
if (empty($value)) $value = "%";
}
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211