note 108870 added to function.mysql-connect

From: Date: Thu, 31 May 2012 09:48:52 +0000
Subject: note 108870 added to function.mysql-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-188318@lists.php.net to get a copy of this message
php and mysql are like those sweet couples who never be without each other or you can say made for each other. when a php fresher writes his/her first line of code in php from that day he/she knows the truth. From technical point of view they are very much compatible with each other and the Phpmyadmin has done the finishing touch perfectly. Though we can connect php with other databases or use mysql db as back-end with other platforms but in 99% cases php is used with mysql. Not as because both are free , because of the inbuilt functions in php for accessing mysql data. mysql_connect([ string $server = ini_get("mysql.default_host") [, string $username = ini_get("mysql.default_user") [, string$password = ini_get("mysql.default_password") [, bool $new_link = false [, int $client_flags = 0 ]]]]] ); $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); class Database { // Connection parameters var $host = ""; var $user = ""; var $password = ""; var $database = ""; var $persistent = false; // Database connection handle var $conn = NULL; // Query result var $result = false; function Database() { $config = new Config(); $this->host = $config->host; $this->user = $config->user; $this->password = $config->password; $this->database = $config->database; } function open() { // Choose the appropriate connect function if ($this->persistent) { $func = 'mysql_pconnect'; } else { $func = 'mysql_connect'; } // Connect to the MySQL server $this->conn = $func($this->host, $this->user, $this->password); if (!$this->conn) { header("Location: error.html"); //echo mysql_error(); exit; return false; } For full source code please read the full article http://www.codingquery.com/php-mysql-connection-class-source-code I am very helpfull from thjis article ---- Server IP: 59.162.86.123 Probable Submitter: 122.176.99.253 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-connect.php Edit -- https://master.php.net/note/edit/108870 Del: integrated -- https://master.php.net/note/delete/108870/integrated Del: useless -- https://master.php.net/note/delete/108870/useless Del: bad code -- https://master.php.net/note/delete/108870/bad+code Del: spam -- https://master.php.net/note/delete/108870/spam Del: non-english -- https://master.php.net/note/delete/108870/non-english Del: in docs -- https://master.php.net/note/delete/108870/in+docs Del: other reasons-- https://master.php.net/note/delete/108870 Reject -- https://master.php.net/note/reject/108870 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188318) next »