h4r00n Posted September 3, 2009 Share Posted September 3, 2009 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] Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/ Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 http://www.rjennings.co.uk/haroon/ this shows it is working, but I cannot get it to work. I have all the files saved in my wamp directory. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911684 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911691 Share on other sites More sharing options...
waterssaz Posted September 3, 2009 Share Posted September 3, 2009 haven't read through all the code as i assume its decent quality if you paid someone to do it. At an absolute glance I see it uses short tage ie <? instead of <?php, ur server is probably not set up to support short tags :-) Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911692 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 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] Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911701 Share on other sites More sharing options...
waterssaz Posted September 3, 2009 Share Posted September 3, 2009 As i said the short tags are probably not supported on your configuration which means that the php is being interprted as literal text Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911706 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 As i said the short tags are probably not supported on your configuration which means that the php is being interprted as literal text So do I just need the replace the <?, at the top of the script with <?php, ? Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911707 Share on other sites More sharing options...
waterssaz Posted September 3, 2009 Share Posted September 3, 2009 To enable short tags on WAMP left click the wamp taksbar icon and select PHP > PHP Settings > short open tag. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911708 Share on other sites More sharing options...
waterssaz Posted September 3, 2009 Share Posted September 3, 2009 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 :-) Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911709 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911713 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911714 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911719 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911739 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911750 Share on other sites More sharing options...
h4r00n Posted September 3, 2009 Author Share Posted September 3, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911758 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172985-php-help-please/#findComment-911816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.