0

I have this piece of code which i use in order to get all the values inside a column And save them in an array.

$sektori="SELECT * FROM userss WHERE Username='".$_SESSION['user_name']."'" 
or die(mysql_error());  
$resektor = odbc_exec($connection, $sektori) or die(odbc_error());
while( $row = odbc_fetch_array($resektor) ) {
$ids_sektor = explode("/",$row['sektori']);
}

I need to add this condition here:

$strSQL = "SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added
FROM formas 
LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET WHERE formas.data_fillim >= '$yesterday' AND formas.data_fillim <= '$tomorrow' AND  sektori_pergjegjes IN ($ids_sektor) ORDER BY formas.id DESC";

It says i have a syntax error, but i don't know..maybe i'm doinf the wrong thing, help please.

Thanks in advance.

2
  • Where does it say there's a syntax error? Commented Feb 28, 2013 at 14:26
  • it says: Invalid column name 'Array' Commented Feb 28, 2013 at 14:27

1 Answer 1

2

Change your condition to that one:

"AND  sektori_pergjegjes IN ('" . implode('\',\'', $ids_sektor) . "')"
Sign up to request clarification or add additional context in comments.

5 Comments

Show the query that is generated into $strSQL with my change
$strSQL = "SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added FROM formas LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET WHERE formas.data_fillim >= '$yesterday' AND formas.data_fillim <= '$tomorrow' AND sektori_pergjegjes IN (" + implode(',', $ids_sektor) + ") ORDER BY formas.id DESC";
OK, check now - replaced + with .
Please one question, so i echo it and i get this result SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added FROM formas LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET WHERE formas.data_fillim >= '20130227' AND formas.data_fillim <= '20130301' AND formas.sektori_pergjegjes IN (B) ORDER BY formas.id DESC
Finally :):) Thanks very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.