Jump to content

Problem with "where item in($array)" query


Perfidus

Recommended Posts

Hi there, I have been running a website with no problems in a shared server, recently I have moved the files to a cheaper one and I'm having some issues in my PHP, even though versions (php, mysql) seem to be equal or newer, one of those issues is the following; I have this query:

SELECT * FROM articles WHERE ref IN (".implode(',', $articles).") AND title LIKE '%$search%' ORDER BY date DESC LIMIT $startvalue, $amount

 

This used to work fine in my old server, now I'm getting this error:

 

Unknown column '455875' in 'where clause'

 

Where 455875 is one of the references in the array, why?

Link to comment
Share on other sites

A more serous question would be why are you storing integers using a varchar data type. That increases the storage requirements, makes every query that references the value slower, and prevents direct ordering and greater-than/less-than comparisons. Integers should be stored using an INT data type.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.