In the code below I get back the error: Error in Query: Query Empty
For the if ($FunctionName == News) section I receive the error above, but also a row from my query (instead of all the rows).
What am I doing wrong?
Thanks.
<?php
// includes
include("../includes/config.php");
include("../includes/functions.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
?>
<html>
<head>
<basefont face="Verdana">
<link rel="stylesheet" href="../css/styles.css" type="text/css"></head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<!-- standard page header begins -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<tr>
<td width="25%"><img src="../images/<?php echo "$CompanyLogoName" ; ?>" width="200" height="45"></td>
<td width="49%" bgcolor="#000000"><img src="../images/<?php echo "$AdminBg" ;?>"></td>
<td width="26%" bgcolor="#000000" align="right" valign="bottom"><b><font color="<?php echo "$AdminDateColor" ;?>">
<?
$today=date("F d, Y");
print"$today";
?> </font></b></td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="5" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<tr>
<td></td>
</tr>
<tr>
<td bgcolor="CC0000"><font size="-1" color="White"><b><?php echo "$CompanyName" ; ?>:
Administration</b></font></td>
</tr>
<tr>
<td align="left" valign="top">
</tr>
<!-- standard page header ends -->
<p>
<!-- standard page footer begins -->
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" valign>
<tr>
<td bgcolor="#333333"><div align="center"></div></td>
</tr>
<tr>
<td height="35" bgcolor="#333333"><div align="center" valign="middle"><font color="#FFFFFF"><strong>Site Content<br></strong></font></div></td>
</tr>
<tr><td height="1" bgcolor="#FFFFFF"></td></tr>
<tr>
<td height="400" bgcolor="#cc0000" valign="top"><br>
<?php
$sql = mysql_query ("Select FunctionName from tblFunction");
while ($sql_row = mysql_fetch_array($sql)){
echo "<p> <a class=\"FunctionName\" href=\"http://localhost/mnetsys/admin/list2.php?function=".$sql_row["FunctionName"]."\">".$sql_row["FunctionName"]."</a><br></p>";
}
?>
<br>
</td>
</tr>
</table></td>
<td width="74%" colspan="2" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#CCCCCC">
<?php
$sql2 = mysql_query ("Select SubFunctionName FROM tblSubFunction");
while ($sql_row2 = mysql_fetch_array($sql2)){
echo " ".$sql_row2["SubFunctionName"]." |";
}
?>
</td>
</tr>
<tr>
<td width="4%"> </td>
<td width="96%"><br><?php echo "$Function"; ?><br><br>
<?php if ($function == News)
// generate and execute query
$qryListPressRelease = "SELECT PressReleaseID, PressReleaseHeadline, PressReleaseDate FROM tblPressRelease ORDER BY PressReleaseDate DESC";
$rsltListPressRelease = mysql_query($qryListPressRelease) or die ("Error in query: $qryListPressRelease. " . mysql_error());
// if records present
if (mysql_num_rows($rsltListPressRelease) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while($row = mysql_fetch_object($rsltListPressRelease))
{
echo "
<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td align=\"left\"> <font size=\"-1\"><b>$row->PressReleaseHeadline </b>
[ formatDate($row->PressReleaseDate)]</font> <br> <font size=\"-2\"><a href=\"edit.php?id=$row->PressReleaseID\">edit</a>
| <a href=\"delete.php?id=$row->PressReleaseID \">delete</a></font>
<p></td>
</tr>
";
?>
<?php
if ($function == "")
echo "No function selected";
if ($function == Career)
// generate and execute query
$qryListJob = "SELECT JobID, JobName, JobDesc FROM tblJob";
$rsltListJob = mysql_query($qryListJob) or die ("Error in query: $qryListJob. " . mysql_error());
// if records present
if (mysql_num_rows($rsltListJob) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while($job_row = mysql_fetch_object($rsltListJob))
{
echo "
<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td align=\"left\"> <font size=\"-1\"><b>$job_row->JobName </b>
[ ]</font> <br> <font size=\"-2\"><a href=\"edit.php?id=$job_row->JobID\">edit</a>
| <a href=\"delete.php?id=$job_row->JobID \">delete</a></font>
<p></td>
</tr>
";
?>
<?
}
}
}
}
// close connection
mysql_close($connection);
?>
<tr>
<td><font size="-2"><a href="news/add.php">add new</a></font></td>
</tr></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>