Dysan Posted January 18, 2008 Share Posted January 18, 2008 Hi, Is it good practice to include all of the following code inside a separate file, then link to it via each page? Does this increase security? session_start(); $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die(mysql_error()); } mysql_select_db("db", $con); Quote Link to comment https://forums.phpfreaks.com/topic/86709-file-include/ Share on other sites More sharing options...
revraz Posted January 18, 2008 Share Posted January 18, 2008 It will save code space and mistakes since you don't have to repeat it on every page you use a DB. Quote Link to comment https://forums.phpfreaks.com/topic/86709-file-include/#findComment-443099 Share on other sites More sharing options...
papaface Posted January 18, 2008 Share Posted January 18, 2008 Not really a security issue, that is what most programmers do. Including me. But in a slightly more complex manner. Quote Link to comment https://forums.phpfreaks.com/topic/86709-file-include/#findComment-443102 Share on other sites More sharing options...
Kingy Posted January 18, 2008 Share Posted January 18, 2008 When i make semi-large websites with multiple sql scripts, i always find it easier to make the dbconn.php page like you've done below and just include on all pages i need it on, it does make things a lot easier when working and can/will shorten your code slightly. As for increasing security, im not sure that i makes any difference where you place that code, but then again i could be wrong Quote Link to comment https://forums.phpfreaks.com/topic/86709-file-include/#findComment-443104 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.