ksun Posted January 16, 2013 Share Posted January 16, 2013 OK, for some reason this function wont execute mysql_query when called upon. function attack() { mysql_query("UPDATE user SET HP = HP - 10 WHERE username = '$user'"); } to my best knowledge, i don't see why this wont work. i am 100% sure there is nothing wrong with the mysql_query. btw if am calling it, simply with this "attack();" so if anyone can help that would be gr8 Quote Link to comment https://forums.phpfreaks.com/topic/273220-faulty-function/ Share on other sites More sharing options...
Jessica Posted January 16, 2013 Share Posted January 16, 2013 There is definitely something wrong with the query. I can see what it is right away. Figuring it out would expose what's wrong with your function. If you were checking for errors, it'd be a lot clearer. See the link in my signature on how to debug your SQL. Quote Link to comment https://forums.phpfreaks.com/topic/273220-faulty-function/#findComment-1406011 Share on other sites More sharing options...
ksun Posted January 16, 2013 Author Share Posted January 16, 2013 (edited) woops, just figured out that PHP functions cannot see variables unless they are passed, or declare it global yep i'm that newb. Edited January 16, 2013 by ksun Quote Link to comment https://forums.phpfreaks.com/topic/273220-faulty-function/#findComment-1406018 Share on other sites More sharing options...
Jessica Posted January 16, 2013 Share Posted January 16, 2013 Quote Link to comment https://forums.phpfreaks.com/topic/273220-faulty-function/#findComment-1406019 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.