Monk3h Posted June 25, 2008 Share Posted June 25, 2008 My script works fine untill i try and see if somthing is == to a variable. <?php include ("header.php"); function idcheck($id) { $check = mysql_fetch_array(mysql_query("SELECT * FROM `alphaground` WHERE `id` = '$id'")); if ($check[ownerid] = $stat[id]){ Print "<img src= images/keyyou.png>"; }else{ Print "<img src= images/keyneu.png>"; }} ?> if ($check[ownerid] = $stat[id]){ Thats the problem part, my ID is 1 and i own 1 land, when i replace $stat[id] with my ID is shows the land i own on the map. When i use $stat[id] (which gets the ID of the user which is me) it dosnt work.. :S When i Print $stat[id] it prints my ID, so my problem will be that im using an incorect syntax inside of a function maybie? Any ideas? Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/ Share on other sites More sharing options...
rhodesa Posted June 25, 2008 Share Posted June 25, 2008 double equals, not single equals == ...you even said it right on the first line of your post Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574123 Share on other sites More sharing options...
Monk3h Posted June 25, 2008 Author Share Posted June 25, 2008 I wish it was that easy, unfortunatly that did not old my problem. It is still not recognising $stat[id] inside the function. Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574127 Share on other sites More sharing options...
kenrbnsn Posted June 25, 2008 Share Posted June 25, 2008 Where is "$stat['id']" coming from. It's not being passed into the function, so it's not defined. Ken Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574131 Share on other sites More sharing options...
Monk3h Posted June 25, 2008 Author Share Posted June 25, 2008 $stat is defined inside header.php should i redefine it inside the function? Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574132 Share on other sites More sharing options...
rhodesa Posted June 25, 2008 Share Posted June 25, 2008 you should pass it as an argument, but you can also add: global $stat; as the first line of the function edit: But passing it as an argument is HIGHLY recommended over global Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574133 Share on other sites More sharing options...
kenrbnsn Posted June 25, 2008 Share Posted June 25, 2008 Also, do you want to compare against the value or "$stat['id']" or "$stat[$id]"? Ken Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574136 Share on other sites More sharing options...
Monk3h Posted June 25, 2008 Author Share Posted June 25, 2008 I just want to use it as a variable so i can use $stat[feild name here] $stat defines all the feilds in my players table that aply to that play. Where user = $user & pass = $pass basicly. Link to comment https://forums.phpfreaks.com/topic/111848-function-problems/#findComment-574144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.