Page 1 of 1

confusing problem ... look within

Posted: Fri May 21, 2004 5:33 am
by WebMonkey

Code: Select all

//user admin swtich
If ($_SESSIONї'rank'] == "admin"){
   $reference = $_SESSIONї'adminvalue'];
         } else {
             $reference = $_SESSIONї'userref'];
}

//debugging test
if ($reference == 572015935){
   echo "correct match";
         } else { 
              echo "match failure";
}

//mysql connection script left out only in this example


//result test
$result = mysql_query("SELECT * FROM messages WHERE messref='$reference'",$MySQLdb);

if ($result){
   echo "you have records";
       } else {
          echo "no records";
}

//outputs

// useradmin switch
// in both cases places the value 572015935 into $reference

//debug test
//in both cases outputs correct match

// result test
// admin = no records
// user = you have records
Why when reference seems to be identical in both situations does the SQL clause work in one occasion and not the other? only difference between the 2 is that one originated from a text box (adminvalue) and (userref) was output from another SQL query earlier on

Posted: Fri May 21, 2004 6:25 am
by launchcode
Place the value in quotes for the comparison - the number is too large for an integer and is being converted to a float which will mess your SQL query up.

if ($reference == '572015935'){

Also what type of SQL field is messref in your table?

Posted: Fri May 21, 2004 7:52 am
by WebMonkey
thanks for the help

well userref is a varchar(40) ... your idea sounds possible but now that i have been playing with it ... the queries have stopped working all together ... what was once working seems not working anymore its becoming worse off

Posted: Fri May 21, 2004 11:56 am
by launchcode
Well post your newly modified code then - the suggestion I made would not effect the rest of the queries.