i'm currently trying to work through a problem where an entry gets added into a database if it doesn't exist. However if it does and the username matches one of the database, it gets updated to whatever the other inputs are. However I am currently getting the error:
sqlsrv_num_rows() expects parameter 1 to be resource
My code is shown below:
$describeQuery = ("INSERT INTO User
(userID, first_name, last_name)
VALUES ('".$Username."', '".$FirstName."', '".$LastName."');");
$results = sqlsrv_query($conn, $describeQuery);
if(sqlsrv_num_rows($describeQuery) == 0)
{
echo 'New entry added';
}
else
{
$describeQuery2= ("UPDATE User
SET first_name = '".$FirstName."',
last_name = '".$LastName."'
WHERE userID = '".$Username."'");
$results = sqlsrv_query($conn, $describeQuery2);
$describeQuery3= ("UPDATE Current_Location
SET first_name = '".$FirstName."',
last_name = '".$LastName."'
WHERE userID = '".$Username."'");
$results = sqlsrv_query($conn, $describeQuery3);
echo '<br>';
echo '<br>';
echo 'Entry updated';
Any help would be appreciated.