The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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? |
#2
|
|||
|
|||
$_POST[name$i] won't work.. try this way: $_POST['name'.$i]
|
#3
|
|||
|
|||
$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 |
#4
|
|||
|
|||
Change to:
PHP Code:
|
#5
|
||||
|
||||
You need to escape the input first to avoid SQL injections.
|
#6
|
||||
|
||||
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:
|
#7
|
|||
|
|||
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
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|