Solved

Input/Output MySQL problem

Posted on 2007-03-27
5
251 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
ID: 18804456
try echo "<input type='text' value='".stripslashes($row["name"])."'>";
0
 
LVL 14

Assisted Solution

by:Vel Eous
Vel Eous earned 250 total points
ID: 18804606
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:Vel Eous
ID: 18804610
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
ID: 18809017
That worked. Thank you very much.
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 18809036
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

810 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