Hello,
This is the first time I write OOP in PHP. I wrote a small class for
Mysql and from the index.php, I am calling the new function. I have a
display before new class and I have a display after the new and only the
display I am getting is the before class and after that there is no error.
Is there any thing I should know before using the class?
I have the class in a protected directory and index.php in the main
directory.
<html>
<body>
<?php
include("incs/Mysql_db.inc");
$db = new Mysql_db();
if($db.return_code)
{
echo " Connection is made";
}
else
{
echo "Couldn't make the connection";
}
?>
</body>
</html>
and the class is
<?php
class Mysql_db
{
var $host;
var $db_name;
var $uid;
var $pwd;
var $link;
var $query;
var $result;
var $return_code;
var $error_info;
var $row;
var $number_of_columns;
var $number_of_rows;
function Mysql_db()
{
$this->host = hostname;
$this->db_name = dbname;
$this->uid = uid;
$this->pwd = pwd;
$link = @mysql_db_connect($host, $uid, $pwd);
}
//*********************************** run the query
***************************
function run($query)
{
$this->number_of_columns = 0;
$this->number_of_rows = 0;
$this->return_code = 0;
$this->error_info = "";
$this->result = @mysql_db_query($db_name, $query, $link);
if(!$result)
{
echo "Query didn't run";
echo @mysql_error();
$error_info = @mysql_error();
}
else
{
$number_of_columns = @mysql_num_fields($result);
$number_of_rows = @mysql_num_rows($result);
$error_info = "";
}//end of bad return code
return $return_code;
}// end of run query function
//********************************* extract or fetch a row
**********************
function get_values()
{
$this->row = @mysql_fetch_object($result);
if($row)
{
extract($row);
$return_code = 0;
}
else
{
$return_code = -1;
}// end of if
}//end of get_values function
}//end of class
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]