BelowZero Posted April 2, 2012 Share Posted April 2, 2012 I'm trying to update my database so that if someone enters an e-mail address that doesn't exist, the program updates the database with the new address. I've tested everything and $result returns the correct data every time (0 or 1) but if the address doesn't exist, nothing gets updated. I know I'm missing something, just not sure what it is... { $result = mysql_query(" SELECT * FROM PlayerInfo WHERE Player_Email = '$playeremail'"); IF($result) { IF (mysql_num_rows($result) = 0) { //Insert into database: new e-mail address... } } I've also tested the insert into statement and it works, so that's not the issure. Any help appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/ Share on other sites More sharing options...
Muddy_Funster Posted April 2, 2012 Share Posted April 2, 2012 IF (mysql_num_rows($result) = 0) wrong number of = , you need at least 2 Quote Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/#findComment-1333781 Share on other sites More sharing options...
BelowZero Posted April 2, 2012 Author Share Posted April 2, 2012 IF (mysql_num_rows($result) == 0) returns: Fatal error: Can't use function return value in write context in... Quote Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/#findComment-1333782 Share on other sites More sharing options...
chriscloyd Posted April 2, 2012 Share Posted April 2, 2012 Then do this and see if it works $Num = mysql_num_rows($result); if ($Num == 0) { //code here } Quote Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/#findComment-1333783 Share on other sites More sharing options...
BelowZero Posted April 2, 2012 Author Share Posted April 2, 2012 Yes, that did it! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/#findComment-1333784 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.