php stripslashes()函数,PHP: stripslashes – Manual

php stripslashes()函数,PHP: stripslashes – ManualHereiscodeIu Idoitbypassi slashes mysql results Thisway

Here is code I use to clean the results from a MySQL query using the stripslashes function.

I do it by passing the sql result and the sql columns to the function strip_slashes_mysql_results.  This way, my data is already clean by the time I want to use it.

function db_query($querystring, $array, $columns)

{

if (!$this->connect_to_mysql())

return 0;

$queryresult = mysql_query($querystring, $this->link)

or die(“Invalid query: ” . mysql_error());

if(mysql_num_rows($queryresult))

{

$columns = mysql_field_names ($queryresult);

if($array)

{

while($row = mysql_fetch_row($queryresult))

$row_meta[] = $this->strip_slashes_mysql_results($row, $columns);

return $row_meta;

}

else

{

while($row = mysql_fetch_object($queryresult))

$row_meta[] = $this->strip_slashes_mysql_results($row, $columns);

return $row_meta;

}

}

else

return 0;

}

function strip_slashes_mysql_results($result, $columns)

{

foreach($columns as $column)

{

if($this->debug)

printp(sprintf(“strip_slashes_mysql_results: %s”,strip_slashes_mysql_results));

$result->$column = stripslashes($result->$column);

}

return $result;

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177858.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月26日 下午6:35
下一篇 2026年3月26日 下午6:35


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号