I need some help on this please. The query below will not work unless I physically add a record into the database with my email address FIRST. It's driving me crazy. Doesn't this query say IF the $requestor exists UPDATE and if he/she doesn't the INSERT into the database?? $requestor, in this case, is my email address. I have printed the $requestor and do see my email address at the top of the screen. What am I don't wrong?
Code: Select all
if ($_POST['save']) {
$query = "SELECT * FROM banking WHERE username = '".$requestor."' " ;
$result = mysql_query($query) or die("query: $query<br>" . mysql_error());
if (mysql_num_rows($result) >= 1) {
$sql = "UPDATE banking SET ".$fields1." WHERE username = '".$requestor."' " ;
} else {
$sql = "INSERT banking SET ".$fields1." WHERE username = '".$requestor."' " ;
}
mysql_query($sql,$con) or die("query: $query<br>" . mysql_error());
}Like I said, everything works perfectly as long as I pre-populate the db with my email address in the 'banking' table first...
Thank you in advance for any help.