Error: 1054, Unknown column 'category.name' in 'field list'
Posted: Mon May 25, 2009 4:22 am
I am trying to find a solution to the error in the subject line. I have read a few posts and have changed my code to match the posts, but still no luck. I'm using Apache 2.2 and MySQL 5.1.32 on FreeBSD 7.0.
Below are the databases structures:
Thank you for your assistance,
Paul
Code: Select all
<html>
<!-- Header -->
<? include("../include/header.php"); ?>
<!-- Menu -->
<? include("../include/menu.php"); ?>
<div id="main">
<!-- Begin Content -->
<table border="1" width = "50%">
<tr>
<th>Category</th>
<th>Short Description</th>
<th>Part No</th>
<th></th>
<th></th>
<th></th>
</tr>
<?php
require('../include/connect.php');
$id_del = $_GET['id'];
if (! is_numeric($id_del))
{
die('Error' . mysql_errno() . ", " . mysql_error());
}
$sql = "SELECT `category.name`,
`item.short_desc`,
`item.part_no`
FROM `item`, `category`
WHERE `item.id` = '" . $id_del . "'";
if (!mysql_query($sql))
{
die('Error: ' . mysql_errno() . ", " . mysql_error());
$row = mysql_query($sql);
}
/*
print pre;
print_r($row);
print pre;
*/
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['short_desc'] . "</td>";
echo "<td>" . $row['part_no'] . "</td>";
echo "<td align=center>Delete?</td>";
echo "<td> <a href='delete.php?id=" . $row['id'] . "'>Yes</a> </td>";
echo "<td> <a href='item.php'>No</a> </td>";
echo "</tr>";
echo "</table>";
mysql_close($con);
?>
<!-- End Content -->
<!-- Footer -->
<? include("../include/footer.php"); ?>Code: Select all
mysql> describe category;
+----------------+-----------+------+-----+---------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-----------+------+-----+---------------------+-----------------------------+
| id | int(5) | NO | PRI | NULL | auto_increment |
| deleted | int(1) | NO | | 0 | |
| date_insert | timestamp | NO | | 0000-00-00 00:00:00 | |
| insert_user_id | text | YES | | NULL | |
| date_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| update_user_id | text | YES | | NULL | |
| name | text | YES | | NULL | |
+----------------+-----------+------+-----+---------------------+-----------------------------+
7 rows in set (0.01 sec) Code: Select all
mysql> describe item;
+----------------+---------------+------+-----+---------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------------------+-----------------------------+
| id | int(5) | NO | PRI | NULL | auto_increment |
| deleted | int(1) | NO | | 0 | |
| date_insert | timestamp | NO | | 0000-00-00 00:00:00 | |
| insert_user_id | text | YES | | NULL | |
| date_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| update_user_id | text | YES | | NULL | |
| category_id | int(5) | NO | | 0 | |
| short_desc | text | YES | | NULL | |
| part_no | text | NO | | NULL | |
| vendor | text | YES | | NULL | |
| unit_price | decimal(10,2) | YES | | NULL | |
| long_desc | text | YES | | NULL | |
| max_qty | int(5) | NO | | 0 | |
| qty | int(5) | YES | | NULL | |
+----------------+---------------+------+-----+---------------------+-----------------------------+
14 rows in set (0.00 sec) Paul