Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 4:22 PM   #1
Andy Hall
 
Andy Hall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

Hi,

I am just starting up with PHP (although I am trained in ColdFusion) and am
having problems with the following code:

$collist = "test1, test2, test3, test4";

$aColumns = explode(",",$collist);
$aValues = array();

while (list($idx, $value) = each($aColumns))
{
print("IDX: $idx; VALUE: $value; Field: ".$HTTP_POST_VARS[$value]."<br>");
}

My main plan was to loop through a list of hardcoded columns passed to the
function and retrieve the values from the posted form fields that match the
column name. This might seem a little odd, but it fits in well with out
application.#

The problem is that even though form is being posted with the correct field
names, the $HTTP_POST_VARS[$value] line is coming back with an empty string.

I have tried:
$HTTP_POST_VARS["$value"]
$HTTP_POST_VARS[($value)]
$HTTP_POST_VARS[$value]

Can anyone tell me what I am doing wrong?

Thanks very much

Andy Hall.


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 4:22 PM   #2
Andy Hall
 
Andy Hall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

> Hi,
>

<snip>
>
> I have tried:
> $HTTP_POST_VARS["$value"]
> $HTTP_POST_VARS[($value)]
> $HTTP_POST_VARS[$value]
>
>


I have also now tried ${"HTTP_POST_VARS".$value} which I found on a PHP
array help page, but to no avail.

Any other ideas greatly appreciated...



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:22 PM   #3
Warstar
 
Warstar's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

did u try
$_POST[$value]


On Mon, 11 Aug 2003 10:34:04 +0000 (UTC), "Andy Hall"
<andy@jaar.co.uk> wrote:

>> Hi,
>>

><snip>
>>
>> I have tried:
>> $HTTP_POST_VARS["$value"]
>> $HTTP_POST_VARS[($value)]
>> $HTTP_POST_VARS[$value]
>>
>>

>
>I have also now tried ${"HTTP_POST_VARS".$value} which I found on a PHP
>array help page, but to no avail.
>
>Any other ideas greatly appreciated...
>
>


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:22 PM   #4
Andy Hall
 
Andy Hall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

Thats seems to have worked for the first array element, but the rest are
blank.

Still, I have something to pursue now - thanks for your help.

Andy.


"Warstar" <warstar@NSA.com> wrote in message
news:hjsejv8kf3vp7cf7f76ttq0e3ab83ch0ti@4ax.com...
> did u try
> $_POST[$value]
>
>
> On Mon, 11 Aug 2003 10:34:04 +0000 (UTC), "Andy Hall"
> <andy@jaar.co.uk> wrote:
>
> >> Hi,
> >>

> ><snip>
> >>
> >> I have tried:
> >> $HTTP_POST_VARS["$value"]
> >> $HTTP_POST_VARS[($value)]
> >> $HTTP_POST_VARS[$value]
> >>
> >>

> >
> >I have also now tried ${"HTTP_POST_VARS".$value} which I found on a PHP
> >array help page, but to no avail.
> >
> >Any other ideas greatly appreciated...
> >
> >

>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:22 PM   #5
pprince
 
pprince's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables


if your on PHP ver 4.1.0+ I'd use $_POST["value"];

I believe HTTP_POST_VARS is being deprecated.

Call your array item variable something different to $value. Your asking
for a field called test1, test2 etc from the form by calling them the
same, which doesn't exist, hence a blank field.......I think! :-)
array item variable name doesn't matter what it is.

Regards

Paul

--
Posted via http://dbforums.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 4:22 PM   #6
Andy Hall
 
Andy Hall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

thanks for the help.

It is now working for the first array element but no further. The code:

$collist = "test1, test2, test3, test4";

$aColumns = explode(",",$collist);
$aValues = array();

while (list($fieldidx, $fieldv) = each($aColumns))
{
print("IDX: $fieldidx; VALUE: $fieldv; Field: " . $_POST[$fieldv] .
"<br>");
}

is outputting:

IDX: 0; VALUE: test4; Field: 4
IDX: 1; VALUE: test3; Field:
IDX: 2; VALUE: test2; Field:
IDX: 3; VALUE: test1; Field:

4 is the correct value for the test4 field but the others are blank.

If I switch the order of collist the first one always is correct but the
rest are blank.

Is there something else stupid I am doing. I have looked on the net but I am
under pressure not to spend to long on this as I could always hardcode my
queries. but, being a fool, I want to create reusable code!!

Thanks for your help

Andy.


"pprince" <member29867@dbforums.com> wrote in message
news:3224167.1060599668@dbforums.com...
>
> if your on PHP ver 4.1.0+ I'd use $_POST["value"];
>
> I believe HTTP_POST_VARS is being deprecated.
>
> Call your array item variable something different to $value. Your asking
> for a field called test1, test2 etc from the form by calling them the
> same, which doesn't exist, hence a blank field.......I think! :-)
> array item variable name doesn't matter what it is.
>
> Regards
>
> Paul
>
> --
> Posted via http://dbforums.com



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:03 PM   #7
pprince
 
pprince's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables


whats the form code ?

your asking for the values of form fields test1, test2, test3 & test4,
do these form fields exist?

what type? if they're checkboxes for example they won't get posted.

--
Posted via http://dbforums.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:03 PM   #8
Ian.H [dS]
 
Ian.H [dS]'s Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Mon, 11 Aug 2003 14:08:12 +0000, pprince
<member29867@dbforums.com> amazingly managed to produce the following
with their Etch-A-Sketch:

> if they're checkboxes for example they won't get posted.



Huh? why not? I happily use checkboxes on forms and receive data with
them. Mighty handy they are too! =)



Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPzeroWfqtj251CDhEQL3WwCg9ZaMGg1jzU7mAu+sfAgwEm duKhwAoP3X
MsMb16h3MmtGOxqH1wD1xrCi
=kwZ8
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:03 PM   #9
Andy Hall
 
Andy Hall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables

Thanks for the idea, but I am aware that a unchecked checkbox does not get
posted.

I am posting a form with the 4 text fields test1, test2, test3, test4.

I have looped through _POST and outputted all the fields and values, but
when it comes to dynamically generating the variable name in my loop
everything is falling flat on its face.

Thanks for the ideas though...





"Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote in message
news:mrafjvc7n0i009hnbir3entrujmfi41s68@4ax.com...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Whilst lounging around on Mon, 11 Aug 2003 14:08:12 +0000, pprince
> <member29867@dbforums.com> amazingly managed to produce the following
> with their Etch-A-Sketch:
>
> > if they're checkboxes for example they won't get posted.

>
>
> Huh? why not? I happily use checkboxes on forms and receive data with
> them. Mighty handy they are too! =)
>
>
>
> Regards,
>
> Ian
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 8.0
>
> iQA/AwUBPzeroWfqtj251CDhEQL3WwCg9ZaMGg1jzU7mAu+sfAgwEm duKhwAoP3X
> MsMb16h3MmtGOxqH1wD1xrCi
> =kwZ8
> -----END PGP SIGNATURE-----
>
> --
> Ian.H [Design & Development]
> digiServ Network - Web solutions
> www.digiserv.net | irc.digiserv.net | forum.digiserv.net
> Programming, Web design, development & hosting.



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:03 PM   #10
pprince
 
pprince's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Dynamic variables


Man its so obvious sometimes!!!
you need to trim the leading space in $collist for test2, 3 & 4.
I've just added a trim to the $_POST expression. Does work as I've
tested it. Thats why test1 was ok and not for the other 3.

$collist = "test1, test2, test3, test4";

$aColumns = explode(",",$collist);
$aValues = array();

while (list($fieldidx, $fieldv) = each($aColumns))
{
print("IDX: $fieldidx; VALUE: $fieldv; Field: " .
$_POST[trim($fieldv)] .
"<br>");
}

Regards

--
Posted via http://dbforums.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Shopping Cart Software Barrie Tingle PHP 0 07-01-2007 3:19 PM
Dynamic Creation of Rows Mr. Clean PHP 4 07-01-2007 3:18 PM
Dynamic Solutions for Dynamic URLs on Data Driven Sites hirenseo HTML 4 07-31-2006 12:27 AM
Dynamic Web Design:: PHP Vs ASP: colin Website Coding 0 07-30-2006 5:52 PM


Featured Websites




All times are GMT +1. The time now is 12:36 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98