PHP/Mysql/special characters problem
From: Mosher (mosh_king2000_at_yahoo.com)
Date: 12/31/03
- Next message: Krista: "can i put the same data in the two different drop box?"
- Previous message: CountScubula: "Re: PHP integration in a Frontpage website?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Dec 2003 13:33:23 -0600
Hi all,
I have an issue with php and/or mysql. I have a php form that writes "items"
to a mysql database, including a description of the item. On the mysql
server, "magic_quotes_gpc" is ON.
I am testing it now by putting special characters in the description field,
this is what I am entering:
O'Leary "special edition"
Now, this item data always gets written to the db just fine and shows up in
the db as entered. Seems correct and working just fine up to this point.
My problem is with my "edit item" page. This page allows users to update
items, including the mentioned "description" field. But when the data is
called back up from the db to display in the "edit item" page and the
description contains double quotes, the description is cut off, and only
shows:
O'Leary
Here is the code (snippet of the important stuff and numbered) on the "edit
item" page:
1. $result = mysql_query("select * from inven where product =
'$product'");
2. $row = mysql_fetch_array($result);
3. echo "Description is: $row[description]";
4. echo "<table width=80% border=1 cellpadding=4 cellspacing=0>";
5. ?>
6. <tr><td>Product #:</td><td><input type=text name=product value="<?echo
$row[product]?>"></td></tr>
7. <tr><td>Description:</td><td><input type=text name=description
value="<?echo $row[description]?>" size=50></td></tr>
8.
9. <?
10. echo "</table>";
11. echo "<br><br><input type=submit name=Update value=Update>";
12. ?>
The important line of code here is line 6, where the value of description
should show. The real value of description that is in the database should be
showing up here, but it is cut off if it contains double quotes. Note also
that the full value (double quotes and all) of description can be seen in
the echo statement at line 3. I'm stumped.
To sum up this problem, data appears to get written to the db just fine. The
"edit item" page is brought up, but the description - if it contains special
characters, is cut off, apparently where there are double quotes. If I go
ahead and update the item, the new value in the db is now cut off and not
what I want.
Any ideas? Thanks in advance.
Mosher
- Next message: Krista: "can i put the same data in the two different drop box?"
- Previous message: CountScubula: "Re: PHP integration in a Frontpage website?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|