Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP page coming up blank

  • This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #30743
    mbarandao
    Member

    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:

     


    Content of Search Results







    Customer's Job Cost History






    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 "

    Please enter a search...

    ";
    exit;
    }

    // check for a search parameter
    if (!isset($var))
    {
    echo "

    We dont seem to have a search parameter!

    ";
    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 "

    " . $query . "

    "; //die(); //$query = "select hashed_name = "%$trimmed%" from music"; //echo "

    " . $query . "

    ";
    $query = "select * from billofservice where vehicleid like '%$trimmed%' order by vehicleid ";

    $results=mysql_query($query);
    $numrows=mysql_num_rows($results);

    if ($numrows == 0)
    {
    //echo "

    Results

    ";
    echo "

    Sorry, your search by sound for "" . $trimmed . "" in the music category returned zero results

    ";
    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 . "&quot sound.

    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.

    Thank you!

    ";

    echo "
    ";

    // google
    //echo "

    Click here! to try the //search on google

    ";
    }

    // 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 "

    Additional Details information the search on: "" . $var . ""

    ";
    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 "

    Invoice Number: $title1

    " ;
    $count++ ;
    echo "

    Service Description: $title2

    ";
    $count++ ;
    echo "

    Client ID: $title3

    ";
    $count++ ;
    echo "

    Service Area: $title4

    " ;
    $count++ ;
    echo "

    Job Total Cost: $title5

    " ;
    $count++ ;
    echo "

    Payment: $title6

    " ;
    $count++ ;
    echo "

    Balance Due: $title7

    " ;
    $count++ ;
    echo "

    Date of The Invoice $title8

    " ;
    $count++ ;


    }
    $currPage = (($s/$limit) + 1);

    //break before paging
    echo "
    ";

    // next we need to do the links to other results
    if ($s>=1) { // bypass PREV link if s is 0
    $prevs=($s-$limit);
    print " << Prev 10&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 " Next 10 >>";
    }

    $a = $s + ($limit) ;
    if ($a > $numrows) { $a = $numrows ; }
    $b = $s + 1 ;
    echo "


    Showing results $b to $a of $numrows

    ";
    ?>





     


    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

    #74350
    sylenix
    Member

    not very sure with this, but as far as i know % sign in mysql statement is usually used as a format symbol like after using sprintf() function or am i wrong?

    here:

    $query = "select * from billofservice where vehicleid  like '%$trimmed%' order by vehicleid ";
    #74351
    Rob MacKay
    Participant

    well %$trimmed% would define a wildcard where it would find anything with $trimmed in it.

    So like if you were looking for dig – you could just say like ‘dig’ and it would just look for those letters in that order… or you could wildcard it dig% – then it would match digger digging digamma etc. With the wildcard defined at the front and the end you are looking for the appearance of those 3 letters in any word. bigdigger for example – made up of course – but you would match that as dig is inside it.

    #74353
    sylenix
    Member

    thanks for the info sir! i didn’t know that one ΓΌ

    #74354
    mbarandao
    Member

    Persicely my intent with %$trimmed% -as Robskiwarrior writes . As I noted, I’m currently using this code in a different section of my project. It is working fine. So I therefore do not believe my issue in this instance is with the %$trimmed%. It is something else!

    #74355
    sylenix
    Member

    i noticed these closing tags





    are positioned outside your body

    #74356
    mbarandao
    Member

    Yes! I have removed them during debugging with no success.

    #74357
    mbarandao
    Member

    What seems a bit incomprehensible to me is that everything is being ignored. Even if I intentionally change my db access with false info, normally an error is produced noting that db is inaccessible…not in this instance. The return is a blank page.

    #74358
    sylenix
    Member

    hmmm strange!

    how about this assignment operator that you used in this line?

    $query .= " limit $s,$limit";

    #74359
    sylenix
    Member

    from what i know, “.=” operator is used to multiply the left variable against the right variable/value given.

    #74360
    mbarandao
    Member

    This assignment operator was specific to a search option with google in case my initial internal search was not successful. This should have been commented out as it pertained to another process–which it is now. …still not the cause.

    #74361
    Rob MacKay
    Participant

    $query .= “string”; will concatenate $query with more string. Example:

    $query = "bob";
    $query .= "cat";

    echo $query; //displays "bobcat"
    #74362
    mbarandao
    Member

    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

Viewing 13 posts - 1 through 13 (of 13 total)
  • The forum ‘Back End’ is closed to new topics and replies.