This is a discussion on PHP/Mysql/special characters problem within the PHP Language forums, part of the PHP Programming Forums category; "Mosher" <mosh_king2000@yahoo.com> wrote in news:9NqdnaqolKxu6mSi4p2dnA@comcast.com: > Hi Ken, > > Thanks ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"Mosher" <mosh_king2000@yahoo.com> wrote in
news:9NqdnaqolKxu6mSi4p2dnA@comcast.com: > Hi Ken, > > Thanks for this, but it did not work. Once again (prior to your code), > the data gets written to the db just fine, quotes and all. But when I > call it back up to edit it, that is where the problem is. First, the > field data: > > O'Leary "special" > > ...only displayed O'Leary when called back up. I then was able to get > around that by the following line of code: > > <input type=text name=description value="<? echo > htmlentities($row[description])?>"> > > This did display the full data above with quotes, etc. But when I look > in the actual source code of the webpage being displayed, it shows: > > O'Leary"special" > > ...in the field and when I try to write to db, it only writes: > I've had similar problems. It's in the DB with the quotes and I used to run around in circles trying to get it back in after displaying it on a form and getting the value back. That's why I've started to store the urlencoded format in the database. So you would do: <input type=text name=description value="<? echo urldecode($row [description])?>"> in your form. In your database update command use something like: "update .... set description='".urlencode(stripslashes($_POST['description']))."'..." You might have to write a one-time job to update all the text fields in your database to conform to the new method or you can just implement it and each field will be updated as time goes on. Ken |
|
|||
|
> This did display the full data above with quotes, etc. But when I look in
> the actual source code of the webpage being displayed, it shows: > > O'Leary"special" > > ...in the field and when I try to write to db, it only writes: > > O'Leary > > Any other ideas? after form submission, i use $_POST['var'] = mysql_escape_string(stripslashes($_POST['var'])); before submitting $_POST['var'] to my database. maybe you can also echo $_POST['var'] after you submit the form to check what is in it. if you use the GET method, the " entity may cause problems as all variables are transmitted like http://php.net/script.php?var1=foo&v...;problem" if this is the case, maybe just try the POST method instead? good luck steven. |
|
|||
|
Ken - the whole thing works now! But the problem was caused by another
issue. I believe that there was another query writing the data to db (so it was getting written twice) and due to this, there was the problem - one query was correct and the other wasn't. I removed the latter query and now it is working. It had me totally stumped because this hasn't been too much of an issue for me before. Anyway, thanks much for the advice. Perhaps I'll try your ideas next time. Later, Mosher "Ken Robinson" <sendspamhere@rbnsn.com> wrote in message news:70499a4b13da5b8d11ff30ca436b1de6@news.teranew s.com... > "Mosher" <mosh_king2000@yahoo.com> wrote in > news:9NqdnaqolKxu6mSi4p2dnA@comcast.com: > > > Hi Ken, > > > > Thanks for this, but it did not work. Once again (prior to your code), > > the data gets written to the db just fine, quotes and all. But when I > > call it back up to edit it, that is where the problem is. First, the > > field data: > > > > O'Leary "special" > > > > ...only displayed O'Leary when called back up. I then was able to get > > around that by the following line of code: > > > > <input type=text name=description value="<? echo > > htmlentities($row[description])?>"> > > > > This did display the full data above with quotes, etc. But when I look > > in the actual source code of the webpage being displayed, it shows: > > > > O'Leary"special" > > > > ...in the field and when I try to write to db, it only writes: > > > > I've had similar problems. It's in the DB with the quotes and I used to > run around in circles trying to get it back in after displaying it on a > form and getting the value back. That's why I've started to store the > urlencoded format in the database. > > So you would do: > <input type=text name=description value="<? echo urldecode($row > [description])?>"> > in your form. > > In your database update command use something like: "update .... set > description='".urlencode(stripslashes($_POST['description']))."'..." > > You might have to write a one-time job to update all the text fields in > your database to conform to the new method or you can just implement it > and each field will be updated as time goes on. > > Ken |