Far Cry Posted January 20, 2011 Share Posted January 20, 2011 Hi there, I have this connect script I have made. I was wondering if it's secure or not, if not... What would be a good way to do so... <?php class connect{ public $host = "localhost"; public $dbuser = ""; public $dbpass = ""; public $db = ""; } $connect = new connect(); mysql_connect($connect->host,$connect->dbuser,$connect->dbpass) or die("Could not connect!"); mysql_select_db($connect->db); ?> Link to comment https://forums.phpfreaks.com/topic/225036-most-secure-way-to-connect-to-a-mysql-database/ Share on other sites More sharing options...
BlueSkyIS Posted January 20, 2011 Share Posted January 20, 2011 not sure why you'd use a class, but it's as secure as it can be considering a connection to localhost. Link to comment https://forums.phpfreaks.com/topic/225036-most-secure-way-to-connect-to-a-mysql-database/#findComment-1162288 Share on other sites More sharing options...
Far Cry Posted January 20, 2011 Author Share Posted January 20, 2011 not sure why you'd use a class, but it's as secure as it can be considering a connection to localhost. Well, I want to make sure it's as secure as can be before I upload it to my live server Link to comment https://forums.phpfreaks.com/topic/225036-most-secure-way-to-connect-to-a-mysql-database/#findComment-1162289 Share on other sites More sharing options...
parino_esquilado Posted January 20, 2011 Share Posted January 20, 2011 Close any script that uses mysql with mysql_close($link); Link to comment https://forums.phpfreaks.com/topic/225036-most-secure-way-to-connect-to-a-mysql-database/#findComment-1162291 Share on other sites More sharing options...
BlueSkyIS Posted January 20, 2011 Share Posted January 20, 2011 not sure why you'd use a class, but it's as secure as it can be considering a connection to localhost. Well, I want to make sure it's as secure as can be before I upload it to my live server Using a class in the way you have doesn't enhance security, as far as I know. Close any script that uses mysql with mysql_close($link); This is not necessary, as PHP automatically closes the connection at the end of script execution. See: http://php.net/manual/en/function.mysql-close.php Link to comment https://forums.phpfreaks.com/topic/225036-most-secure-way-to-connect-to-a-mysql-database/#findComment-1162293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.