Scooby08 Posted August 17, 2008 Share Posted August 17, 2008 I know this is pretty elementary, but I cannot find a straight answer as to how to retrieve data from that database that has double quotes.. This line is in my table: hello "Kyle" I can insert into the database, but cannot retrieve it?? What am I missing?? Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2008 Share Posted August 17, 2008 What is happening when you do this (mind reading does not work over the Internet)? We cannot help you unless you tell us or show us what "cannot retrieve it??" means. Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618290 Share on other sites More sharing options...
Scooby08 Posted August 17, 2008 Author Share Posted August 17, 2008 here is my select.. <?php $query = "SELECT * "; $query .= "FROM dw_company "; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $hello = $row['hello']; } echo $hello; ?> should be selecting and displaying this text: hello "Kyle" This is what I see in my field: hello \ Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618293 Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2008 Share Posted August 17, 2008 fieldDoes that mean a form field? If so, then take a look at this link on how to output characters that have special meaning in HTML - http://www.php.net/manual/en/function.htmlentities.php Edit: Also magic_quotes_runtime is turned on and is escaping the data being retrieved from your database. I recommend turning the magic_quotes_runtime setting off as it has been completely removed in upcoming php6. Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618295 Share on other sites More sharing options...
Scooby08 Posted August 17, 2008 Author Share Posted August 17, 2008 Hey thanks.. I think I found a solution.. Do you see any problems with this?? <?php $query = "SELECT * "; $query .= "FROM dw_company "; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $hello = htmlentities($row['hello']); } echo $hello; ?> Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618300 Share on other sites More sharing options...
chronister Posted August 17, 2008 Share Posted August 17, 2008 It looks to be correct, does it work? Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618306 Share on other sites More sharing options...
Scooby08 Posted August 17, 2008 Author Share Posted August 17, 2008 It definitely works.. I was just curios if anybody saw any problems with doing it like that.. I'm just working on my first database project so I'm just trying to take in as much input as possible from all you pro's out there.. haha Thanks a bunch!! Quote Link to comment https://forums.phpfreaks.com/topic/120026-solved-database-double-quotes/#findComment-618311 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.