aruns Posted March 15, 2008 Share Posted March 15, 2008 Hai guys, class connection { var $server; var $user; var $pass; var $db; var $con; function connection($server, $user, $pass, $db) { $this->server = $server; $this->user = $user; $this->pass = $pass; $this->db = $db; } function connect($sql) { $this->con = mysql_connect($this->server, $this->user, $this->pass); mysql_select_db($this->db, $this->con); $que = @mysql_query($sql); settype ($que, "null"); mysql_close($this->con); } } $server = "localhost"; $user = "root"; $pass = "fairy"; $db = "up"; $dbconnect = new connection($server, $user, $pass, $db); $que = $dbconnect->connect("select * from load"); $res = mysql_fetch_array($que); echo $res['name']; this cannot working Arun Link to comment https://forums.phpfreaks.com/topic/96275-help-with-db-connection/ Share on other sites More sharing options...
Jabop Posted March 15, 2008 Share Posted March 15, 2008 define('CFG_SQLHOST','host'); define('CFG_SQLLOGIN','login'); define('CFG_SQLPASS','pass'); define('CFG_SQLDB','db'); define('CFG_SQLPORT','port'); class DB_MYSQL { var $LinkID = false; var $QueryID = false; var $Record = array(); var $Row; var $Errno = 0; var $Error = ''; function connect() { if(!$this->LinkID) { $this->LinkID = mysql_connect(CFG_SQLHOST.':'.CFG_SQLPORT,CFG_SQLLOGIN,CFG_SQLPASS); if (!$this->LinkID) { $this->halt('Connection failed (host:'.CFG_SQLHOST.':'.CFG_SQLPORT.' Login:'.CFG_SQLLOGIN.')'); } } } } Link to comment https://forums.phpfreaks.com/topic/96275-help-with-db-connection/#findComment-492827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.