I'm having a real problem with a single variable... and I've read every post I could find to resolve it.
In the following code (I only show the stuff after the form is submitted), everything works fine if I remove the first if statement "if ($email != 0) {xxxxx} otherwise I get an error... This seems like a global variable issue since "if" is a sort of function and, therefore, may treat $result as a local variable.
Does anyone know why (and a solution)?
Thanks,
Fido
<?php
// if form has been submitted
if (isset($POST['submitok']))
{
$email = $POST['email'];
$lastname = $POST['lastname'];
$company = $POST['company'];
global $result;
$result = 0;
// get email
if ($email != 0)
{ $result = mssql_query("SELECT * FROM users WHERE email = '".$_POST['email']."'");
if (DB::isError($result))
{ die($email_check->getMessage()); }
}
echo "<table border=0 cellspacing=0 cellpadding=0>\n";
echo "<tr><td class='boldtext'><A HREF='databasemenu.html'>back to database menu</A><P></td></tr>\n";
echo "<tr><td class='titletext'>Database Entries<P></td></tr>\n";
echo "<tr><td>";
echo "<table border=0 cellspacing=1 cellpadding=3 bgcolor='#CCCCCC'>\n";
echo "<tr><td bgcolor='#eeeeee' class='boldtext' colspan=26>Database: PURE</td></tr>\n";
echo "<tr bgcolor='#eeeeee' class='boldtext'><td>email</td><td>Sal</td><td >FName</td><td>MName</td><td>LName</td><td>Cmpy</td><td>URL</td><td>Addr1</td><td>Addr2</td><td >City</td><td>State</td><td>Zip</td><td>Phone1</td><td>Phone2</td><td>Fax</td><td>School</td><td>Deg</td><td>Grad</td><td>Specialty</td><td>Lic #</td><td>PW</td><td>PW2</td></tr>\n";
while ($myrow = mssql_fetch_row($result))
{ printf("<tr bgcolor='#FFFFFF' class='text'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[9], $myrow[6], $myrow[7], $myrow[8], $myrow[10], $myrow[11], $myrow[12], $myrow[13], $myrow[14], $myrow[15], $myrow[16], $myrow[17], $myrow[18], $myrow[19], $myrow[20], $myrow[29], $myrow[21], $myrow[22], $myrow[23], $myrow[2], $myrow[24]); }
echo "</table>\n";
echo "</td></tr></table>\n";
}
?>