newb to php
Posted: Tue Aug 11, 2009 6:07 pm
Hi All,
Im very new to php and learning some scripts that I have been given. When entering the following code it comes back with the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Can you offer some suggestions to get round this.
Thanks
im using php 5.2.9, apache 2.2.11, mysql 5.1
Thanks in advance
Im very new to php and learning some scripts that I have been given. When entering the following code it comes back with the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Can you offer some suggestions to get round this.
Thanks
Code: Select all
<?php
// Class: DBConnector
// Purpose: Connect to to a database, MYSQL version
require_once 'SystemComponent.php';
class DBConnector extends SystemComponent {
var $theQuery;
var $link;
// Function: DBConnector, Purpose: Connect to a Database
function DBConnector(){
// Load settings from parent class
$settings = SystemComponent::getSettings();
// Get the main settings from the array just loaded
$host = $settings['dbhost'];
$db = $settings['dbname'];
$user = $settings['dbusername'];
$pass = $settings['dbpassword'];
// Connect to database
$this->link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
register_shutdown_function(array(&$this, 'close'));
}
// Function: Query, Purpose: Execut a Database Query
function query($query) {
$this->theQuery = $query;
return mysql_query($query, $this->link);
}
// Fuction: FetchArray, Purpose: Get array of query results
function fetchArray($result) {
return mysql_fetch_array($result);
}
// Function: Close, Purpose: Close the connection
function close() {
mysql_close($this->link);
}
}
?>Thanks in advance