在我的php页面上,在顶部,我像这样连接到数据库
$db = mysql_connect("mysql.site.com","thedb", "pass");
mysql_select_db("dbase",$db);
这安全吗?有人能扫描并查看我的代码,从而访问数据库吗?
UPDATE
我问的原因是,用户能够访问我的数据库,我很确定这不是通过sql注入。
在我的php页面上,在顶部,我像这样连接到数据库
$db = mysql_connect("mysql.site.com","thedb", "pass");
mysql_select_db("dbase",$db);
这安全吗?有人能扫描并查看我的代码,从而访问数据库吗?
我问的原因是,用户能够访问我的数据库,我很确定这不是通过sql注入。
如果您将此代码段移动到文档根目录之外的包含文件中会更好——这将防止人们在您的Web服务器配置错误并开始以纯文本形式提供PHP文件的情况下阅读它。虽然,就其本身而言,它是足够安全的——但不太可能有人故意这样错误配置你的服务器。
如果有人确实可以访问您的代码,那么是的,他们将能够读取密码。
你对此无能为力,但确保这段代码是你的网络根目录上的一个目录会有所帮助。
(即,如果您从文件夹/usr/htdocs/mysite
为您的网站提供服务,请将其更改为usr/htdocs/maysite/public
您应该始终应用多层防御:
没关系,重要的是,我可以说,去你的数据库,给那个用户有限的权限,我的意思是只选择、插入、更新和删除它需要的表。。除此之外,我的建议是,用这些信息创建一个文件,并在需要时包含。
如果有人浏览你的代码,就能看到这些信息,但要尽量减少损害影响
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
我把我的用心从使用QQL转向MySQL。 它与凯科特合作,现在不工作,因为我已经改变,使用MySQL。 这里的错误信息是:
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...
Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...
What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...
My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...