Reputation: 63
I got a error with my php project.Error are below. How can i solve this problem? I dont have much experience in php
Notice: Query Failed: Unknown column 'P.id' in 'order clause'
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
<?php
$search= "";
if(isset($_POST['btnsearch']))
{
$search="WHERE p.product_description LIKE '%".$_POST['search']."%'";
}
else
{
$search="";
}
$query = mysql_query("SELECT
p.id,
p.product_description,
p.product_category,
p.album_name,
p.date,
pd.product_name
FROM
product AS p
INNER JOIN product_detail AS pd ON p.id = pd.product_id
".$search."
GROUP BY p.id
ORDER BY P.id ASC
") or trigger_error('Query Failed: ' . mysql_error());
while ($row = mysql_fetch_object($query))
{
?>
<tr>
<td><img style="width:100px; height=100px;" src="<?php echo 'upload/' .$row->product_name?>"></td>
<td class="center"><?php echo $row->album_name ?></td>
<td class="center"><?php echo $row->product_description ?></td>
<td class="center"><?php echo $row->product_category ?></td>
<td class="center">
<?php echo $row->date ?>
</td>
<td class="center">
<a class="btn btn-info" href="edit.php?id=<?php echo $row->id ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-info" href="view.php?id=<?php echo $row->id ?>">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger" onclick="return confirm('Are you sure to delete this Image ?');" href="delete.php?id=<?php echo $row->id ?>">
<i class="halflings-icon white trash"></i>
</a>
</td>
</tr>
<?php
}
?>
Upvotes: 0
Views: 43
Reputation: 380
case sensitive? try change ORDER BY P.id ASC with ORDER BY p.id ASC
Upvotes: 1