Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    338
    Thanks
    22
    Thanked 1 Time in 1 Post

    PHP page coming up blank

    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:

    PHP 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 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)) {
      
    $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: &quot;" $var "&quot;</p>";
    echo 
    "-----------------------------------------------------------------------------------------------------";

    // begin to show results set
    //echo "Results";
    $count $s ;

    // now you can display the results returned
      
      
    while ($rowmysql_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
      
    $prevs=($s-$limit);
      print 
    "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; Prev 10</a>&nbsp&nbsp;";
      }

    // 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 
    "&nbsp;<a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 &gt;&gt;</a>";
      }

    $a $s + ($limit) ;
      if (
    $a $numrows) { $a $numrows ; }
      
    $b $s ;
      echo 
    "<p>-----------------------------Showing results $b to $a of $numrows---------------------------</p>";
      
    ?>
        
            </body></p></td>
            </tr>
        </div>    

    &nbsp;</html>
    for the referring url variable I have something like this:
    Code:
    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
    Last edited by mbarandao; 11-19-2010 at 05:02 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    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 ...

    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    338
    Thanks
    22
    Thanked 1 Time in 1 Post
    Thanks for the reply. I had inserted:

    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);

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

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    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.

    Example:

    echo "line 83 <br>";

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



    .

  • #5
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    338
    Thanks
    22
    Thanked 1 Time in 1 Post
    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,
    Mossa


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •