php - SELECT * FROM table WHERE row IN ('list') -


i'm having trouble code below, it's giving me syntax error , can't find in manual or online it. thoughts on how run?

1st attempt:

<?php require("../dbpass.php");    $types = array('buyer','seller','buyer / seller','investor'); $typeslist = implode ("','", $types);  $sql = "select * contacts contacttype in ('$typeslist') , status = 'new' order date desc"; $result = mysqli_query($mysqli,$sql) or die ("error: ".mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { 

2nd attempt (put "=" after "in"):

<?php require("../dbpass.php"); $types = array('buyer','seller','buyer / seller','investor'); $typeslist = implode ("','", $types);  $sql = "select * contacts contacttype = in ('$typeslist') , status = 'new' order date desc"; $result = mysqli_query($mysqli,$sql) or die ("error: ".mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { 

this rest of code:

$firstname = $row ['firstname'];       echo'.$firstname.'; } ?> 

error: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'in ('buyer','seller','buyer / seller','investor') , status = 'new' order da' @ line 1

you have ; after while condition.

while ($row = mysqli_fetch_array($result)); { 

should

while ($row = mysqli_fetch_array($result)) { 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -