mysql_fetch_array isnt working as part of my class

Discussion in 'PHP' started by Jayson, Jul 23, 2006.

  1. #1
    Hi,

    when I use mysql_fetch_array() in a simple while-loop with an echo statement, as is shown in the PHP Manual, it works fine for fetching data from my database. But when I use it in combination with a class that I wrote, it doesnt display anything. Here's the source:

    	while($row = mysql_fetch_array($db)) {
    		$text = $row['content'];
    		$homepage->content = $text;
    
    }
    
    PHP:
    Here's the relevant part of my class:

     function DisplayContent() {
    		?>
    		<div id="center">
    				<?php
    		echo $this->content;
    		
    	}
    PHP:
    I just dont understand why. When I simply use an echo statement in the while loop, it displays all results they way its supposed to. But when I try to display them with my $homepage->content command, nothing shows up.

    thanks in advance
     
    Jayson, Jul 23, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    T0PS3O, Jul 23, 2006 IP
  3. Jayson

    Jayson Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I tried declaring some variables in the script as global, but it didnt work.
     
    Jayson, Jul 23, 2006 IP
  4. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What is $db? Can you post the code where $db is being created?

    Thomas
     
    coderlinks, Jul 23, 2006 IP