Hello,
I am having trouble with my script. I get this error:
"Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/imperia/public_html/
testaccess
.php on line 7
Could not select database because" (<---- That is a custom error message in my file)
I am trying to create management system from the ground up and right now I am at the part where I get the pages from a database. This is my first time using classes in php but after I read a certain chapter in my C++ book I understood some things like the "->" and "$this" operator better but I don't know where to put them still. Any help on solving the select db problem? Thanks!
----------begin queries.php-------------
<?php
require('settings.php');
class DBconnector {
var $name = "DBconnector";
function DbConnect($host, $user, $pass){
mysql_connect($host, $user, $pass) or die($error001." ".mysql_error());
}
}
class QueryDB {
var $name = "QueryDB";
function GetPage($id){
$Pageget = "select id, content from mainpage where id = ${id}";
$PageGetRes = mysql_query($PageGet);
while($DisplayPageGet = mysql_fetch_array($PageGet
Res)) {
$content = stripslashes($DisplayPageG
et['conten
t']);
}
}
}
?>
---------------------End queries.php---------------
----------
----
----------begin testpage.php-----------
<?PHP
require('include/queries.p
hp');
class page extends DBconnector{
var $conn;
function SelectDB($db, $host, $user, $pass){
$conn = $this->dbconnect($host,$us
er, $pass);
mysql_select_db($db, "$conn");
}
}
$page = new page;
$page->SelectDB("$mysql[db
]","$mysql
[host]","$
mysql[unam
e]","$mysq
l[pass]") or die($error002." ".mysql_error());
?>
-------------end testpage.php------------
Start Free Trial