You are here: Re: [PHP] Variables and Strings « PHP « IT news, forums, messages
Re: [PHP] Variables and Strings

Posted by Jochem Maas on 12/29/05 11:23

PHP Superman wrote:
> Hey everyone, is there a way to return all the variables from a string into
> an array, for example
> $Var1="Yo";
> $Var2="Man";
> $SQL="SELECT * FROM tblname WHERE 4=$Var1 AND WHERE 3=$Var2";
> $AllVars=MySpecialFunction($SQL);

your function MySpecialFunction() will recieve the following string:

"SELECT * FROM tblname WHERE 4=Yo AND WHERE 3=Man"

which apart from being (probably) incorrect SQL, is just a string -
how is your special function supposed to tell which chars are part of
the previously injected variables' values - and even more impossible:
how would the function find out what those variables we're called to
begin with (it can't).

what is it you would like to achieve?

rgds,
jochem

PS - learn to walk before you fly ;-)

> print_r($AllVars);
>
> would ideally print an array like:
> {
> array
> $Var1="Yo"
> $Var2="Man"
>
> }
> i think i should use an ereg or preg replace but I don't know much about
> them or how to use them, thanks in advance
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация