james19
02-21-2008, 07:05 AM
Hi
I got this code from the internet and cannot get it to work. It is supposed to connect to a database but it shows the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/rkhan19/ftpaccess/pub/includes/DbConnector.php on line 43
Does anyone know what could be wrong on line 43????????? Could it be that it only works on certain versions????????? Beloe is the code:
<?php
require_once 'something.php';
class DbConnector extends SystemComponent {
var $theQuery;
var $link;
function DbConnector(){
$settings = SystemComponent::getSettings();
$host = $settings['dbhost'];
$db = $settings['dbname'];
$user = $settings['dbusername'];
$pass = $settings['dbpassword'];
$this->link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
register_shutdown_function(array(&$this, 'close'));
}
function query($query) {
$this->theQuery = $query;
return mysql_query($query, $this->link);
}
function fetchArray($result) {
return mysql_fetch_array($result);
}
function close() {
mysql_close($this->link);
}
}
?>
Your help would be very much appreciated:)
I got this code from the internet and cannot get it to work. It is supposed to connect to a database but it shows the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/rkhan19/ftpaccess/pub/includes/DbConnector.php on line 43
Does anyone know what could be wrong on line 43????????? Could it be that it only works on certain versions????????? Beloe is the code:
<?php
require_once 'something.php';
class DbConnector extends SystemComponent {
var $theQuery;
var $link;
function DbConnector(){
$settings = SystemComponent::getSettings();
$host = $settings['dbhost'];
$db = $settings['dbname'];
$user = $settings['dbusername'];
$pass = $settings['dbpassword'];
$this->link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
register_shutdown_function(array(&$this, 'close'));
}
function query($query) {
$this->theQuery = $query;
return mysql_query($query, $this->link);
}
function fetchArray($result) {
return mysql_fetch_array($result);
}
function close() {
mysql_close($this->link);
}
}
?>
Your help would be very much appreciated:)