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 7816241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:47:54+00:00 2026-06-02T05:47:54+00:00

I have an issue with PDO binding parameters, the parameters that are set are

  • 0

I have an issue with PDO binding parameters, the parameters that are set are not being pushed into the query when it is executed on the database. I have witnessed this by getting MySQL to log the queries to a file.

If I execute against the server – I see this in the log file.

SELECT sg.locID, ( 3959 * acos( cos( radians(53.21333) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(-2.4354014) ) + sin( radians(53.21333) ) * sin( radians( latitude ) ) ) ) AS distance FROM location_geo sg HAVING distance < 1000 ORDER BY distance LIMIT 0 , 20

When executed from within PHP/PDO

SELECT
  sg.locID,
  ( 3959 * acos( cos( radians(NULL) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(NULL) ) + sin( radians(NULL) ) * sin( radians( latitude ) ) ) ) AS distance
FROM
  location_geo sg
HAVING
  distance < 1000
ORDER BY distance LIMIT 0, 20

Here is the code thats executed by PHP

$lat = 53.21333;
$lng = -2.4354014;
$limit = 10;
$start = 0;

$query = "
    SELECT
      sg.locID,
      ( 3959 * acos( cos( radians(:latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:longitude) ) + sin( radians(:latitude) ) * sin( radians( latitude ) ) ) ) AS distance
    FROM
      location_geo sg
    HAVING
      distance < :radius
    ORDER BY distance LIMIT :start, :limit
";

$stm = Modules::db()->prepare($query);
$stm->bindValue(":radius", 1000, PDO::PARAM_INT);
$stm->bindParam(":latitude", $lat, PDO::PARAM_INT);
$stm->bindParam(":longitude", $lng, PDO::PARAM_INT);
$stm->bindParam(":start", $start, PDO::PARAM_INT);
$stm->bindParam(":limit", $limit, PDO::PARAM_INT);
$stm->execute();

Heres my table

CREATE TABLE `location_geo` (
  `locID` int(11) unsigned NOT NULL,
  `latitude` double DEFAULT NULL,
  `longitude` double DEFAULT NULL,
  PRIMARY KEY (`locID`)
)

Dummy data –

INSERT INTO `location_geo` (`locID`, `latitude`, `longitude`)
VALUES
    (1, 53.21333, -2.4354014),
    (2, 53.213435, -2.4345214);

I have tried replacing the bindParams and putting the data into an array within the execute call however the outcome is the same.

In case you missed it, the values for latitude and longitude remain null. No errors from PDO.

Weird.

  • 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-02T05:47:58+00:00Added an answer on June 2, 2026 at 5:47 am

    For debugging purposes I use setAttribute(). Like this for example:

    setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
    

    This way it will tell you if you make any errors and what they are.

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

Sidebar

Related Questions

I have an issue with PDO that I'd really like to get an answer
Strange issue - I have a live copy of a database class (using PDO)
I have issue with Win2003 that Java Applet Closes IE for Users not Admins.
I'm trying to insert data into a database that I have on my server.
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue with an open source C++ project that I have been
I have written a PHP script to pull a query from an Oracle database
Im writing sql query and i have issue which i cannot fix. I'm trying
I have an issue, I'm looping threw a set of values and then creating
I have issue with url rewrite. I have a site example.com that has a

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.