Solved

Input/Output MySQL problem

Posted on 2007-03-27
5
231 Views
Last Modified: 2007-03-28
Hi guys,

I'm storing values in mysql database like this:

mysql_query("UPDATE galleriesList SET name = '".mysql_real_escape_string($galleryspecs[$j][1])."'  WHERE id = '".$galleryspecs[$j][0]."'") or die(mysql_error());

So for example if I put in Te'st it shows up in database as Te\'st. Then I get value from database and put it in input:

echo "<input type='text' value='".$row["name"]."'>";

I want to get Te'st in input but all I get is just Te\
What can be the problem? Thank you.
0
Comment
Question by:RealSnaD
  • 2
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
steelseth12 earned 250 total points
Comment Utility
try echo "<input type='text' value='".stripslashes($row["name"])."'>";
0
 
LVL 14

Assisted Solution

by:Tchuki
Tchuki earned 250 total points
Comment Utility
It appears to have something to do with the single apostraphie.

if you place similar code inside:

<html>
<input type="text" value="<?PHP echo stripslashes("it\'s a winner"); ?>" />
</html>

You get "it's a winner", yet if you use single quote:

<html>
<input type="text" value="<?PHP echo stripslashes('it\'s a winner'); ?>" />
</html>

You get "it".

My suggestion is perhaps just use standard HTML for your form.
0
 
LVL 14

Expert Comment

by:Tchuki
Comment Utility
Woops,

<input type="text" value="<?PHP echo stripslashes('it\'s a winner'); ?>" />

should be

<input type="text" value='<?PHP echo stripslashes("it\'s a winner"); ?>' />

in the above example
0
 
LVL 7

Author Comment

by:RealSnaD
Comment Utility
That worked. Thank you very much.
0
 
LVL 7

Author Comment

by:RealSnaD
Comment Utility
I'm going to split points because just stripslashes wouldn't do me any good. I had to replace single quotes to make it work.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now