elmas156 Posted March 25, 2011 Share Posted March 25, 2011 I'm having a problem that I didn't seem to have in the past... for some reason, it just popped up... or maybe I'm just noticing it. Anyway, I this in a field in a mysql database: "Here's a test." When I query the database and echo the text to the page with this code: $result = mysql_query("SELECT question FROM signin WHERE email = '$email'") or die (mysql_error()); $row = mysql_fetch_row($result); $test = $row[0]; echo $test; This is the result: "Heres a test." Any ideas on why the apostrophe is not being displayed and how to fix it? I'm stumped. Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/ Share on other sites More sharing options...
btherl Posted March 25, 2011 Share Posted March 25, 2011 What do you use to view the field in the database? Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192017 Share on other sites More sharing options...
elmas156 Posted March 25, 2011 Author Share Posted March 25, 2011 phpMyAdmin is how I view the database and its contents. Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192021 Share on other sites More sharing options...
btherl Posted March 25, 2011 Share Posted March 25, 2011 Hmm, try this code instead of the plain echo: echo urlencode($test); Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192024 Share on other sites More sharing options...
elmas156 Posted March 25, 2011 Author Share Posted March 25, 2011 No luck... still no apostrophe too Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192025 Share on other sites More sharing options...
btherl Posted March 25, 2011 Share Posted March 25, 2011 What does this show: $result = mysql_query("SELECT * FROM signin WHERE email = '" . mysql_real_escape_string("Here's a test.") . "'") or die (mysql_error()); $row = mysql_fetch_row($result); var_dump($row); Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192027 Share on other sites More sharing options...
elmas156 Posted March 25, 2011 Author Share Posted March 25, 2011 I just found the problem! I finally just broke down and rewrote the whole section of code and I realized that I was pulling info from the "signin" table when I should have been getting it from the "staff" table! Basically, I was querying the wrong information. Silly mistakes cost me so much time! Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192030 Share on other sites More sharing options...
Zane Posted March 25, 2011 Share Posted March 25, 2011 Silly mistakes cost me so much time! Thanks for your help. That should be the new motto for this place. Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192040 Share on other sites More sharing options...
elmas156 Posted March 25, 2011 Author Share Posted March 25, 2011 Haha... We all make them, some are just better at finding them than others. The ones that I hate the most are the ones where there's not really any problem in the code, so you get no errors... just the wrong output, so you're left trying to trace your steps, usually to find that the only problem was yourself! Funny how something works right when you do it right... Quote Link to comment https://forums.phpfreaks.com/topic/231653-displaying-special-character/#findComment-1192134 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.