![]() |
How do I loop inside of varibale names?
I have some posts variables that would be like this
$_POST[name1] $_POST[name2] $_POST[name3] $_POST[name4] $_POST[name5] $_POST[name6] $_POST[name7] $_POST[name8] $_POST[name9] I want to loop through them. I will alays know how many there will be. I was trying to do something like $_POST[name$i] then increment through. But that won't work. What do I need to do? |
$_POST[name$i] won't work.. try this way: $_POST['name'.$i]
|
$sql = "UPDATE user SET username = \"$_POST['username'.$i]\", access = \"$_POST['access'.$i]\", owner= \"$_POST['owner'.$i]\" WHERE id= \"$_POST['userid'.$i]\"";
I tried that and got this error Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING the error is on that line for sure |
Change to:
PHP Code:
|
You need to escape the input first to avoid SQL injections.
|
on a side note... at the very LEAST you should be running them through addslahes() if not $db->escape_string() (which is better).
Otherwise you have a gargantuan security hole there. Your best bet is something like this (assuming its vb integrated) PHP Code:
Code:
<input type="text" name="name[1]" value="" /> PHP Code:
|
Ya, Iw ould have done this differently if I was doing it from the beginning. But I am finishing something someone else started. I figured it out withyour guys help. Thanks
|
All times are GMT. The time now is 03:46 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|