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

  • SEARCH
  • Home
  • 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 8858387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:49:02+00:00 2026-06-14T14:49:02+00:00

I have been stuck over this for almost a day now and I can

  • 0

I have been stuck over this for almost a day now and I can not figure out whats the problem here. I need $_POST['brand'] in the SQL statement here and I get a blank.

// sql for getting nearby stores
$sql = "SELECT *, ( 3959 * ACOS( COS( RADIANS(".$_POST['lat'].") ) * COS( RADIANS( latitude ) ) * COS( RADIANS( longitude ) - RADIANS(".$_POST['lng'].") ) + SIN( RADIANS(".$_POST['lat'].") ) * SIN( RADIANS( latitude ) ) ) ) AS distance
FROM stores
WHERE brand='".$_POST['brand']."'
HAVING distance <= ".$_POST['distance']."
ORDER BY distance";

This is the form in the PHP file.

<form method="post" action="./index.php" id="store_locator">
    <fieldset>
        <legend>Store Locator</legend>
        <div class="input">
            <label>Address/Postcode: <span class="required">*</span></label>
            <input type="text" class="texta" name="address" id="address" value="<?php if(isset($_POST['address'])){ echo $_POST['address'];} ?>" />
            <span>e.g: "Sydney", "Magill Road"</span>
        </div>
        <div class="input">
            <label>Brand: <span class="required">*</span></label>
            <select name="brand" id="brand">
                <option selected="selected" value="bmw">BMW</option>
                <option value="fiat">Fiat</option>
                <option value="ford">Ford</option> 
            </select>

            <label>Distance: <span class="required">*</span></label>
            <select name="distance" id="distance">
                <?php
                // populate selected option
                $selected = 1;
                if(isset($_POST['distance'])) {
                        $selected = $_POST['distance'];
                }
                ?>
                <?php foreach($distances as $k=>$v): ?>
                <option value="<?php echo $k; ?>" <?php if($selected == $k){ echo 'selected="selected"';} ?>><?php echo $v; ?></option>
                <?php endforeach; ?>
            </select>
        </div>
        <div class="input buttons">
            <button type="submit" name="find" id="find">Find</button>
        </div>
        </br>
        <input type="button" value="Reset Map" onclick="reset2();" />
    </fieldset>
</form>

What am I missing here? Strangely $_POST['distance'] is getting value. Please help.
If I echo the SQL I see brand ='' in the SQL statement.

This is the SQL code getting executed:

SELECT *, ( 3959 * ACOS( COS( RADIANS(-31.9530044) ) * COS( RADIANS( latitude ) ) * COS( RADIANS( longitude ) - RADIANS(115.85746930000005) ) + SIN( RADIANS(-31.9530044) ) * SIN( RADIANS( latitude ) ) ) ) AS distance FROM stores WHERE brand='' HAVING distance <= 30 ORDER BY distance

Contents of $_POST

array(5) {
    ["ajax"]=> string(1) "1"
    ["action"]=> string(17) "get_nearby_stores"
    ["distance"]=> string(1) "5"
    ["lat"]=> string(11) "-31.9530044"
    ["lng"]=> string(18) "115.85746930000005"
}
  • 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-14T14:49:04+00:00Added an answer on June 14, 2026 at 2:49 pm

    That comment thread is getting too long.

    [“ajax”]=> string(1) “1”

    You appear to be posting using ajax. We need to see the javascript you are connecting to the submit button.

    You likely forgot to tell jQuery (or whatever function you are using) to serialze the brand select.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been stuck with this problem for over a week now. Hopefully some one
I have been stuck with this problem for a while now. I know that
I have been stuck on this for a while now and I cannot seem
so i have been stuck with this issue for 3 weeks now and i
i know this is basic but somehow i have been stuck here for some
Well I have been trying this problem for over 10 hours and have no
I have been all over this one, and I am just plumb stuck. I
I've been stuck on this for a few days now and can't seem to
I've been stuck with this problem from a couple of days and I can't
I've searched all over and I can't figure this one out. I am working

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.