[solved] class ( connection wont work )
Posted: Wed Dec 08, 2004 3:28 pm
Oke i have this class
had me an other one. but that didnt work so came up with this.
However i cant seem to figure out why it wont connect.
Executing it.
had me an other one. but that didnt work so came up with this.
However i cant seem to figure out why it wont connect.
Code: Select all
<?php
class database {
var $link;
var $errors = array();
function connect( $host, $name, $pass, $db ) {
$link = mysql_connect( $host, $name, $pass );
if ( ! $link ) {
$this->setError("Couldn't connect to database server");
return false;
}
if ( ! mysql_select_db( $db, $this->link ) ) {
$this->setError("Couldn't select database: $db");
return false;
}
$this->link = $link;
return true;
}
// and some more ofcourseCode: Select all
$dl = new database( );
$dl->connect( "***", "****", "", "test" ) or die ("cant connect");
#$dl->connect( "localhost", "root", "", "test" ) or die ( $dl->getError() );
# as this didnt return a error i put it cant connect manually to see where it went wrong.