Click to See Complete Forum and Search --> : variable changes from string to array??


Crushin
07-22-2005, 05:06 PM
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.


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;

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

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>";


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?

NogDog
07-22-2005, 05:19 PM
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.

Crushin
07-25-2005, 10:42 AM
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.

CompGeek01
07-25-2005, 11:21 AM
<input type = 'hidden' name = 'queryselect' value = $queryselect>

<!-- You might try... -->

<input type = 'hidden' name = 'queryselect' value =\"$queryselect\">

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.