Mustafa Shafout Mustafa Shafout - 4 months ago 7
PHP Question

i got no result fetching the database

i have this code it is not getting any result from database

<?php include_once('header.php');
$sql = mysql_query("select * from page where id_page=$get_id_page ");
$row = mysql_fetch_object($sql);

?>

<table border="0" dir="rtl" width="990px">
<tr>
<td width="730px" valign="top">
<div class="cat-box-content" style="margin: 5px;">
<h2 class="title" style="border-color: Default;"> <a href="index.htm"> main</a> &raquo;
<a><?php echo $row->title_page;?></a>
</h2>
<div style="clear: both;"></div>




<?php echo $row->body_page;?>


</div>

<div style="clear: both;"></div>

</div>
</td>
<td width="260px" valign="top"><?php @include_once('left.php')?></td>
</tr>
</table>
<?php include('footer.php');?>


the database Structure is

id_page
title_page
url_page
body_page

time

Answer

Define the variable before you access it. Like this....

<?php $get_id_page = ( isset( $_GET["page_id"] )? $_GET["page_id"] : 0 ); $sql = mysql_query("select * from page where id_page=$get_id_page "); $row = mysql_fetch_object($sql); ?>

Comments