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
https://forums.phpfreaks.com/topic/187391-problem-with-where-item-inarray-query/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.