tags:

views:

35

answers:

1

Using PHP I'm populating a dropdown list with values taken from a MySQL database. The list displays fine, my problem comes when I try to retrieve the selected value. I'm defining a variable and passing it the dropdownlist name for the POST array:

$variable = $_POST['dropdownlist'];

but the contents of $variable are \{value}"

Why is it putting in the \{ and }", and how do I get rid of them to get a value I can actually use?

+1  A: 

If you are getting curly brackets as part of the value then the chances are they are their in your HTML code. Your code is likely something like echo '{$value}'; rather than echo "{$value}"; or something similar.

Cags
Was using echo $value without any curly brackets or quotes
Chelle
In which case how did the information get into the database? Are they present if viewing the database via phpMyAdmin? Click view source in your browser, and show us what the HTML looks like, it's extremely likely that they are present there.
Cags
Data fine in the database, but think I've found the bug. I'd used a function from a book to populate all the select lists, and part of its code was:print "\n\t<option value ="\{$result}\">{$result}"; I've changed it and it looks OK in the source view now, so I'll try pulling the values out to see if that's the problem sorted. Thanks for you help.
Chelle