Mysql_real_escape_string() A link to the server could not be established

独自空忆成欢 提交于 2019-12-01 21:31:51

This is because mysql_real_escape_string takes into account the current character set of the connection. As such, it needs a connection. :-)

If you don't want to manually set up a connection in advance, you could set the various MySQL runtime defaults within your .ini file.

However, if you're using your own database class (or simply the manual commands), it's often worth establishing the connection early in the lifetime of your script.

Because escaping depends on the character set on the server. See mysql_real_escape_string in the MySQL manual (the PHP function of the same name is just a wrapper around this C function).

find and delete

mysql_close();

this function disconnect completely from MySQL server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!