PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
/db connect and select
$db_name="myDBname";
$table_name ="mytablename";
$connection = @mysql_connect("datbaseconnection", "username", "password")
or die (mysql_error());
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
}
$result=mysql_query ("select * from mytablename");
$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['adsress1']</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
Blank pages are almost always a syntax error in the script when display_errors is Off. If you cannot modify your php.ini, you are going to have to go through your code line by line looking for (the usual suspects) unmatched braces/parentheses or missing semicolons.
Note: Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
A fatal error will be thrown for syntax related issues like the unmatched braces and missing semicolons. Because of that, even changing the 'display_errors' directive with ini_set() will not show information on those types of issues. Unless you change it in php.ini, you will still get a blank page.
I added that and still get the blank page. I will look at it tomorrow in a better PHP editor.
Ah ok.
A fatal error will be thrown for syntax related issues like the unmatched braces and missing semicolons. Because of that, even changing the 'display_errors' directive with ini_set() will not show information on those types of issues. Unless you change it in php.ini, you will still get a blank page.
<?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", "username", "password")
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
?>