PHP select value not saving to MySQL -


cannot figure out why below save fine on local test server, not on hosted. dollar sign value save on hosted. save fine on local.

for both have "enum('$', '€', '¥', '£')" type utf8_unicode_ci collation.

<select name="user_currency" id="user_currency">     <option value="$" <?php echo ($user_currency == '$'?'selected="selected"':'');?>>$ - dollar</option>       <option value="&euro;" <?php echo ($user_currency == '&euro;'?'selected="selected"':'');?>>&euro; - euro</option>                           <option value="&yen;" <?php echo ($user_currency == '&yen;'?'selected="selected"':'');?>>&yen; - yen</option>                      <option value="&pound;" <?php echo ($user_currency == '&pound;'?'selected="selected"':'');?>>&pound; - pound</option>                </select> 

the query:

    $query = "update users set user_currency = ".$db->prep($_post['user_currency'])." us.user_id = '{$user_id}'"; 

the prep function

function prep($value,$strip_tags = 1){         // stripslashes        if (get_magic_quotes_gpc()) {            $value = stripslashes($value);        }        // quote if not integer        if (!is_numeric($value) || $value[0] == '0') {            $value = "'" . mysql_real_escape_string($value) . "'";        }                  if($strip_tags){             $value = db::strip_html_tags($value);        }else{             $value = db::strip_html_tags($value,0);        }                   return $value; }    

any ideas?

perhaps should try changing part:

<select name="user_currency" id="user_currency">     <option value="$" <?php echo ($user_currency == '$'?'selected="selected"':'');?>>$ - dollar</option>       <option value="&euro;" <?php echo ($user_currency == '&euro;'?'selected="selected"':'');?>>&euro; - euro</option>                           <option value="&yen;" <?php echo ($user_currency == '&yen;'?'selected="selected"':'');?>>&yen; - yen</option>                      <option value="&pound;" <?php echo ($user_currency == '&pound;'?'selected="selected"':'');?>>&pound; - pound</option>                </select> 

to be:

<select name="user_currency" id="user_currency">     <option value="$" <?php echo ($user_currency == '$'?'selected="selected"':'');?>>$ - dollar</option>       <option value="&amp;euro;" <?php echo ($user_currency == '&euro;'?'selected="selected"':'');?>>&euro; - euro</option>                           <option value="&amp;yen;" <?php echo ($user_currency == '&yen;'?'selected="selected"':'');?>>&yen; - yen</option>                      <option value="&amp;pound;" <?php echo ($user_currency == '&pound;'?'selected="selected"':'');?>>&pound; - pound</option>                </select> 

otherwise browser going send actual currency characters don't match stated enums. [edit] because enums html entities. might suggest switching internally using currency codes jpy, usd, etc.?

[clarification edit: iso currency codes lot easier move around, , 3rd-party apis more use them if ever decide draw upon of currency-related resources out there. why worked locally , not on external server... php version difference in entity handling if you're using of entity functions on user input. if that's case, more reason use iso currency codes.]


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -