Jump to content

Why is this query failing?


ghurty

Recommended Posts

Why is this query select not working.

When I have this one, it is always writing a value of 1 to the tmp variable:

$GROUP = $_SERVER["argv"][1]; 
$GROUP = trim($GROUP); 
$GROUP = ltrim($GROUP); 

$USERID = $_SERVER["argv"][2]; 
$USERID = trim($USERID); 
$USERID = ltrim($USERID); 


$link = mysql_connect("localhost", "root", "passw0rd")
    or die("Data base connection failed");
mysql_select_db("dialer")
    or die("data base open failed");

$query = "SELECT *  FROM `list` WHERE ( userid = '$USERID' AND group = '$GROUP' )";
$result = mysql_query($query)
    or die("Web site query failed");


$reccount = mysql_num_rows($result) ;

write("SET VARIABLE tmp $reccount");

However, if I set it like this, then it counts the amount of rows properly:

$query = "SELECT *  FROM `list` WHERE `group` = " . $GROUP;

 

The problem is that I want a count of the amount of records that have the both, the group# as well as userid#.

 

Looking at the debug, I see the values for $GROUP and $USERID are passed onto the script.

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/188854-why-is-this-query-failing/
Share on other sites

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.