Jump to content

stripslashes in Mysql query var


monkeybidz

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.