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. 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 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... 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 } 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. Link to comment https://forums.phpfreaks.com/topic/260222-cant-update-database/#findComment-1333784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.