I have spent ages going over and over this piece of code and I cannot find where the problem is and was hoping someone could help.
The page is: http://ccgi.vajudd.plus.com/search.php
Its for a university project which will be hosted on uni servers but Im using my Plus.net cgi space for testing.
The problem is the drop down list, it dynamically creates the list correctly but when one is selected and the "submit query" is hit I get the following error:
Fatal error: Call to undefined function: showerror() in /files/home1/vajudd/search.php on line 173
Googling the error merely took me to other pages with same errors-not helpful!
The source code for the drop down box is with the connection file name starred out:
<?php
include '********';
//Do connection stuff
if (!($connection = @ mysql_connect($hostname, $username, $password)))
die("Could not connect");
if (!mysql_select_db($databaseName, $connection))
showerror();
//If the region is empty then display the selection box
if (empty($_GET["typeBrand"]))
{ displaySelection($query, $connection);
}
else
{
displayResults($query, $connection);
}
mysql_close($connection);
function displaySelection($query, $connection)
{
//Create the Query - notice the use of 'distinct'
$query = " SELECT distinct Brand FROM Product";
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
echo "<p>Please select a brand name from the list below</p>";
//FORM ACTIONS ITSELF
echo "<form action='search.php' method='GET'>";
echo "<p><select name='typeBrand'>";
echo "<option> All</option>";
while ($row = @ mysql_fetch_array($result))
{
echo "<option/>".$row["Brand"];
}
echo "</select>";
}//Rows Found
echo "<p><input type='submit'></p></form>";
}//End of empty region Name
function displayResults($query, $connection)
{
$typeBrand = $_GET["typeBrand"];
$query = "SELECT Name, Description, Type, Interface, UnitPrice, Image FROM Product";
if ($typeBrand != "All")
$query .= " AND Brand = '$typeBrand' ";
$query .= " ORDER BY Name";
// echo $query;
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
// and start a <table>.
echo "\n<table border=1 cellpadding =10 class=paragraph>\n<tr>" .
"\n\t<th>Name</th>" .
"\n\t<th>Description</th>" .
"\n\t<th>Type</th>" .
"\n\t<th>Interface</th>" .
"\n\t<th>Price (£)</th>" .
"\n\t<th>Image</th>" .
"\n</tr>";
// Fetch each of the query rows
while ($row = @ mysql_fetch_array($result))
{
// Print one row of results
echo "\n<tr>" .
"\n\t<td>" . $row["Name"] . "</td>" .
"\n\t<td>" . $row["Description"] . "</td>" .
"\n\t<td>" . $row["Type"] . "</td>" .
"\n\t<td>" . $row["Interface"] . "</td>" .
"\n\t<td>" . $row["UnitPrice"] . "</td>" .
"\n\t<td><img src=" . $row["Image"] . " /></td>" .
"\n</tr>";
} // end while loop body
// Finish the <table>
echo "\n</table>";
} // end if $rowsFound body
// Report how many rows were found
echo "$rowsFound records found matching your
criteria<br>";
}//End else for region name
?>
Any help would be very much appreciated.
The page is: http://ccgi.vajudd.plus.com/search.php
Its for a university project which will be hosted on uni servers but Im using my Plus.net cgi space for testing.
The problem is the drop down list, it dynamically creates the list correctly but when one is selected and the "submit query" is hit I get the following error:
Fatal error: Call to undefined function: showerror() in /files/home1/vajudd/search.php on line 173
Googling the error merely took me to other pages with same errors-not helpful!
The source code for the drop down box is with the connection file name starred out:
<?php
include '********';
//Do connection stuff
if (!($connection = @ mysql_connect($hostname, $username, $password)))
die("Could not connect");
if (!mysql_select_db($databaseName, $connection))
showerror();
//If the region is empty then display the selection box
if (empty($_GET["typeBrand"]))
{ displaySelection($query, $connection);
}
else
{
displayResults($query, $connection);
}
mysql_close($connection);
function displaySelection($query, $connection)
{
//Create the Query - notice the use of 'distinct'
$query = " SELECT distinct Brand FROM Product";
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
echo "<p>Please select a brand name from the list below</p>";
//FORM ACTIONS ITSELF
echo "<form action='search.php' method='GET'>";
echo "<p><select name='typeBrand'>";
echo "<option> All</option>";
while ($row = @ mysql_fetch_array($result))
{
echo "<option/>".$row["Brand"];
}
echo "</select>";
}//Rows Found
echo "<p><input type='submit'></p></form>";
}//End of empty region Name
function displayResults($query, $connection)
{
$typeBrand = $_GET["typeBrand"];
$query = "SELECT Name, Description, Type, Interface, UnitPrice, Image FROM Product";
if ($typeBrand != "All")
$query .= " AND Brand = '$typeBrand' ";
$query .= " ORDER BY Name";
// echo $query;
// Run the query on the DBMS
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
// and start a <table>.
echo "\n<table border=1 cellpadding =10 class=paragraph>\n<tr>" .
"\n\t<th>Name</th>" .
"\n\t<th>Description</th>" .
"\n\t<th>Type</th>" .
"\n\t<th>Interface</th>" .
"\n\t<th>Price (£)</th>" .
"\n\t<th>Image</th>" .
"\n</tr>";
// Fetch each of the query rows
while ($row = @ mysql_fetch_array($result))
{
// Print one row of results
echo "\n<tr>" .
"\n\t<td>" . $row["Name"] . "</td>" .
"\n\t<td>" . $row["Description"] . "</td>" .
"\n\t<td>" . $row["Type"] . "</td>" .
"\n\t<td>" . $row["Interface"] . "</td>" .
"\n\t<td>" . $row["UnitPrice"] . "</td>" .
"\n\t<td><img src=" . $row["Image"] . " /></td>" .
"\n</tr>";
} // end while loop body
// Finish the <table>
echo "\n</table>";
} // end if $rowsFound body
// Report how many rows were found
echo "$rowsFound records found matching your
criteria<br>";
}//End else for region name
?>
Any help would be very much appreciated.