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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:25:42+00:00 2026-05-25T18:25:42+00:00

My model: function version() { $this->load->database(); $this->db->select(‘location_id’); $this->db->from(‘geo_blocks’); $this->db->where(2057793231 BETWEEN `ip_start` AND `ip_end`); echo

  • 0

My model:

    function version()
    {
        $this->load->database();

        $this->db->select('location_id');  
   $this->db->from('geo_blocks');  
   $this->db->where("2057793231 BETWEEN `ip_start` AND `ip_end`"); 
 echo   $query=$this->db->get()->row();  

    }

The error I’m getting:

A Database Error Occurred

Error Number: 1054

Unknown column ' ip_start <= 2057793231 AND ip_end >= 2057793231' in 'where clause'

SELECT `location_id` FROM (`geo_blocks`) WHERE ` ip_start <= 2057793231 AND ip_end >= 2057793231

Line Number: 93

But the query works fine in PHPMyAdmin:

SELECT * FROM `geo_blocks` WHERE 2057793231 BETWEEN `ip_start` AND `ip_end`

I also tried different queries which produce the same output in PHPMyAdmin, but not in CodeIgniter:

$this->db->where("ip_start <= 2057793231 AND ip_end >= 2057793231"); 

What am I doing wrong?

  • 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-05-25T18:25:43+00:00Added an answer on May 25, 2026 at 6:25 pm

    You’re using the where()-function wrong. The entire point with the where function is for the system to determine where the column is, and what value to escape in order to prevent mysql injections.
    In this case the first parameter needs to be the columns and the second one the value:

    $this->db->where('ip_start <=', 2057793231);
    $this->db->where('ip_end >=', 2057793231);
    

    Note that you can call the where() function more then once. It simply adds an AND between the 2 conditions.

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

Sidebar

Related Questions

This doesn't seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m)
Given this very familiar model of prototypal construction: function Rectangle(w,h) { this.width = w;
I have been testing inline function calls in C++. Thread model: win32 gcc version
I am trying to model a transfer function block for say 1/(s+1). What is
I have a function in my Comic Model as such: <?php class Comic extends
I have defined a function in my Navigation model that executes a query, and
Django's get_or_create function always cause get() returned more than one Model name error in
i have the following function to override the default save function in a model
I've created an Entity Data Model and imported several stored procedures as Function Imports.
I'd like to create a callback function in rails that executes after a model

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.