Re: Re: Declare variables in advance question
| From: | shiplu | Date: | Tue, 21 Aug 2007 08:53:04 +0000 |
| Subject: | Re: Re: Declare variables in advance question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261075@lists.php.net to get a copy of this message | ||
use
#php -s
command to indend your source file
On 8/21/07, Colin Guthrie <gmane@colin.guthr.ie> wrote:
> nitrox . wrote:
> > I want to declare these variables Game_id and Member_id in advance. Following the
> > suggestionfrom one of my books can I do something like this:
> >
> > $expected = array('Game_id', 'Member_id');foreach($expected AS $key) {
> > if ( !empty($_POST[$key])) { ${$key} = $_POST[$key]; } else { ${$key} = NULL;
> > }} case "addmember": switch ($_GET['type']) { case
> > "membergame": $sql = "INSERT INTO xsm_membergames
> > (Game_id, Member_id) VALUES ('" .
> > mysql_real_escape_string((int)$_POST["Game_id"])) . "',
> > '" . mysql_real_escape_string((int)$_POST["Member_id"])) . "')";
> > break; } break;
> > My concern is did I achieve anything with the code I just added to declare the variables?
> > Is it actually being passed to this: case "addmember": switch
> > ($_GET['type']) { case "membergame": $sql = "INSERT INTO
> > xsm_membergames (Game_id, Member_id) VALUES
> > ('" . mysql_real_escape_string((int)$_POST["Game_id"]) .
> > "', '" .
> > mysql_real_escape_string((int)$_POST["Member_id"]) . "')"; break;
> > } break;
> > I did add this and tested it on my server and I didnt recieve any errors. So how can I be
> > sure its doing what I intended?
> > _________________________________________________________________
> > See what you're getting into…before you go there
> >
> > http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507
>
>
> Your code is not formatted very nicly in your mail which makes it very
> hard to read, but it's also invalid. There is a case statement in there
> without a switch to control it.... twice.
>
> Col
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
shout at http://shiplu.awardspace.com/
Available for Hire/Contract/Full Time