TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-08-2007, 02:53 PM   #1 (permalink)
The Contributor
Upcoming Programmer 
 
Gurnk's Avatar
 
Join Date: Oct 2007
Location: US
Posts: 66
Thanks: 19
Gurnk is on a distinguished road
Default Newbi OOP Question

I am just starting to learn OOP, this very moment, and I have a question. I got a few things done (more than expected), but I am having some problems.

I am trying to just get a post from a database based on the ID.

PHP Code:
class post {
    var 
$id;
    
    function 
set_post($id) {  
        
$this->id $id
        
        
$post_query mysql_query("SELECT * FROM `v7_posts` WHERE id = '$this->id'");
        if(
mysql_num_rows($post_query) < 1) {
            return 
false;
        } 
        
        
$this->title mysql_result($post_query,'0',"title");
        
$this->post mysql_result($post_query,'0',"post");
        return 
true
    }

    function 
get_post() {
        return 
$this->title;
        return 
$this->post;
    }


Thats my class, and I'm using this to call it.

PHP Code:
$post = new post;
$post->set_post("1");
echo 
$post->get_post(); 
My problem is, that it is only returning the title, not the actual content. Am I doing this completely wrong?

Thanks!
Send a message via MSN to Gurnk
Gurnk is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 10:52 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design