Posted: Mon Aug 07, 2006 9:36 am
Count your braces. You have an extra one somewhere.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
ini_set('display_errors', 'On')
error_reporting(E_ALL);
//db connect and select
$db_name="bruceg_friends-family";
$table_name ="address_book";
$connection = @mysql_connect("208.65.62.13", "bruceg_webmaster", "phoenix")
or die (mysql_error());
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
$result=mysql_query ("select * from address_book");
$resultCount = mysql_num_rows($result);
if ($resultCount > 0) { // make sure we have data to display
echo<<<TABLETOP
<table border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<th>id</th>
<th>Name</th>
<th>address1</th>
<th>address2</th>
<th>zip</th>
<th>primary phone</th>
<th>Seconday phone</th>
<th>notes</th>
</tr>
TABLETOP;
while ($row = mysql_fetch_assoc($result)) { // Display the data from mysql
echo<<<TABLEDATA
<tr>
<td>{$row['id']}</td>
<td>{$row['Name']</td>
<td>{$row['address1']</td>
<td>{$row['addres2']</td>
<td>{$row['zip']</td>
<td>{$row['primary_phone']</td>
<td>{$row['2ndary_phone']</td>
<td>{$row['notes']</td>
</tr>
TABLEDATA;
} // End while
echo "</table>";
} // End if
?>I forgot the second half of the curly braces for the $row data inside the while loop. Try it now.bruceg wrote:I took out a brace that looked like it didn't belong, but that didn't fix the problem.
I now have:
if someone has a php debugging program, they could test this on, I would greatly appreciate it.Code: Select all
<?php ini_set('display_errors', 'On') error_reporting(E_ALL); //db connect and select $db_name="bruceg_friends-family"; $table_name ="address_book"; $connection = @mysql_connect("208.65.62.13", "bruceg_webmaster", "phoenix") or die (mysql_error()); $db = @mysql_select_db($db_name, $connection) or die (mysql_error()); $result=mysql_query ("select * from address_book"); $resultCount = mysql_num_rows($result); if ($resultCount > 0) { // make sure we have data to display echo<<<TABLETOP <table border="0" cellspacing="0" cellpadding="10" align="center"> <tr> <th>id</th> <th>Name</th> <th>address1</th> <th>address2</th> <th>zip</th> <th>primary phone</th> <th>Seconday phone</th> <th>notes</th> </tr> TABLETOP; while ($row = mysql_fetch_assoc($result)) { // Display the data from mysql echo<<<TABLEDATA <tr> <td>{$row['id']}</td> <td>{$row['Name']}</td> <td>{$row['address1']}</td> <td>{$row['addres2']}</td> <td>{$row['zip']}</td> <td>{$row['primary_phone']}</td> <td>{$row['2ndary_phone']}</td> <td>{$row['notes']}</td> </tr> TABLEDATA; } // End while echo "</table>"; } // End if ?>
Code: Select all
<?php
ini_set('display_errors', 'On')
error_reporting(E_ALL);
//db connect and select
$db_name="bruceg_friends-family";
$table_name ="address_book";
$connection = @mysql_connect("208.65.62.13", "bruceg_webmaster", "phoenix");
or die (mysql_error());
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
$result=mysql_query ("select * from address_book");
$resultCount = mysql_num_rows($result);
if ($resultCount > 0) { // make sure we have data to display
echo<<<TABLETOP
<table border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<th>id</th>
<th>Name</th>
<th>address1</th>
<th>address2</th>
<th>zip</th>
<th>primary phone</th>
<th>Seconday phone</th>
<th>notes</th>
</tr>
TABLETOP;
while ($row = mysql_fetch_assoc($result)) { // Display the data from mysql
echo<<<TABLEDATA
<tr>
<td>{$row['id']}</td>
<td>{$row['Name']</td>
<td>{$row['address1']</td>
<td>{$row['addres2']</td>
<td>{$row['zip']</td>
<td>{$row['primary_phone']</td>
<td>{$row['2ndary_phone']</td>
<td>{$row['notes']</td>
</tr>
TABLEDATA;
} // End while
echo "</table>";
} // End if
?>Code: Select all
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
//db connect and select
$db_name="bruceg_friends-family";
$table_name ="address_book";
$connection = @mysql_connect("208.65.62.13", "bruceg_webmaster", "phoenix") or die (mysql_error());
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
$result=mysql_query ("select * from address_book");
$resultCount = mysql_num_rows($result);
if ($resultCount > 0) { // make sure we have data to display
echo<<<TABLETOP
<table border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<th>id</th>
<th>Name</th>
<th>address1</th>
<th>address2</th>
<th>zip</th>
<th>primary phone</th>
<th>Seconday phone</th>
<th>notes</th>
</tr>
TABLETOP;
while ($row = mysql_fetch_assoc($result)) { // Display the data from mysql
echo<<<TABLEDATA
<tr>
<td>{$row['id']}</td>
<td>{$row['Name']}</td>
<td>{$row['address1']}</td>
<td>{$row['addres2']}</td>
<td>{$row['zip']}</td>
<td>{$row['primary_phone']}</td>
<td>{$row['2ndary_phone']}</td>
<td>{$row['notes']}</td>
</tr>
TABLEDATA;
} // End while
echo "</table>";
} // End if
?>Code: Select all
<table>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
</td><td></td><td></td></td><td></td>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
</td><td></td><td></td></td><td></td>
</tr>
</table>