/    Sign up×
Community /Pin to ProfileBookmark

variable changes from string to array??

Ok so I have a form that returns words and I want to put those words together in the string $querystring. Then I want to delete the last comma.

[CODE]
while(list($key, $value) = each($HTTP_POST_VARS))
{
if($key == ‘submit2’){}
else
{
$queryselect = $queryselect.$key.”, “;
}
}
//take off the last comma
$length = strlen($queryselect);
$queryselect[$length-2]=” “;
echo $queryselect;
[/CODE]

echoing $queryselect should return a long string of words for instance:
Hi, my, name, is
This all works fine and dandy..After this is done the program does this

[CODE]
echo ”
<table>
<form name = ‘IR_SELECT’ action = $PHP_SELF method = ‘get’>”;
while($row = pg_fetch_row($result))
{
if($count%4==0)
{
echo”<tr>”;
}

echo”<td><input type=checkbox name = $row[1]>$row[0]<br></td>”;
$count++;
}

echo”
<tr>
<input type = ‘hidden’ name = ‘queryselect’ value = $queryselect>
<td><input type=’submit’ value=’submit’ name =’submit’></td>

</tr>
</form>
</table>”;
[/CODE]

As soon as I hit submit something happens to the string $queryselect. When I echo it out it only returns ‘Hi’. I think it turns it into an array. Why is it doing this?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 22.2005 — I don't think that it's being changed to an array, but frankly I'm not entirely sure what you're trying to do and thus having a little trouble analyzing the provided code snippets out of context.
Copy linkTweet thisAlerts:
@CrushinauthorJul 25.2005 — OK...let me explain a little better what I'm trying to do. I think most of that code is not needed to explain what is happening. But I have this value $queryselect. It Looks like this: Hi, my, name, is. It returns some characters followed by a comma and then a space.

The values in $queryselect will be the columns in the next Select statement from my database. But when I am choosing more conditions via the next form..I hit submit and the $queryselect returns only the first word in $queryselect. Once it sees a space it deletes that information out of $queryselect. I don't really understand what is going on.
Copy linkTweet thisAlerts:
@CompGeek01Jul 25.2005 — <i>
</i>&lt;input type = 'hidden' name = 'queryselect' value = $queryselect&gt;

&lt;!-- You might try... --&gt;

&lt;input type = 'hidden' name = 'queryselect' value ="$queryselect"&gt;


I think the issue is the HTML. You'll need to make sure the values are quoted or commas/spaces WILL mess up your results.
×

Success!

Help @Crushin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.11,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...