i have the following query:

1.$query="SELECT * FROM ab_service WHERE account_id=$account_id AND sku='".$sku."'";



2.$query="SELECT * FROM ab_service WHERE account_id=$account_id AND sku='$sku'";

none of the above seems to work.the problem is with $sku var because when i dont put it as the condition, i get results.what is the problem ? the variable $sku is already asigned from another table.

n, i get results.what is the problem ? the variable $sku is already asigned from another table.

Have you echo query? And does echoed query work in phpmyadmin?

Hello mogaka ,

did you declare sku earlier?

<?php
 $query = "SELECT emp_no FROM employees WHERE dpt_no = '%s'";
(....)
$var = 'sku';
$qstring = sprintf($query, $var);
 mysql_query($qstring);
 ?> 

one question though...why is $account not in single quotes while $sku is?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.