Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problems working with database
Old 10-12-2007, 01:29 PM Problems working with database
Novice Talker

Posts: 12
Trades: 0
ok for some reason i am getting warings saying that

Warning: supplied argument is not a valid MySQL result resource

when ever i try to run my scripts.

for all my functions.

this is my class
PHP Code:
<?php
////////////////////////////////////////////////////////////////////////////////////////
// Class: Db
// Purpose: Connect to a database, MySQL version
///////////////////////////////////////////////////////////////////////////////////////
require_once 'core.php';

class 
Db extends Core {

    var 
$theQuery;
    var 
$link;

    
//*** Function: DbConnector, Purpose: Connect to the database ***
    
function Db(){
        
        
// Load settings from parent class
        
$settings     Core::getSettings();
        
        require_once(
'mysql.php');

        
// Get the main settings from the array we just loaded
        
$host         $settings['dbhost'];
        
$db         $settings['dbname'];
        
$user         $settings['dbusername'];
        
$pass         $settings['dbpassword'];
        
        
// Connect to the database
        
$this->link mysql_connect($host$user$pass);
        
mysql_select_db($db);

    }

    
//*** Function: query, Purpose: Execute a database query ***
    
function query($query) {
        
$this->theQuery $query;
        return 
mysql_query($query$this->link) or die(mysql_error());
    }    
    
    
//*** Function: getQuery, Purpose: Returns the last database query, for debugging ***
    
function getQuery() {
        return 
$this->theQuery;
    }
    
    
//*** Function: getNumRows, Purpose: Return row count, MySQL version ***
    
function getNumRows($result){
        return 
mysql_num_rows($result);
    }
    
    
//*** Function: 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);
    }

}
?>
Bascially I got this class directly from a tutorial that I am following so can some please help me figure out what is happening.

I am running it in a login class. I query the database to check for the user and if the rows is greater than 0 i validate otherwise i return to the login page.
stickybomb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2007, 02:08 PM Re: Problems working with database
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
what line ?
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 10-12-2007, 02:46 PM Re: Problems working with database
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
At the end of the day, if you can't get the class working, scrap it. Just write the function in directly to wherever they're needed.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Reply     « Reply to Problems working with database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48863 seconds with 12 queries