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 3 of 3

Thread: Fatal Error

  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Fatal Error

    Can some1 help me with this.. I trying to run a search php script for my project and I'm getting a fatal error.. Below is the code can any1 please help me out.. Thanks.

    Note: The error is highlighted in RED.

    <tr>
    <td class="content" valign="top" colspan="2">
    <table cellpading="3" cellspacing="4" width="781" border=0>
    <tr><td align="left" colspan="5">
    <?php
    if(!isset($_REQUEST["FirstName"])){
    $_REQUEST["FirstName"] = "";
    }else{
    $_REQUEST["FirstName"] = str_replace("'", "''", $_REQUEST["FirstName"]);
    }
    if(!isset($_REQUEST["LastName"])){
    $_REQUEST["LastName"] = "";
    }else{
    $_REQUEST["LastName"] = str_replace("'", "''", $_REQUEST["LastName"]);
    }
    if(!isset($_REQUEST["MRN"])){
    $_REQUEST["MRN"] = "";
    }else{
    $_REQUEST["MRN"] = str_replace("'", "''", $_REQUEST["MRN"]);
    }
    if(!isset($_REQUEST["DOB"])){
    $_REQUEST["DOB"] = "";
    }else{
    $_REQUEST["DOB"] = str_replace("'", "''", $_REQUEST["DOB"]);
    }
    if(!isset($_REQUEST["Gender"])){
    $_REQUEST["Gender"] = "";
    }
    if(!isset($_REQUEST["EthnicityRace"])){
    $_REQUEST["EthnicityRace"] = "";
    }
    if(!isset($_REQUEST["Language"])){
    $_REQUEST["Language"] = "";
    }
    if(!isset($_REQUEST["OtherLanguage"])){
    $_REQUEST["OtherLanguage"] = "";
    }else{
    $_REQUEST["OtherLanguage"] = str_replace("'", "''", $_REQUEST["OtherLanguage"]);
    }
    if(!isset($_REQUEST["searchpd"])){
    $_REQUEST["searchpd"] = "";
    }

    $table_name="PatientDemographics";

    if (!isset($_REQUEST["offset"])){
    $_REQUEST["offset"]=0;
    }
    $newoffset = $_REQUEST["offset"] + MYSEARCH_ROWS;
    $searchkeywords = "";

    if($_REQUEST["searchpd"]== "Y"){
    if ($_REQUEST["searchcarp"] != "Y") {
    $sqlrows ="SELECT count(*) as num_rows FROM $table_name WHERE ";
    $q = "(";
    if($_REQUEST["FirstName"] !=""){
    $q .= "FirstName = '" .$_REQUEST["FirstName"] ."' ";
    $searchkeywords .= "First Name: " .$_REQUEST["FirstName"];
    }
    if($_REQUEST["LastName"] !=""){
    if($_REQUEST["FirstName"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

    $q .= "LastName = '" .$_REQUEST["LastName"] ."' ";
    $searchkeywords .= "Last Name: " .$_REQUEST["LastName"];
    }
    if($_REQUEST["MRN"] !=""){
    if($_REQUEST["LastName"] !="" || $_REQUEST["FirstName"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

    $q .= "MRN = '" .$_REQUEST["MRN"] ."' ";
    $searchkeywords .= "MRN: " .$_REQUEST["MRN"];
    }
    if($_REQUEST["DOB"] !=""){
    if($_REQUEST["MRN"] !="" || $_REQUEST["LastName"] !="" || $_REQUEST["FirstName"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

    $q .= "DOB = '" .$_REQUEST["DOB"] ."' ";
    $searchkeywords .= "DOB: " .$_REQUEST["DOB"];
    }
    if($_REQUEST["DOB"] !="" || $_REQUEST["MRN"] !="" || $_REQUEST["LastName"] !="" || $_REQUEST["FirstName"] !=""){
    if($_REQUEST["Gender"] !="" || $_REQUEST["EthnicityRace"] !="" || $_REQUEST["Language"] !="" || $_REQUEST["OtherLanguage"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }
    if($_REQUEST["Gender"] !=""){
    $q .= "Gender = '" .$_REQUEST["Gender"] ."' ";
    $searchkeywords .= "Gender: " .$_REQUEST["Gender"];
    }
    if($_REQUEST["EthnicityRace"] !=""){
    if($_REQUEST["Gender"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

    $q .= "EthnicityRace = '" .$_REQUEST["EthnicityRace"] ."' ";
    $searchkeywords .= "Ethnicity/Race: " .$_REQUEST["EthnicityRace"];
    }
    if($_REQUEST["Language"] !=""){
    if($_REQUEST["Gender"] !="" || $_REQUEST["EthnicityRace"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

    $q .= "(Language = '" .$_REQUEST["Language"] ."' ";
    $searchkeywords .= "Language: " .$_REQUEST["Language"];
    }
    if($_REQUEST["OtherLanguage"] !=""){
    if($_REQUEST["Language"] !=""){
    $q .= "OR ";
    $searchkeywords .= ", ";
    }else{
    if($_REQUEST["Gender"] !="" || $_REQUEST["EthnicityRace"] !=""){
    $q .= "AND ";
    }
    $searchkeywords .= ", ";
    }

    $q .= "OtherLanguage = '" .$_REQUEST["OtherLanguage"] ."'";
    if($_REQUEST["Language"] == ""){
    $searchkeywords .= "Other Language: ";
    }
    $searchkeywords .= $_REQUEST["OtherLanguage"];
    }
    if($_REQUEST["Language"] !=""){
    $q .= ") ";
    }
    }

    $q .= ") ";
    $list ="select top " .MYSEARCH_ROWS ." * from $table_name WHERE " .$q ." AND StudyID not in ";
    $list .="(select top " .$_REQUEST["offset"] ." StudyID from $table_name where " .$q ." order by LastName, FirstName, MRN ASC) ";
    $list .= " ORDER BY LastName, FirstName, MRN ASC";
    $sqlrows .= $q;
    //Error is here//
    $db->query($sqlrows);
    $db->next_record();
    $numrows = $db->f("num_rows");
    }
    if ($numrows == 0 || $_REQUEST["searchcarp"] == "Y") {

    $searchcarp = "Y";
    /*
    $q = "execute GET_DEMOGRAPH ";

    if($_REQUEST["MRN"]){
    $q .= "" .$_REQUEST["MRN"] ."";
    }else{
    $q .= "DEFAULT";
    }

    if($_REQUEST["LastName"]){
    $q .= ",'" .$_REQUEST["LastName"] ."'";
    }else{
    $q .= ",DEFAULT";
    }

    if($_REQUEST["FirstName"]){
    $q .= ",'" .$_REQUEST["FirstName"] ."'";
    }else{
    $q .= ",DEFAULT";
    }
    */

    $qqq = "";
    if($_REQUEST["EthnicityRace"] == "Caucasian"){

    $qqq .= "(PTRACE = 'WHITE' OR PTRACE = 'EUROPEAN' OR PTRACE = 'MIDEAST') ";

    }elseif($_REQUEST["EthnicityRace"] == "Latino"){
    $qqq .= "(PTRACE = 'HISP-MEX' OR PTRACE = 'HISP_GUAT' OR PTRACE = 'HISP_PR' OR PTRACE = 'HISP_SA' OR PTRACE = 'LATINO') ";
    }elseif($_REQUEST["EthnicityRace"] == "Black"){

    $qqq .= "(PTRACE = 'AFRICAN' OR PTRACE = 'BLACK0' OR PTRACE = 'BLACK') ";
    }elseif($_REQUEST["EthnicityRace"] == "Other"){

    $qqq .= "(PTRACE = 'OTHSR' OR PTRACE = '' OR PTRACE = 'UNKNOWN' OR PTRACE = 'CARIBBEAN' OR PTRACE = 'NHPIS') ";
    }elseif($ethnicityrace == "Asian/Pacific Islander"){
    $qqq .= "(PTRACE = 'AS-CHI' OR PTRACE = 'AS-FIL' OR PTRACE = 'AS-KOR' OR PTRACE = 'AS-CHI0' OR PTRACE = 'ASIAN' OR PTRACE = 'AS-IND' OR PTRACE = 'AS-JAP' OR PTRACE = 'AS-PAK' OR PTRACE = 'AS-THAI' OR PTRACE = 'AS-VIET' OR PTRACE = 'NHPIS') ";
    }elseif($ethnicityrace == "Biracial"){

    $qqq .= "(PTRACE = 'MULTIETHNIC' OR PTRACE = 'MULTI ETHNIC' OR PTRACE = 'MULTIOTHER' OR PTRACE = 'MULTI OTHER') ";
    }

    $searchkeywords = "";
    $sqlrows ="SELECT count(*) as num_rows FROM carpdemograph WHERE ";
    $q = "(";
    if($_REQUEST["FirstName"] !=""){
    $q .= "PTNAME_FIRST = '" .$_REQUEST["FirstName"] ."' ";
    $searchkeywords .= "First Name: " .$_REQUEST["FirstName"];
    }
    if($_REQUEST["LastName"] !=""){
    if($_REQUEST["FirstName"] !=""){
    $q .= "AND ";
    $searchkeywords .= ", ";
    }

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    What exactly does the error say?

    And is $db defined prior to calling $db->query($sqlrows);?

  • Users who have thanked kbluhm for this post:

    alpeshnath29 (10-14-2010)

  • #3
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Fatal error: Call to a member function on a non-object in C:\..\patientcare\demographics\pd_listshort.html on line 143


    Yes it defined it in the global.inc file..if thats not right do let me knw whr to define it.... Actually I'm new to PHP can you tell me how to define $db,.. but this code is working prefectly fine with my other project which is similar to this one.

    Thanks,
    A
    Last edited by alpeshnath29; 10-14-2010 at 04:59 PM.


  •  

    Posting Permissions

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