Bob-Marley Posted January 2, 2009 Share Posted January 2, 2009 I have created a function which updates a database but the mysql_query isnt running i have used mysql_error to output any errors however there arnt any, it just isnt running the query. Any Help? Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/ Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 £5 PayPal gift if it is solved under the next 20 minutes Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728322 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 c'mon guys its only a little thing for £5 Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728328 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Would you relax? You sound this is a life threatening problem... it just isnt running the query. Any Help? What are we supposed to do, guess? Show us some code! Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728332 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 Sorry lol function Update($npass, $username){ $npass=md5($npass); mysql_query("UPDATE users SET password='$npass' WHERE username='$username'"); } Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728349 Share on other sites More sharing options...
dennismonsewicz Posted January 2, 2009 Share Posted January 2, 2009 are you getting any errors? Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728354 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Before I do anything I would advise you to do two things... 1) Put your queries in strings so you can easily debug: 2) Put or die(mysql_error()); at the end of your queries so it displays any errors, which you claimed not to have any. function Update($npass, $username){ $npass=md5($npass); $sql="UPDATE users SET password='$npass' WHERE username='$username'"; echo $sql; mysql_query($sql) or die(mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728356 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 Nope, no errors it just doesnt run it Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728358 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 What did the $sql echo out? Can you post where you're calling it and what you're passing in... Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728361 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 Let me just try what you suggested Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728363 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Nope, no errors it just doesnt run it That's because you need to add the or die(mysql_error()); to see it. Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728375 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 Thanks for the help but i have solved it, thankyou for helping me echo the query, it wasnt recognising the username with $_SESSION so i posted it through the function Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728386 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Thanks for the help but i have solved it, thankyou for helping me echo the query, it wasnt recognising the username with $_SESSION so i posted it through the function I see. I solve most of my problems with echos... Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728388 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Author Share Posted January 2, 2009 Lol, echo always solves you just have to put it in the right place and echo the right things Quote Link to comment https://forums.phpfreaks.com/topic/139242-solved-function/#findComment-728390 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.