...

View Full Version : Fatal Error



alpeshnath29
10-14-2010, 04:39 PM
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 .= ", ";
}

kbluhm
10-14-2010, 05:00 PM
What exactly does the error say?

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

alpeshnath29
10-14-2010, 05:06 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum