0

Working locally on MySQL this works fine, where the two session objects are just a small string of numbers.

...
WHERE stars IN (:stars) AND propType IN (:proptype)");
$stmt->execute(array(
':stars' => $_SESSION['starr'],
':proptype' => $_SESSION['proptype']
));

When I put the code to the live server which uses MariaDB 10 it fails and seems to be just bringing back results that have zero for the stars (the first number in the session for stars

If I hard code the sessions into the SQL then it works fine.

Is there some restriction on IN clauses in a prepared statement, googled the hell out of this and cannot find anything.

I'm using prepared statements thus the execute is:

$stmt->execute(array(':star'=>implode(",",$_SESSION['starr']),':proptype' =>implode(",",$_SESSION['proptype'])));
user1011585
  • 19
  • 1
  • 1
  • 7
  • Possible duplicate of [Binding parameters for WHERE IN clause with PDO](https://stackoverflow.com/questions/7044144/binding-parameters-for-where-in-clause-with-pdo) – GMB Mar 18 '19 at 21:21
  • I'm using multiple IN on both MySQL & MariaDB with no issues (however, I'm not binding them as you bind them in your code). I think you should look at something else, for example on your prod server it might be something different with the session variable filled ($_SESSION['starr']). – fifonik Mar 18 '19 at 21:22
  • 2
    Possible duplicate of [Can I bind an array to an IN() condition?](https://stackoverflow.com/questions/920353/can-i-bind-an-array-to-an-in-condition) – Nick Mar 18 '19 at 21:30
  • Are you trying to bind a comma separated string or array? If so it won't work, you need to bind each parameter separately. – EternalHour Mar 18 '19 at 21:33
  • @EternalHour - i've edited the question to show the exec statement, are you saying this doesn't work? If so it seems crazy to iterate every value – user1011585 Mar 18 '19 at 23:26
  • Solved it using FIND_IN_SET, binding them seperately is way too much work for something simple but the comments made me see it wouldn't work my original way – user1011585 Mar 19 '19 at 18:57

0 Answers0