php database connection
Posted by: wili (---.181.122.info.com.ph)
Date: January 20, 2006 06:12AM

I made a working simple registration php.
then i made a simple databse in wamp..
how can i connect the databes and the php?

Options: ReplyQuote
Re: php database connection
Posted by: Kyrin (---.houston.res.rr.com)
Date: January 20, 2006 08:50AM

<?php
require("const.php"winking smiley;

class mysql{
public $connection;

public function mysql(){
$this->connection = mysql_connect(db_host, db_user, db_pass) or die(mysql_error());
mysql_select_db(db_data, $this->connection) or die(mysql_error());
}

function query($query){
return mysql_query($query, $this->connection);
}
};

/* Create database connection */
$database = new mysql;

?>

const.php

<?php

//define for datasbase
define("db_user", "root"winking smiley;
define("db_pass", ""winking smiley;
define("db_host", "localhost"winking smiley;
define("db_data", "journal"winking smiley;

?>

or

<?php

$host = ' ';
$user = ' ';
$pass = ' ';
$db = ' ';

$q = mysql_connect($host, $user, $pass) or die("Couldn't Connect To Datebase"winking smiley;
mysql_select_db($db, $q) or die("Couldn't Select DataBase"winking smiley;

?>

Options: ReplyQuote


Sorry, only registered users may post in this forum.