Phpfr3ak Posted October 12, 2010 Share Posted October 12, 2010 Hi, fairly new to php, can't seem to figure out why this isn't working, it did before i added the $level_type aspect in... which i need to work with the way ive changed my script, any ideas as to why its not working? if ($token == $_SESSION['token']){ $sql = "SELECT * FROM skills WHERE id=$sid"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); //code goes here if ($playerdata['$level_type'] < $res['level_req']) { echo "You don't have the required level to learn this skill<br><br><a href='doresearch.php?sid=$res[id]'>Return to skill points!</a>"; } else { Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 12, 2010 Share Posted October 12, 2010 You've neglected to say what the actual problem is. Quote Link to comment Share on other sites More sharing options...
Phpfr3ak Posted October 12, 2010 Author Share Posted October 12, 2010 It's echoing You don't have the required level to learn this skill, but i don't see as why... Quote Link to comment Share on other sites More sharing options...
optikalefx Posted October 12, 2010 Share Posted October 12, 2010 its echoing because the value of $playerdata['$level_type'] is less than the value of $res['level_req'] Most likely those values aren't what you are expecting them to be. Check those guys separately. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 12, 2010 Share Posted October 12, 2010 Lose the single quotes from <?php$playerdata['$level_type']?> just use <?php$playerdata[$level_type]?> Variables contained in strings delimited by single quotes are not expanded. Ken Quote Link to comment Share on other sites More sharing options...
Phpfr3ak Posted October 12, 2010 Author Share Posted October 12, 2010 I think ive found the issue i think its something along the lines of; if ($playerdata($res[$level_type]) < $res['level_req']) { Yet its not working any ideas? :s sorry im really crummy at php atm trying to gather the basics Quote Link to comment Share on other sites More sharing options...
aleX_hill Posted October 12, 2010 Share Posted October 12, 2010 $sql = "SELECT * FROM skills WHERE id='$sid'"; --> include quotes around '$sid' and see if that changes things. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 12, 2010 Share Posted October 12, 2010 If the id field is numeric, you shouldn't have quotes around the value. Ken Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 12, 2010 Share Posted October 12, 2010 i prefer to quote EVERY value. that way, there is never a question to quote or not. is there a reason to not quote numbers? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.