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 Quote Link to comment 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.')'); } } } } Quote Link to comment 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.