Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:59:08+00:00 2026-06-02T06:59:08+00:00

My main website references this php file at the beginning of the document like

  • 0

My main website references this php file at the beginning of the document like this

<?php
include('db.php');
include('func.php');
?>

db.php is a database reference file and it works fine. However, as soon as I reference func.php the website has the following error:

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

So I would love if you would look at the following code and see if you can spot mistakes that would make this happen. Thank you in advance.

<?php
require_once('models.php');
require_once('phpspellcheck/include.js');
$spellcheckObject = new PHPSpellCheck();
$spellcheckObject -> LicenceKey = "TRIAL";
$spellcheckObject -> DictionaryPath = ("phpspellcheck/dictionaries/");
$spellcheckObject -> LoadDictionary("English (International)") ;
$spellcheckObject -> LoadCustomDictionary("custom.txt");

$ckfile = tempnam('/tmp', 'ADCOOK');

//**************************************
//     Page load dropdown results     //
//**************************************
function getTierOne()
{
    /*$result = mysql_query("SELECT DISTINCT vmake FROM vmake") 
    or die(mysql_error());

      while($tier = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$tier['vmake'].'">'.$tier['vmake'].'</option>';
        }*/

}

//**************************************
//     First selection results     //
//**************************************
if(isset($_GET['func']) && $_GET['func'] == "vmake") { 
   vmake($_GET['drop_var']); 
}

function vmake($drop_var)
{  
    /*include_once('db.php');
    $result = mysql_query("SELECT * FROM vmake WHERE vmake='$drop_var'") 
    or die(mysql_error());

    echo '
          <option style="width:242" value=" " selected="selected">Model</option>';

           while($drop_2 = mysql_fetch_array( $result )) 
            {
              echo '<option style="width:242" value="'.$drop_2['vmodel'].'">'.$drop_2['vmodel'].'</option>';
            }

*/

}


if(isset($_POST['email'])) {
    // Keep count
    $count = 0;

    // Time to process searches!

    // Is it a familiar zip code?
    if(substr($_POST['zip'], 0, 2) == '45') {
        if($_POST['homesearch'] == true) {
            $count = craigs('http://ogden.craigslist.org/search/sss', $_POST['city'] . ' ' . $_POST['propertytype'], $_POST['pricemin'], $_POST['pricemax']);
        } elseif($_POST['carsearch'] == true) {
            $count = craigs('http://ogden.craigslist.org/search/sss', $_POST['vmake'] . ' ' . $_POST['vmodel'], $_POST['pricemin'], $_POST['pricemax']);
        } else {
            $count = craigs('http://ogden.craigslist.org/search/sss', $_POST['item'], $_POST['pricemin'], $_POST['pricemax']);
        }
    } elseif(substr($_POST['zip'], 0, 2) == '65') {
        if($_POST['homesearch'] == true) {
            $count = craigs('http://boise.craigslist.org/search/sss', $_POST['city'] . ' ' . $_POST['propertytype'], $_POST['pricemin'], $_POST['pricemax']);
        } elseif($_POST['carsearch'] == true) {
            $count = craigs('http://boise.craigslist.org/search/sss', $_POST['vmake'] . ' ' . $_POST['vmodel'], $_POST['pricemin'], $_POST['pricemax']);
        } else {
            $count = craigs('http://boise.craigslist.org/search/sss', $_POST['item'], $_POST['pricemin'], $_POST['pricemax']);
        }
    }
    // Okay, it's neither.
    // Is it a home search?
    elseif(isset($_POST['homesearch']) && $_POST['homesearch'] == true) {
        // First off, let's split up the cities.
        $cities = explode(',', $_POST['city']);

        // Now, let's translate our owner types.
        if($_POST['homeseller'] == 'owner') {
            $homeseller = '1';
        } elseif($_POST['homeseller'] == 'agent') {
            $homeseller = '0';
        } else {
            $homeseller = '';
        }

        // Now, let's translate our apartment types.
        if($_POST['propertytype'] == '') {
            $propertytype = 0;
        } elseif($_POST['propertytype'] == 'apartment') {
            $propertytype = 3;
        } elseif($_POST['propertytype'] == 'singlefamily') {
            $propertytype = 1;
        } elseif($_POST['propertytype'] == 'townhome') {
            $propertytype = 2;
        } elseif($_POST['propertytype'] == 'manufactured') {
            $propertytype = 4;
        } elseif($_POST['propertytype'] == 'horse') {
            $propertytype = 5;
        } elseif($_POST['propertytype'] == 'vacation') {
            $propertytype = 6;
        } elseif($_POST['propertytype'] == 'multi') {
            $propertytype = 7;
        } else {
            $propertytype = '';
        }

        //function house($item = null, $type = 0, $city = null, $state = null, $zip = null, $distance = null, $seller = null, $pricemin = null, $pricemax = null, $minsqft = null, $maxsqft = null, $minacres = null, $maxacres = null, $minbed = null)
        foreach($cities as $city) {
            $count = house($_POST['item'], $propertytype, $_POST['city'], $_POST['state'], $_POST['zip'], $_POST['distance'], $homeseller, $_POST['pricemin'], $_POST['pricemax'], $_POST['minsqfeet'], $_POST['maxsqfeet'], $_POST['minacres'], $_POST['maxacres'], $_POST['minbedrooms']);
        }
    } elseif(isset($_POST['carsearch']) && $_POST['carsearch'] == true) {
        //function car($pricemin, $pricemax, $vmake, $vmodel, $minmileage, $maxmileage, $year, $carseller, $doors)
        $count = car($_POST['pricemin'], $_POST['pricemax'], $_POST['vmake'], $_POST['vmodel'], $_POST['minmileage'], $_POST['maxmileage'], $_POST['year'], $_POST['carseller'], $_POST['doors']);
    } else {
        $count = ksl($_POST['item'], $_POST['zip'], $_POST['distance'], $_POST['pricemin'], $_POST['pricemax']);
    }

    $perDay = round($count/7);

    if ($count > 14) {
        echo "<p>Based on your search criteria, we estimate that you will receive approximately $perDay alerts a day.</p><p>If this is ok, just press SUBMIT. If not, please press edit and be more specific in your search criteria.</p><p><input type=\"submit\" value=\"Submit\" onclick=\"doSubmit()\" /><input type=\"submit\" value=\"Edit\" onclick=\"$('.loading').dialog('destroy')\" /></p>";
    } elseif ($count > 0) {
        doSubmit();
    } else {
        $bad = false;
        $words = explode(" ", $_POST['item']) {
        if(count($words) > 0) {
            foreach($words as $word) {
                if(!$spellcheckObject->SpellCheckWord($word)) { $bad = true; }
            }
        }
        if($bad) {
            echo "<p>Current estimates show no results based on your current criteria.</p><p>Please ensure the all details are accurate before proceeding.</p><p><input type=\"submit\" value=\"Submit\" onclick=\"doSubmit()\" /><input type=\"submit\" value=\"Edit\" onclick=\"$('.loading').dialog('destroy')\" /></p>";
        } else { 
            doSubmit();
        }
    }
}

// curl
function curl($url, $post=false, $cookie=false) {
    global $ckfile;

    $curl_handle = curl_init();

    if($cookie == 'init') {
        curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $ckfile);
    }

    curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt($curl_handle, CURLOPT_URL, $url);
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);

    if($post <> false) {
        curl_setopt($curl_handle, CURLOPT_POST, TRUE);
        curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post['data']);
    }

    $result = curl_exec($curl_handle);
    curl_close($curl_handle);

    return $result;
}

// craigslist
function craigs($url, $item = null, $pricemin = null, $pricemax = null)
{
    $i = 0;

    // http://ogden.craigslist.org/search/sss?query={item}&srchType=A&minAsk={pricemin}&maxAsk={pricemax}
    $result = curl("$url?query=$item&srchType=A&minAsk=$pricemin&maxAsk=$pricemax");

    if(strpos($result, 'Nothing found for that search') === false) {
        preg_match_all('/<p class="row">.*?<\/p>/is', $result, $output, PREG_PATTERN_ORDER);

        $sevenDaysAgo = strtotime('8 days ago');
        $total = 0;

        foreach($output[0] as $out) {
                if($i < 100) {
                        preg_match_all('/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*\d{1,2}/is', $out, $date, PREG_PATTERN_ORDER);

                        foreach($date[0] as $day) {
                                // Total count
                                $total++;

                                // Let's strip extra spaces...
                                $finalDay = preg_replace('/\s\s+/is', ' ', $day);

                                // Let's compare the dates...
                                if ($sevenDaysAgo < strtotime($finalDay)) {
                                        $i++;
                                }
                        }
                }
        }
    } else {
        // Nothing found.
    }

    return $i;
}

// ksl
function ksl($item = null, $zip = null, $distance = null, $pricemin = null, $pricemax = null)
{
    $i = 0;

    // http://www.ksl.com/index.php?nid=231&search=radio&zip=45174&distance=10&min_price=1&max_price=500&addisplay=%5BNOW-7DAYS+TO+NOW%5D&sort=5&nocache=1&viewNumResults=70&sort=5
    $result = curl("http://www.ksl.com/index.php?nid=231&search=$item&zip=$zip&distance=$distance&min_price=$pricemin&max_price=$pricemax&addisplay=%5BNOW-7DAYS+TO+NOW%5D&sort=5&nocache=1&viewNumResults=70&sort=5");

    if(strpos($result, 'There are no listings for this search.') === false) {
        preg_match_all('/<div class="adBox">.*?<\/div>/is', $result, $output, PREG_PATTERN_ORDER);

        $i = count($output[0]);
    } else {
        // Nothing found.
    }

    return $i;
}

// house
function house($item = null, $type = 0, $city = null, $state = null, $zip = null, $distance = null, $seller = null, $pricemin = null, $pricemax = null, $minsqft = null, $maxsqft = null, $minacres = null, $maxacres = null, $minbed = null)
{
    // http://www.ksl.com/index.php?si=5017903&nid=651&city=Salt+Lake+City&zipcode=&distance=&state=&start=&end=25000&keyword=&sellertype=&acresstart=&acresend=&sqftstart=&sqftend=&bedrooms=&type=&homes_search=Search

    $done = false;
    $pid = 1;
    $i = 0;
    $sevenDaysAgo = strtotime('8 days ago');
    $total = 0;

    while(!$done) {
        $result = curl("http://www.ksl.com/index.php?sid=5017903&nid=651&city=$city&zipcode=$zip&distance=$distance&state=$state&start=$pricemin&end=$pricemax&keyword=$item&sellertype=$seller&acresstart=$minacres&acresend=$maxacres&sqftstart=$minsqft&sqftend=$maxsqft&bedrooms=$minbed&type=&homes_search=Search&pid=$pid");

        if(strpos($result, '0 results') === false) {
            preg_match_all('/<div class="postDate">.*?<\/div>/is', $result, $output, PREG_PATTERN_ORDER);

            if(count($output[0] != 0)) {
                foreach($output[0] as $out) {
                    // Check the date on this entry.
                    preg_match_all('/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*\d{1,2}/is', $out, $date, PREG_PATTERN_ORDER);
                    foreach($date[0] as $day) {
                        // Total count
                        $total++;
                        // Let's strip extra spaces...
                        $finalDay = preg_replace('/\s\s+/is', ' ', $day);
                        // Let's compare the dates...
                        if ($sevenDaysAgo < strtotime($finalDay)) {
                            $i++;
                        }
                    }
                }

                if ($i >= 70) {
                    $done = true;
                }

                $pid++;
            } else {
                $done = true;
            }
        } else {
            $done = true;
        }
    }

    return $i;
}

// car search
function car($pricemin, $pricemax, $vmake, $vmodel, $minmileage, $maxmileage, $year, $carseller, $doors)
{
    // Car values
    // $carMake = array(); - This is included in an external file.

    // $carModel = array(); - This is included in an external file.

    $carSeller = array(
                'dealer' => 288110,
                'owner' => 20);

    // Let's setup our post data:
    if(trim($vmake) <> "") {
        $fields['make'][$carMake[$vmake]] = 1;
    }

    if (trim($vmodel) <> "" && $vmodel <> 0) {
        $fields['model'][$carModel[$vmodel]] = 1;
    }

    if ($pricemin <> "") {
        $fields['sell_price'][$pricemin] = 1;
    }

    if ($pricemax <> "") {
        $fields['sell_price'][$pricemax] = 1;
    }

    if ($minmileage <> "") {
        $fields['mileage'][$minmileage] = 1;
    }

    if ($maxmileage <> "") {
        $fields['mileage'][$maxmileage] = 1;
    }

    if(is_array($doors)) {
        foreach($doors as $door) {
            $fields['doors'][$door] = 1;
        }
    }

    if(is_array($year)) {
        foreach($year as $yr) {
            $fields['year'][$yr] = 1;
        }
    }

    if(is_array($carseller)) {
        foreach($carseller as $seller) {
            if($seller == '' || $seller == ' ') { 
                $fields['seller_type']['0'] = 1;
            } else {
                $fields['seller_type'][$carSeller[$seller]] = 1;
            }
        }
    }

    // We need to firstly initiate a cookie. This is done like so.
    curl('http://www.ksl.com/index.php?sid=0&nid=443', false, 'init');

    // Then, we need to set our search values. We can send a post value to do this.

    $data = 'call='.urlencode('save_query').'&sdata='.urlencode(urlencode(serialize($fields))).'&run='.urlencode('resources/community/java/community_rpc.php');

    $post['count'] = 3;
    $post['data'] = $data;

    // Submit our post data...


    $done = false;
    $pid = 0;
    $i = 0;
    $sevenDaysAgo = strtotime('8 days ago');

    while(!$done) {
        // do curl here
        $result = curl("http://www.ksl.com/index.php?sid=0&nid=443&tab=list&pid=$pid", false, true);
        $f = fopen('f.txt', 'w');
        fwrite($f, $result);
        fclose($f);

        if(strpos($result, 'There are no listings for this search.') === false) {
            preg_match_all('/<div class="adTime">.*?<\/div>/is', $result, $output, PREG_PATTERN_ORDER);

            if(count($output[0] != 0)) {
                foreach($output[0] as $out) {
                    // Check the date on this entry.
                    preg_match_all('/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*\d{1,2}/is', $out, $date, PREG_PATTERN_ORDER);

                    foreach($date[0] as $day) {
                        // Let's strip extra spaces...
                        $finalDay = preg_replace('/\s\s+/is', ' ', $day);
                        // Let's compare the dates...
                        if ($sevenDaysAgo < strtotime($finalDay)) {
                            $i++;
                        }
                    }
                }

                if ($i >= 70) {
                    $done = true;
                }

                $pid++;
            } else {
                $done = true;
            }
        } else {
            $done = true;
            // Nothing found.
        }
    }

    return $i;
}

function doSubmit() {
foreach($_POST as $key => $value) {
    // This should trim any extra spaces in addition to any newlines or tabs.
    $_POST[$key] = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $value);
}

$email=$_POST['email'];
$phone=$_POST['phone'];
$item=$_POST['item'];
$pricemin=$_POST['pricemin'];
$pricemax=$_POST['pricemax'];
$zip=$_POST['zip'];
$miles=$_POST['miles'];
$carsearch=$_POST['carsearch'];
$vmake=$_POST['vmake'];
$vmodel=$_POST['vmodel'];
$minmileage=$_POST['minmileage'];
$maxmileage=$_POST['maxmileage'];
$year=$_POST['year'];
$carseller=$_POST['carseller'];
$doors=$_POST['doors'];
$homesearch=$_POST['homesearch'];
$propertytype=$_POST['propertytype'];
$city=$_POST['city'];
$state=$_POST['state'];
$homeseller=$_POST['homeseller'];
$minacres=$_POST['minacres'];
$maxacres=$_POST['maxacres'];
$minsqfeet=$_POST['minsqfeet'];
$maxsqfeet=$_POST['maxsqfeet'];
$minbedrooms=$_POST['minbedrooms'];
$maxbedrooms=$_POST['maxbedrooms'];



// check email & phone validity
if(!preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i", $email) && !preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $phone)) {
    die();
}
$url="id.txt";
$id=file($url);
$next=$id[0]+1;


$fp=fopen("form$next.txt", "a");
$fh=fopen($url, 'w') or die ("cant open file");
$savestring =  $carsearch . "\n" . $homesearch . "\n" . $next . "\n" . $email . "\n" . $phone . "\n" . $item . "\n" . $pricemin . "\n" . $pricemax . "\n"  . $zip . "\n"   . $miles . "\n"   . $vmake . "\n"  . $vmodel . "\n"  . $minmileage . "\n" . $maxmileage . "\n"  . implode(",",$_POST['year']) . "\n" . implode(",",$_POST['carseller']) . "\n" . implode(",",$_POST['doors']) . "\n"  . $propertytype . "\n"  . $city . "\n"  . $state . "\n"  . $homeseller . "\n"  . $minacres . "\n"  . $maxacres . "\n"  . $minsqfeet . "\n"  . $maxsqfeet . "\n"  . $minbedrooms . "\n"  . $maxbedrooms . "\n";
fwrite($fp, $savestring);
fclose($fp);
unlink("id.txt");
$fa=fopen("id.txt", "a");
fwrite($fa, $next);
fclose($fa)


//header("Location:http://www.mywebsite.com/formsubmit.html");
echo "<script type=\"text/javascript\">window.location = \"http://www.mywebsite.com/formsubmit.html"\"</script";
}

unlink($ckfile);
?>

Its a lot to look at, but I am just totally stumped at this point. Thanks again for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:59:10+00:00Added an answer on June 2, 2026 at 6:59 am

    Here is your problem:

        $words = explode(" ", $_POST['item']) { 
    

    Should be

        $words = explode(" ", $_POST['item']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand how the ~/protected/config/main.php work like 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=test_blog', 'emulatePrepare' => true,
I've been searching through this website and have seen multiple references to time deltas,
I recently moved my main website into a new folder: The websites was in
www.mydomain.com = main website m.mydomain.com is a virtual site which maps to www.mydomain.com/m/ I
Struts 1.3 application. Main website is NOT served by struts/Java. I need to forward
My website has a main image that changes depending on what thumbnails you click
My website uses Response.Redirect(~/Main/Main.aspx) type redirects all over the place. Worked flawlessly until the
Example website is http://www.wikihow.com/Main-Page , check the Recent Changes heading on the right side.
My website is about sharing music files and putting it for download. My main
I am developing a website and for the main navigation, I was thinking it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.