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
I have a problem, Works on one page and not on another, PHP5
Old 03-29-2008, 04:21 PM I have a problem, Works on one page and not on another, PHP5
jonathanadams's Avatar
Experienced Talker

Posts: 34
Name: Jonathan Adams
Trades: 0
Hello,
i am coding my own cms and im gettin the back end working and i have ran into some difficaulty.

On this page it says whats new http://www.jonathan-adams.co.uk/testcms
the articles listed below are being got from a mysql database. When you click on them it goes to another page to show the full article. here is the code

PHP Code:
<html>
<head> <title>DbConnector</title> </head>
<body>

<?php

    
require_once 'SystemComponent.php';

    class 
DbConnector extends SystemComponent {

    var 
$theQuery;
    var 
$link;

    
//*** Function: DbConnector, Purpose: Connect to the database ***
    
function DbConnector(){

    
// Load settings from parent class
    
$settings SystemComponent::getSettings();

    
// 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);
    
register_shutdown_function(array(&$this'close'));

    }

    
//*** Function: query, Purpose: Execute a database query ***
    
function query($query
    {

    
$this->theQuery $query;
    return 
mysql_query($query$this->link);

    }

    
//*** 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);

    }

}

?>

</body>
</html>
it says on the page

Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.tia/jonathanadams/jonathan-adams.co.uk/testcms/includes/DbConnector.php on line 46
this is the line that im having problems with.

PHP Code:
return mysql_fetch_array($result); 

can anyone help me with my problem please.
__________________

Please login or register to view this content. Registration is FREE
jonathanadams is offline
Reply With Quote
View Public Profile Visit jonathanadams's homepage!
 
 
Register now for full access!
Old 03-31-2008, 01:04 AM Re: I have a problem, Works on one page and not on another, PHP5
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Class definition seems to be correct enough. Show the code.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-31-2008, 07:00 AM Re: I have a problem, Works on one page and not on another, PHP5
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.tia/jonathanadams/jonathan-adams.co.uk/testcms/includes/DbConnector.php on line 46

this is beacuse your SQL is not good... make it mysql_query($query) or die(mysql_error()); but, not in the return... trie to have $bool = mys..... and return $bool
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Reply     « Reply to I have a problem, Works on one page and not on another, PHP5
 

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.20178 seconds with 12 queries