monkeybidz Posted April 28, 2011 Share Posted April 28, 2011 I have this small piece of a query, there is a var $fulltxt in it that I need to stripslashes for, how would the code look? $query1 = "SELECT distinct link_id, url, title, description, $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)"; $result = mysql_query($query1); echo mysql_error(); Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/234943-stripslashes-in-mysql-query-var/ Share on other sites More sharing options...
kenrbnsn Posted April 28, 2011 Share Posted April 28, 2011 Either <?php $query1 = "SELECT distinct link_id, url, title, description, " . stripslashes($fulltxt) . ", size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)"; $result = mysql_query($query1); echo mysql_error(); ?> or <?php $fulltxt = stripslashes($fulltxt); $query1 = "SELECT distinct link_id, url, title, description, $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)"; $result = mysql_query($query1); echo mysql_error(); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/234943-stripslashes-in-mysql-query-var/#findComment-1207399 Share on other sites More sharing options...
monkeybidz Posted April 28, 2011 Author Share Posted April 28, 2011 I had already tried both of those, but I think I am missing something or stripslashes is probably not what I need. What I am trying to do is get $fulltxt from database. The information is there via addslashes. Example, if I insert something like this to database: What's your name? It will be inserted and appear as in database : What\'s your name? Now, when I query it, it on shows as : What Seems to stop at the slash. Quote Link to comment https://forums.phpfreaks.com/topic/234943-stripslashes-in-mysql-query-var/#findComment-1207405 Share on other sites More sharing options...
kenrbnsn Posted April 28, 2011 Share Posted April 28, 2011 That's different. You need to put the column name in the select clause, not the value. Plus you shouldn't use addslashes when adding data into the database, use mysql_real_escape_string which escapes many more problematic characters. If you explain what you're trying to do with the retrieved data & how you're doing it, we can help you. Ken Quote Link to comment https://forums.phpfreaks.com/topic/234943-stripslashes-in-mysql-query-var/#findComment-1207407 Share on other sites More sharing options...
monkeybidz Posted April 28, 2011 Author Share Posted April 28, 2011 It is for links page: Example: Title, Description and Link Yoursite(Title) Yoursite is free test site. (Description) http://www.yoursite.com (Url) The description is in the database, just will not fully appear for some sites when a \ is in the description. Quote Link to comment https://forums.phpfreaks.com/topic/234943-stripslashes-in-mysql-query-var/#findComment-1207409 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.