hello:
I'm working on this code that receives a variable via url and performs a mysql search for records using the value of the variable as the key word. I'm using the following code --which I'm currently using successfully on another section of my project, but experiencing problems in a different section.
The code is the same with a few minor changes (database and table connection etc), for some odd reason, the page comes out blank without any errors. I tried changing the connection information with intentional false access info to see if an error would be produced, still nothing. I'm a bit puzzled. Here is the code:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Content of Search Results</title> <!--<link rel="stylesheet" type="text/css" href="../music/.keycode2.css"> --></head> <body topmargin="0">
<hr color="#C0C0C0" size="1">
<table border="0" width="100%" id="resultbar" bgcolor="#E2EBED">
<tr>
<td>Customer's Job Cost History</td>
</tr>
</table>
<div class="graph" style="margin-left: 0px; margin-right: 0px;" display="inline">
<align="left">
<hr size="1" color="#CCCCCC">
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Get the search variable from URL
$var = @$_GET["clientID"] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == "")
{
//echo "<p>Please enter a search...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}
//connect to your database
mysql_connect("xxxxxxxxx", "xxxxxxxxx","xxxxxxxxxxxx"); //(host, username, password)
//specify database
mysql_select_db("shop") or die("Unable to select database"); //select which database we're using
// Build SQL Query
//$query = "select * from billofservice where clientID like '%$trimmed%' order by vehicleid "; // EDIT HERE and specify your table and field names for the SQL query
//echo "<br /><br />" . $query . "<br /><br />"; //die(); //$query = "select hashed_name = \"%$trimmed%\" from music"; //echo "<br /><br />" . $query . "<br /><br />";
$query = "select * from billofservice where vehicleid like '%$trimmed%' order by vehicleid ";
$results=mysql_query($query);
$numrows=mysql_num_rows($results);
if ($numrows == 0)
{
//echo "<h4>Results</h4>";
echo "<p>Sorry, your search for <a href=\"http://xxxxxxxxxxxxxxxxxxxxx/newsounds.php\?q=$var\">"" . $trimmed . ""</a> in the music category returned zero results</p>";
echo "This may simply be that our records has not been updated with detailed information of this search. Please click on the link above,
this will prompt our system to initiate the process for detailed information concerning "" . $trimmed . "" sound. <p>It may also be possible that you have selected the wrong category for your search. A review of your search category selection may resolve the issue.</p><p> Thank you!</p>";
echo "--------------------------------------------------------------------------------------------------------";
// google
//echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\"target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here!</a> to try the //search on google</p>";
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
//else{
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
//echo "-----------------------------------------------------------------------------------------------------";
echo "<p>Additional Details information the search on: "" . $var . ""</p>";
echo "-----------------------------------------------------------------------------------------------------";
// begin to show results set
//echo "Results";
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title1 = $row["invoicenum"];
$title2 = $row["servicedesc"];
$title3 = $row["vehicleid"];
$title4 = $row["servicearea"];
$title5 = $row["total"];
$title6 = $row["paid"];
$title7 = $row["Balancedue"];
$title8 = $row["date "];
echo "<p><strong>Invoice Number:</strong> $title1</P>" ;
$count++ ;
echo "<p><strong>Service Description:</strong> $title2 </p>";
$count++ ;
echo "<p><strong>Client ID:</strong> $title3 </p>";
$count++ ;
echo "<p><strong>Service Area:</strong> $title4</p>" ;
$count++ ;
echo "<p><strong>Job Total Cost:</strong> $title5</p>" ;
$count++ ;
echo "<p><strong>Payment:</strong> $title6</P>" ;
$count++ ;
echo "<p><strong>Balance Due:</strong> $title7</P>" ;
$count++ ;
echo "<p><strong>Date of The Invoice</strong> $title8</P>" ;
$count++ ;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo "<br />";
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>-----------------------------Showing results $b to $a of $numrows---------------------------</p>";
?>
</body></p></td>
</tr>
</div>
</html>
for the referring url variable I have something like this:
onclick=\"window.location= 'invoicehistory.php?var=$clientID'
Can someone take a look at it to see if they catch something I'm not seeing.
Thanks,
Mossa