View Full Version : PHP page coming up blank

11-19-2010, 05:57 AM

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:


<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">
<td>Customer's Job Cost History</td>
<div class="graph" style="margin-left: 0px; margin-right: 0px;" display="inline">
<hr size="1" color="#CCCCCC">

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

// check for an empty string and display a message.
if ($trimmed == "")
//echo "<p>Please enter a search...</p>";

// check for a search parameter
if (!isset($var))
echo "<p>We dont seem to have a search parameter!</p>";
//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 ";


if ($numrows == 0)
//echo "<h4>Results</h4>";
echo "<p>Sorry, your search by sound for <a href=\"http://xxxxxxxxxxxxxxxxxxxxx/newsounds.php\?q=$var\">&quot;" . $trimmed . "&quot;</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 &quot;" . $trimmed . "&quot 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)) {

// get results
$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: &quot;" . $var . "&quot;</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>&nbsp;$title1</P>" ;
$count++ ;
echo "<p><strong>Service Description:</strong>&nbsp;$title2 </p>";
$count++ ;
echo "<p><strong>Client ID:</strong>&nbsp;$title3 </p>";
$count++ ;
echo "<p><strong>Service Area:</strong>&nbsp;$title4</p>" ;
$count++ ;
echo "<p><strong>Job Total Cost:</strong>&nbsp;$title5</p>" ;
$count++ ;
echo "<p><strong>Payment:</strong>&nbsp;$title6</P>" ;
$count++ ;
echo "<p><strong>Balance Due:</strong>&nbsp;$title7</P>" ;
$count++ ;
echo "<p><strong>Date of The Invoice</strong>&nbsp;$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
print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; Prev 10</a>&nbsp&nbsp;";

// calculate number of pages needing links

// $pages now contains int of pages needed unless there is a remainder from division

if ($numrows%$limit) {
// has remainder so add one page

// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link

echo "&nbsp;<a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 &gt;&gt;</a>";

$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>-----------------------------Showing results $b to $a of $numrows---------------------------</p>";



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.


11-19-2010, 01:35 PM
The blank page is because the script failed and you have error reporting turned off.
Turn on error reporting via your webhost control panel, or by doing this ...


11-19-2010, 01:55 PM
Thanks for the reply. I had inserted:


as per the advice of an article on google, that did nothing in identifying problem.

11-19-2010, 03:22 PM
Since we have no possible way to test your script ourselves,
you'll have to start commenting-out portions of the script until
you see where the problem is.

Insert a few test echoes to keep track of where you're at.


echo "line 83 <br>";

Put them in various places so you know if a particular line in the script was reached.


11-19-2010, 05:04 PM
Issue resolved!

It was pointed to me by another forumer that I had two instances of "exit;" on line 29 and 36. These instances were causing the failure. After commenting out these instance; "voila", the script works.

Thank you to all who have posted in attempt to help resolve the problem.

The very best,