PHP / Mysql /特殊字符问题 [英] PHP/Mysql/special characters problem

查看:92
本文介绍了PHP / Mysql /特殊字符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有php和/或mysql的问题。我有一个php表单,它将items

写入mysql数据库,包括该项目的描述。在mysql

服务器上,magic_quotes_gpc打开了。


我现在通过在描述字段中添加特殊字符来测试它,

这就是我要输入的内容:


O''Leary"特别版"


现在,这个项目数据总是被写入数据库并且显示在

输入的数据库。看起来是正确的,到目前为止工作正常。


我的问题在于我的编辑项目页。此页面允许用户更新

项目,包括提到的描述项目。领域。但是当数据被从数据库中调回来时,要显示在编辑项目中。页面和

描述包含双引号,描述被截断,只有

显示:


O''Leary


以下是编辑

项目中的代码(重要内容的片段和编号)。页面:


1. $ result = mysql_query(" select * from invent where product =

''$ product''");

2. $ row = mysql_fetch_array($ result);

3. echo"描述是:$ row [描述]" ;;

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>描述:< / td>< td><输入类型=文字名称= 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.?>


这里重要的代码行是第6行,其中应显示描述值

。数据库中描述的真正价值应该是

显示在这里,但如果它包含双引号则被截断。另请注意

可以在第3行的回声语句中看到完整值(双引号和全部)的说明。我很难过。


总结这个问题,数据似乎写得很好。

"编辑项目"页面被提起,但描述 - 如果它包含特殊的

字符,被切断,显然有双引号。如果我提前

更新项目,数据库中的新值现在被切断,而不是我想要的



有什么想法吗?在此先感谢。


Mosher

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

推荐答案

result = mysql_query(&select; from * from invent where product =

''
result = mysql_query("select * from inven where product =
''


product''");

2。
product''");
2.


row = mysql_fetch_array(
row = mysql_fetch_array(


这篇关于PHP / Mysql /特殊字符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆