Displaying all the information...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greenthree
Forum Newbie
Posts: 3
Joined: Thu Feb 24, 2005 11:54 pm

Displaying all the information...

Post by greenthree »

Code: Select all

<?    

    include('includes/config.php');

    // Builds the database query
	$query  = "SELECT * FROM courses ";
 	$query .= "WHERE id = '$id' ";
    // Execute the query

    $result = mysql_query($query);


    // fetch the row and display the product
    $row = mysql_fetch_array($result);


    echo ( "<tr>" );
    echo ( "<td><b>$row&#1111;name]</b></td>" );
    echo ( "<td><b>$row&#1111;description]</b></td>" );
    echo ( "<td><b>$row&#1111;status]</b></td>" );
    echo ( "</tr>" );
?>

</table>
</body>
</html>
When I run this, it gives me an undefined variable error. When I comment it out, the script works, except it only displays the first set of data. I know the problem lies with line 11, but I am lost as to how to fix it... any help is appreciated.
Last edited by greenthree on Fri Feb 25, 2005 12:15 am, edited 1 time in total.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Code: Select all

while ($row = mysql_fetch_assoc($query))&#123;
echo $row&#1111;suckingatlife];
echo $row&#1111;otherstuff];
&#125;
p.s. edit your post quick before someone yells at you for not using code tags
greenthree
Forum Newbie
Posts: 3
Joined: Thu Feb 24, 2005 11:54 pm

Post by greenthree »

I'm sorry. I fixed my post, but it didn't work. the id variable is still undefined. could you be a little more specific?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Line 11 is a space.. Post the exact code and the exact error..
greenthree
Forum Newbie
Posts: 3
Joined: Thu Feb 24, 2005 11:54 pm

Post by greenthree »

Code: Select all

<?   

    include('includes/config.php');

    // Builds the database query
   $query  = "SELECT * FROM courses ";
    $query .= "WHERE id = '$id' ";
    // Execute the query

    $result = mysql_query($query);


    // fetch the row and display the product
    $row = mysql_fetch_array($result);


    echo ( "<tr>" );
    echo ( "<td><b>$row&#1111;name]</b></td>" );
    echo ( "<td><b>$row&#1111;description]</b></td>" );
    echo ( "<td><b>$row&#1111;status]</b></td>" );
    echo ( "</tr>" );
?>

</table>
</body>
</html>
ERROR: Notice: Undefined variable: id in G:\wwwroot\greenthree\display.php on line 10
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd bet your code is banking on register_globals being on, which they aren't. (A good thing(tm))

Code: Select all

$id = (isset($_POST&#1111;'id']) ? intval($_POST&#1111;'id']) : ''' OR ''1');
You may need to fiddle and use $_GET
Post Reply