drne47241 2015-04-12 18:13
浏览 22

我的数据库连接是否安全,所以我的网站没有被黑了? [重复]

This question already has an answer here:

I use the following PHP code to connect to MySQL.

$link = mysql_connect('127.0.0.1', 'root', '123456') or die("wrong user pass mysql");
mysql_select_db('database', $link);

This code is placed in a connection file called connection.php which is included in all PHP scripts that require access to database.

If a hacker gets the URL of connect.php (http://www.example.com/connection.php), is it possible to hack my database? How can I ensure that the PHP connection code does not help the hacker? Or which is the best secure way of connecting to the database?

</div>
  • 写回答

1条回答 默认 最新

  • douxiu6835 2015-04-12 18:26
    关注

    to start you should know about how php work : when the browser send request to server , apahce server (or whatever server use for php server) handle the request and compile php page that browser request . php server make an html(+js+css) for view results. therefore php code can not be seen by the client.

    and about hack : use PDO for connect to data base . it's best way to connect mysql database . PDO-PHP manual

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测