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); 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. 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. 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 Link to comment https://forums.phpfreaks.com/topic/86709-file-include/#findComment-443104 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.