Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: VGRPosted on 2003-03-14 at 13:45:40ID: 8139567
yes, trivial : this error is because the mysql_query did not return any results (either failed or result set is empty).
You should always add "or die("bad query $query : ".mysql_error())" at the end of commands mysql_query($query)
The same for connect.
I would write this :
<?php
class MySQL_Database extends Abstract_Database {
var $link;
function MySQL_Database($host, $uname, $pass, $dbname) {
$this->link = mysql_connect($host, $uname, $pass) or die("bad connect"); // or set the return value to FALSE and test on exit !!!
mysql_select_db($dbname, $this->link) or die ("bad select db");
// return TRUE; if you chose not to die on error
}
function query($sql) {
mysql_query($sql, $this->link) or die("bad query $sql ".mysql_error());
return TRUE;
}
// CAN ONLY BE CALLED IF $results IS VALID !!!
function fetch_row($results) {
$row = mysql_fetch_row($results);
return $row;
}
}
?>