RON_ron Posted August 30, 2012 Share Posted August 30, 2012 my code with the problem: $res = sprintf("UPDATE student SET Pas = '%s' WHERE Mail = '%s'", mysql_real_escape_string($Ber), mysql_real_escape_string($Mail)); $resDone = mysql_query($res); I can not get this work? I don't see any mistake in this code?? Could someone please help... I tried echo ($res)... it was blank? (I can assure the variable names are correct) Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/ Share on other sites More sharing options...
darkfreaks Posted August 30, 2012 Share Posted August 30, 2012 could be a mysql syntax error try this and tell me what you get..... $resDone = mysql_query($res) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373762 Share on other sites More sharing options...
RON_ron Posted August 30, 2012 Author Share Posted August 30, 2012 Thanks for the reply darkfreaks. it's blank. Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373764 Share on other sites More sharing options...
scootstah Posted August 30, 2012 Share Posted August 30, 2012 Thanks for the reply darkfreaks. it's blank. There is no syntax error in that line, and the code works fine for me. Post your whole code please. Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373767 Share on other sites More sharing options...
RON_ron Posted August 30, 2012 Author Share Posted August 30, 2012 $query3 =sprintf("SELECT * FROM student WHERE Mail ='%s' AND Usr = '1'", mysql_real_escape_string($Mail)); $query3a = mysql_query($query3); if(mysql_num_rows($query3a) > 0){ $res = sprintf("UPDATE student SET Pas = '%s' WHERE Mail = '%s'", mysql_real_escape_string($Ber), mysql_real_escape_string($Mail)); $resDone = mysql_query($res); } Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373768 Share on other sites More sharing options...
scootstah Posted August 30, 2012 Share Posted August 30, 2012 if(mysql_num_rows($query3a) > 0){ Are you sure that statement is true? Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373771 Share on other sites More sharing options...
RON_ron Posted August 30, 2012 Author Share Posted August 30, 2012 of course it's correct. Quote Link to comment https://forums.phpfreaks.com/topic/267786-mysql-update/#findComment-1373789 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.