mysql - PHP comparing two datavalues -


i've been trying compare 2 strings, 1 username user entering, , 2nd 1 data program pulls database. here php code:

$sqlcheck = "select username location username ='$usernamebeingreq'" ;  $result2 = mysqli_query($con, $sqlcheck); $result2 = mysql_fetch_array($result2); $resultcheck = false; //mysqli_query($con, $sqlcheck); if((strcmp($result2, $usernamebeingreq) == 1)) {     $sql="insert pending_req (fromuser, touser) values ('$username', '$usernamebeingreq')";     $resultcheck = true; } 

$usernamebeingreq equal user enter in, , result should equal when pulls database. i'm not sure why it's not working correctly.

you cannot combine mysql_ , mysqli_ this. also, need iterate through result set value , compare then:

$result2 = mysqli_query($con, $sqlcheck); while ($row2 = mysqli_fetch_array($result2)) {     $username_to_check = $row2['username']; } $resultcheck = false;  if((strcmp($username_to_check , $usernamebeingreq) == 1)) /*  rest of code */ 

more mysqli_fetch_ functions: http://php.net/manual/en/mysqli-result.fetch-array.php


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -