|
|
#1 |
|
Silver Member
![]() Join Date: Jul 2011
Posts: 146
|
Question for PHP experts:
How does one typically hide from prying eyes the server name, username, and password that appear in a mysql_connect operation, and the database name in mysql_select_db? Seems you would not want them seen by someone browsing the script. |
|
|
|
|
|
#2 |
|
Silver Member
![]() Join Date: Aug 2011
Posts: 100
|
I don't quite understand what you mean, if you mean preventing them from displaying to the client if an error occurs you can hide errors using
PHP Code:
__________________
Mark R Wubbleyou - Web Design Newcastle A professional web design agency based in Newcastle upon Tyne servicing clients based throughout the U.K. Home spray tan machine - Landlord Reviews |
|
|
|
|
|
#3 |
|
Silver Member
![]() Join Date: Jul 2011
Posts: 146
|
Mark, I mean how to keep the server name, user name, password and database name from being visible somewhere in the script where the following statements are used, or in a related script, as I understand you cannot totally hide website code:
$sqlcon = mysql_connect(server name, user name, password); $sqldb = mysql_select_db(database name, $sqlcon); |
|
|
|
|
|
#4 |
|
Silver Member
![]() Join Date: Aug 2011
Posts: 100
|
Do you mean when sharing the scripts with others?
I usually define variables like that which don't change else where in another file anyway using: PHP Code:
__________________
Mark R Wubbleyou - Web Design Newcastle A professional web design agency based in Newcastle upon Tyne servicing clients based throughout the U.K. Home spray tan machine - Landlord Reviews |
|
|
|
|
|
#5 |
|
Silver Member
![]() Join Date: Jul 2011
Posts: 146
|
I was mostly concerned about someone being able to view the scripts with Notepad or another text editor (yes, you can open a text file on a web server by just giving Notepad the url) so I did what you suggested, and placed the constants file in a separate password protected directory on my web server. Thank you for the help.
|
|
|
|
|
|
#6 | |
|
Bronze Member
![]() |
Quote:
I would be much more worried about SQL injection risks and the like. As suggested above, disable all error reporting on the page and route the errors to a log file instead. Error messages can be precious to hackers. Also use safe passwords (#1 hacking cause in my experience) and escape your SQL parameters.
__________________
Nicolas Bouliane Web designer/developer in Granby, Québec |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|