PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
//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
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?
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