I am new to PHP and MySQL, I'm trying to create a page that displays a SELECT statement inside of a table. When I run the page, it goes blank. I've reviewed the code and looked at examples online. I'm not sure what I am missing. I'm confident that the error is the php code displaying the data in the table. Can anyone guide me as to the problem?
-------------CODE-------------------------
<html>
<!-- Header -->
<? include("../include/header.php"); ?>
<!-- Menu -->
<? include('../include/menu.php'); ?>
<div id='main'>
<!-- Begin Content -->
<?php
<!-- Database Connection -->
require('../include/connect.php');
$result = mysql_query('
SELECT
category.name,
item.short_desc,
item.part_no,
item.vendor,
item.unit_price,
item.long_desc,
item.max_qty
FROM
item, category
WHERE
item.deleted = 1 AND item.category_id = category.id
ORDER BY
item.id DESC');
}
echo '<table border="1">
<tr>
<th>Category</th>
<th>Short Description</th>
<th>Part No</th>
<th>Vendor</th>
<th>Unit Price</th>
<th>Description</th>
<th>Max Qty</th>
<th></th>
<th></th>
<th></th>
</tr>';
while($row = mysql_fetch_assoc($result))
{
echo '<tr bgcolor=$bgcolor>';
echo '<td>' . $row['category.name'] . "</td>";
echo '<td>' . $row['item.short_desc'] . "</td>";
echo '<td>' . $row['item.part_no'] . "</td>";
echo '<td>' . $row['item.vendor'] . "</td>";
echo '<td>' . $row['item.unit_price'] . "</td>";
echo '<td>' . $row['item.long_desc'] . "</td>";
echo '<td>' . $row['item.max_qty'] . '</td>';
echo '<td> <a href="">Update</a> </td>';
echo '<td> <a href="">Delete</a> </td>';
echo '<td> <a href="">Order</a></td>';
echo '<tr>';
}
echo '</table>';
?>
<!-- End Content -->
<!-- Footer -->
<? include('../footer.php'); ?><html>
<!-- Header -->
<? include("../include/header.php"); ?>
<!-- Menu -->
<? include('../include/menu.php'); ?>
<div id='main'>
<!-- Begin Content -->
<?php
<!-- Database Connection -->
require('../include/connect.php');
$result = mysql_query('
SELECT
category.name,
item.short_desc,
item.part_no,
item.vendor,
item.unit_price,
item.long_desc,
item.max_qty
FROM
item, category
WHERE
item.deleted = 1 AND item.category_id = category.id
ORDER BY
item.id DESC');
}
echo '<table border="1">
<tr>
<th>Category</th>
<th>Short Description</th>
<th>Part No</th>
<th>Vendor</th>
<th>Unit Price</th>
<th>Description</th>
<th>Max Qty</th>
<th></th>
<th></th>
<th></th>
</tr>';
while($row = mysql_fetch_assoc($result))
{
echo '<tr bgcolor=$bgcolor>';
echo '<td>' . $row['category.name'] . "</td>";
echo '<td>' . $row['item.short_desc'] . "</td>";
echo '<td>' . $row['item.part_no'] . "</td>";
echo '<td>' . $row['item.vendor'] . "</td>";
echo '<td>' . $row['item.unit_price'] . "</td>";
echo '<td>' . $row['item.long_desc'] . "</td>";
echo '<td>' . $row['item.max_qty'] . '</td>';
echo '<td> <a href="">Update</a> </td>';
echo '<td> <a href="">Delete</a> </td>';
echo '<td> <a href="">Order</a></td>';
echo '<tr>';
}
echo '</table>';
?>
<!-- End Content -->
<!-- Footer -->
<? include('../footer.php'); ?>
PHP Code Error Causes a Blank Page
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: PHP Code Error Causes a Blank Page
Turn display errors on and php will tell you what line the error is on.
Re: PHP Code Error Causes a Blank Page
Personally I always use the following two lines of code to force errors to be displayed.
Code: Select all
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', '1');
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: PHP Code Error Causes a Blank Page
I agree, show everything, even notices. Just because php is forgiving does not mean we should write bad code. A real programmer declares everything so will have no noticesMcInfo wrote:Code: Select all
My preference for debugging is [code=php]error_reporting(E_ALL);
Re: PHP Code Error Causes a Blank Page
Thank you to everyone, I was able to identify the errors and move to the next step by changing the php.ini file to display all errors.
Paul
Paul