Jump to content

Recommended Posts

I have just received a php coding and search form from somebody I payed to do, however when I click the search button on the form, it doesn't read the php script as a php. Is there anything wrong with it?

 

<?
include('mysql.inc.php');
include('config.php');


$db = new dblink($log);
$db->connect($dbhost,$dbuser,$dbpass);
if($db->selectDb($dbname) === false){echo "could not connect to database";}


if(isset($_POST['ref']) && $_POST['ref'] != ""){
	$boolRef = true;
	$ref = $_POST['ref'];
	$ref = "'%".$ref."%'";
	$masterQuery = "SELECT * FROM jobs WHERE `Job Ref` LIKE ".$ref;
	$results = getResults($db,$masterQuery);
		display($results);
	exit();
}



if($_POST['keywords'] != ""){
	$keywords = explode(' ',$_POST['keywords']);
	foreach($keywords as $keyword){
		if($keyword !=""){$key .= "`Keywords` LIKE  '%".$keyword."%' AND ";}
	}

	$keywords = substr($key,0,-4);

	$boolKeywords = true;
}


if(isset($_POST['location']) && $_POST['location'] != ""){
	$boolLocation = true;
	$location = $_POST['location'];
	if($location == "all"){$boolLocation = false;}
}


if(isset($_POST['permanent']) && $_POST['permanent'] != ""){$boolPerm = true;}
if(isset($_POST['temporary']) && $_POST['temporary'] != ""){$boolTemp = true;}
if(isset($_POST['parttime']) && $_POST['parttime'] != ""){$boolPartTime = true;}
if(isset($_POST['fulltime']) && $_POST['fulltime'] != ""){$boolFullTime = true;}


if(isset($_POST['sector']) && $_POST['sector'] != ""){
	$boolSector = true;
	$sector = $_POST['sector'];
}






//jobtype
//full
if($boolPerm != true && $boolTemp != true && $boolPartTime != true && $boolFullTime == true){ 
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Full Time%') as a";
}
//part
if($boolPerm != true && $boolTemp != true && $boolPartTime == true && $boolFullTime != true){ 
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Part Time%') as a";
}
//full & part
if($boolPerm != true && $boolTemp != true && $boolPartTime == true && $boolFullTime == true){ 
	$masterQuery .= "(SELECT * FROM jobs) as a";
}
//temp
if($boolPerm != true && $boolTemp == true && $boolPartTime != true && $boolFullTime != true){
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Temporary%') as a";	
}
//temp & full
if($boolPerm != true && $boolTemp == true && $boolPartTime != true && $boolFullTime == true){
	$masterQuery .= "(SELECT * FROM (SELECT * FROM jobs WHERE `Job Type` LIKE '%Temporary%') as a WHERE `Job Type` LIKE '%Full Time%') as b";
}
//temp & part
if($boolPerm != true && $boolTemp == true && $boolPartTime == true && $boolFullTime != true){
	$masterQuery .= "(SELECT * FROM (SELECT * FROM jobs WHERE `Job Type` LIKE '%Temporary%') as a WHERE `Job Type` LIKE '%Part Time%') as b";
}
//temp & part & full
if($boolPerm != true && $boolTemp == true && $boolPartTime == true && $boolFullTime == true){
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Temporary%') as a";	
}
//perm
if($boolPerm == true && $boolTemp != true && $boolPartTime != true && $boolFullTime != true){
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Permanent%') as a";
}
//perm & full
if($boolPerm == true && $boolTemp != true && $boolPartTime != true && $boolFullTime == true){
	$masterQuery .= "(SELECT * FROM (SELECT * FROM jobs WHERE `Job Type` LIKE '%Permanent%') as a WHERE `Job Type` LIKE '%Full Time%') as b";
}
//perm & part
if($boolPerm == true && $boolTemp != true && $boolPartTime == true && $boolFullTime != true){
	$masterQuery .= "(SELECT * FROM (SELECT * FROM jobs WHERE `Job Type` LIKE '%Permanent%') as a WHERE `Job Type` LIKE '%Part Time%') as b";
}
//perm & part & full
if($boolPerm == true && $boolTemp != true && $boolPartTime == true && $boolFullTime == true){
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Permanent%') as a";
}
//perm & temp
if($boolPerm == true && $boolTemp == true && $boolPartTime != true && $boolFullTime != true){ $masterQuery .= "(SELECT * FROM jobs) as a";}
//perm & temp & full
if($boolPerm == true && $boolTemp == true && $boolPartTime != true && $boolFullTime == true){ 
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Full Time%') as a";
}
//perm & temp & part
if($boolPerm == true && $boolTemp == true && $boolPartTime == true && $boolFullTime != true){ 
	$masterQuery .= "(SELECT * FROM jobs WHERE `Job Type` LIKE '%Part Time%') as a";
}
//perm & temp & full & part
if($boolPerm == true && $boolTemp == true && $boolPartTime == true && $boolFullTime == true){ $masterQuery .= "(SELECT * FROM jobs) as a";}



//location
if($boolLocation == true){
	if($boolPerm == true || $boolTemp == true || $boolPartTime == true || $boolFullTime == true){
		$masterQuery = "(SELECT * FROM ".$masterQuery." WHERE `location` LIKE '%".$location."%') as c";
	}else{$masterQuery = "(SELECT * FROM jobs WHERE `location` LIKE '%".$location."%') as c";}
}

//sector
if($boolSector == true){
	if(($boolPerm == true || $boolTemp == true || $boolPartTime == true || $boolFullTime == true) || $boolLocation == true){
		if($sector == "All Social Care"){
			$a=1;
			$masterQuery="(SELECT * FROM ".$masterQuery." WHERE `Sector` LIKE '%Care Assistant%' OR `Sector` LIKE '%Care Manager%' OR `Sector` LIKE '%Child Care/Nanny%' OR `Sector` LIKE '%Elderly Care%' OR `Sector` LIKE '%Family Support%' OR `Sector` LIKE '%Learning Mentor%' OR `Sector` LIKE '%Qualified Social worker%' OR `Sector` LIKE '%Management%' OR `Sector` LIKE '%Social Work Assistant%' OR `Sector` LIKE '%Support Worker%' OR `Sector` LIKE '%Youth Worker%' OR '%Other%') as d";}

		if ($sector == "All Nursing"){
			$a=1;
		$masterQuery="(SELECT * FROM ".$masterQuery." WHERE `Sector` LIKE 'Grade A,B,C' OR `Sector` LIKE '%Grade D%' OR `Sector` LIKE '%Grade E%' OR `Sector` LIKE '%Grade F%' OR `Sector` LIKE '%Grade G%' OR `Sector` LIKE '%Grade H%' OR `Sector` LIKE '%Grade I%' OR `Sector` LIKE '%Management%' OR `Sector` LIKE '%Midwifery%' OR `Sector` LIKE '%Staff Nurse%' OR `Sector` LIKE '%Student%' OR `Sector` LIKE '%Sister/ChargeNurse%' OR `Sector` LIKE '%Other%' OR `Sector` LIKE '%Nursing%') as d";}

		if($sector == "All Allied Health"){
			$a=1;
		$masterQuery="(SELECT * FROM ".$masterQuery." WHERE `Sector` LIKE '%Audiology%' OR `Sector` LIKE '%Dental Auxiliary%' OR `Sector` LIKE '%Medical Assistant%' OR `Sector` LIKE '%Midwifery%' OR `Sector` LIKE '%Pharmacy%' OR `Sector` LIKE '%Physiotherapy%' OR `Sector` LIKE '%Optometry%' OR `Sector` LIKE '%Radiography%' OR `Sector` LIKE '%Other%') as d";}

		if($a != 1){$masterQuery="(SELECT * FROM ".$masterQuery." WHERE `Sector` LIKE '%".$sector."%') as d";}
	}

	if(($boolPerm != true && $boolTemp != true && $boolPartTime != true && $boolFullTime != true) && $boolLocation != true){
		$masterQuery="(SELECT * FROM jobs WHERE `Sector` LIKE '%".$sector."%') as d";
		if($sector == "All Social Care"){
			$masterQuery="(SELECT * FROM jobs WHERE `Sector` LIKE '%Care Assistant%' OR `Sector` LIKE '%Care Manager%' OR `Sector` LIKE '%Child Care/Nanny%' OR `Sector` LIKE '%Elderly Care%' OR `Sector` LIKE '%Family Support%' OR `Sector` LIKE '%Learning Mentor%' OR `Sector` LIKE '%Qualified Social worker%' OR `Sector` LIKE '%Management%' OR `Sector` LIKE '%Social Work Assistant%' OR `Sector` LIKE '%Support Worker%' OR `Sector` LIKE '%Youth Worker%' OR '%Other%') as d";}

		if ($sector == "All Nursing"){
		$masterQuery="(SELECT * FROM jobs WHERE `Sector` LIKE 'Grade A,B,C' OR `Sector` LIKE '%Grade D%' OR `Sector` LIKE '%Grade E%' OR `Sector` LIKE '%Grade F%' OR `Sector` LIKE '%Grade G%' OR `Sector` LIKE '%Grade H%' OR `Sector` LIKE '%Grade I%' OR `Sector` LIKE '%Management%' OR `Sector` LIKE '%Midwifery%' OR `Sector` LIKE '%Staff Nurse%' OR `Sector` LIKE '%Student%' OR `Sector` LIKE '%Sister/ChargeNurse%' OR `Sector` LIKE '%Other%' OR `Sector` LIKE '%Nursing%') as d";}

		if($sector == "All Allied Health"){
		$masterQuery="(SELECT * FROM jobs WHERE `Sector` LIKE '%Audiology%' OR `Sector` LIKE '%Dental Auxiliary%' OR `Sector` LIKE '%Medical Assistant%' OR `Sector` LIKE '%Midwifery%' OR `Sector` LIKE '%Pharmacy%' OR `Sector` LIKE '%Physiotherapy%' OR `Sector` LIKE '%Optometry%' OR `Sector` LIKE '%Radiography%' OR `Sector` LIKE '%Other%') as d";}
	}
}



//keywords
if($boolKeywords == true){
if(($boolPerm == true || $boolTemp == true || $boolPartTime == true || $boolFullTime == true) || $boolLocation == true || $boolSector == true){

	$masterQuery = "(SELECT * FROM ".$masterQuery." WHERE ".$keywords." ) as e";
}
else {$masterQuery = "(SELECT * FROM jobs WHERE ".$keywords." ) as e";}
}






if ($masterQuery == ""){$masterQuery = "SELECT * FROM jobs";}
else{$masterQuery = "SELECT * FROM ".$masterQuery;}



$results = getResults($db,$masterQuery);
display($results);







function getResults($db,$masterQuery){
$query = $db->query($masterQuery);
if(@$db->numRows($query)>0){
	//we have a result
	while($row=$db->fetchArray($query)){$results[] = $row;}
	@mysql_free_result($query);
	return $results;
}else{return $results;}
}


function display($results){
$resultCount = count($results);

//
$resultLimitLower = "1";
$resultLimitHigher = $resultCount;

include('results.inc.php');
if($resultCount == 0){echo "Nothing Found";}
else{
	foreach($results as $result){include('result.inc.php');}
	}
include('footer.inc.php');
}



?>










 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/
Share on other sites

In order to get a web server to serve up a .php file, you must browse to a URL that causes the web server to do that. You need to enter a URL like http://localhost/your_file.php in your browser. You are apparently trying to enter a Windows file system path as a URL, which it is not.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911691
Share on other sites

In order to get a web server to serve up a .php file, you must browse to a URL that causes the web server to do that. You need to enter a URL like http://localhost/your_file.php in your browser. You are apparently trying to enter a Windows file system path as a URL, which it is not.

 

I have attached a print screen of what I get when I do this

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911701
Share on other sites

Yes you could do that which would make your code more portable should you ever move it to another host, however it depends how many files you will have to change. If there are a lot, then you could just turn on short tag support as I explained above although i have never been a fan of short tags at all :-)

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911709
Share on other sites

Yes you could do that which would make your code more portable should you ever move it to another host, however it depends how many files you will have to change. If there are a lot, then you could just turn on short tag support as I explained above although i have never been a fan of short tags at all :-)

 

How do I switch it on?

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911713
Share on other sites

If you paid someone to write that code, get them to change the tags to full php tags. No one that is getting paid to write php code should be using short open tags as you will eventually end up on a server where you won't have the ability to turn on the short_open_tag setting.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911714
Share on other sites

If you paid someone to write that code, get them to change the tags to full php tags. No one that is getting paid to write php code should be using short open tags as you will eventually end up on a server where you won't have the ability to turn on the short_open_tag setting.

 

I have just changed all the <? to <?php and it still does not work.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911719
Share on other sites

Define: "it still does not work." Yes, but what is it doing now compared to what you previously posted it was doing when it was not working? We only see the information you post and the solutions you get cannot be any better than the information you supply.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911739
Share on other sites

Define: "it still does not work." Yes, but what is it doing now compared to what you previously posted it was doing when it was not working? We only see the information you post and the solutions you get cannot be any better than the information you supply.

 

Exactly the same as before, it reads the search.php as if it is not a php script. The creator of the script advised I download XAMPP rather than WAMP. But I did previously have a small search form with a php script working with WAMP.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911750
Share on other sites

Actually, it works now but I get loads of errors

Notice: Undefined variable: log in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 6

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 60

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 60

Notice: Undefined variable: boolPartTime in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 60

Notice: Undefined variable: boolFullTime in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 60

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 64

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 64

Notice: Undefined variable: boolPartTime in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 64

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 68

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 68

Notice: Undefined variable: boolPartTime in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 68

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 72

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 72

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 76

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 76

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 80

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 80

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 84

Notice: Undefined variable: boolTemp in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 84

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 88

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 92

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 96

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 100

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 104

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 106

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 110

Notice: Undefined variable: boolPerm in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 114

Notice: Undefined variable: boolSector in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 126

Notice: Undefined variable: boolKeywords in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 159

Notice: Undefined variable: masterQuery in C:\Documents and Settings\haroon\My Documents\JobJar\wamp\www\wamp\www\Pages\search.php on line 172

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911758
Share on other sites

Those type of errors indicate that the code is not validating data in variables, which could mean it is open to sql injection by a hacker.

 

To correct any of those errors, it would take seeing the code that corresponds to the errors. I would have the person you already paid fix the errors and make sure that the code is secure.

Link to comment
https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911816
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.