Page 1 of 1

Displaying all the information...

Posted: Thu Feb 24, 2005 11:59 pm
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.

Posted: Fri Feb 25, 2005 12:04 am
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

Posted: Fri Feb 25, 2005 12:18 am
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?

Posted: Fri Feb 25, 2005 12:44 am
by d3ad1ysp0rk
Line 11 is a space.. Post the exact code and the exact error..

Posted: Fri Feb 25, 2005 12:49 am
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

Posted: Fri Feb 25, 2005 12:52 am
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