troubleshooting Question

Compare two strings php

Avatar of team2005
team2005 asked on
HTML
5 Comments1 Solution285 ViewsLast Modified:
Hi!

Have this function, that compares two strings

function sjekkqrkode($lokasjon,$kundeid)
{
    $qrkode1 = hent_tmp_qrkode();
	$qrkode2 = hent_qrkode_lokasjon($kundeid,$lokasjon);
	
	if ( strcmp ( $qrkode1, $qrkode2) == 0  )
	{
	    echo 'HELT LIKE';
		die();
	    return 'like';
	}
	else
	{
	  echo 'ULIKE';
      die();	  
	  return 'ulike';
	}
}

function hent_tmp_qrkode()
{
        $sql = "SELECT tmpqr FROM qrcode";
        $res = mysql_query($sql);
        
        // IF THE QUERY SUCCEEDED
        if ($res)
        {
            // THERE SHOULD BE ONE ROW
            $num = mysql_num_rows($res);
            if ($num)
            {
                // RETRIEVE THE ROW FROM THE QUERY RESULTS SET
                $row = mysql_fetch_assoc($res);
                // STORE THE USER-ID IN THE SESSION ARRAY
                return $row["tmpqr"];
          
            }
			else
			{return 'xx';}
        }
		else
		{
		  return 'xx';
		}
}

function hent_qrkode_lokasjon($kundeid,$lokk)
{
        $sql = "SELECT qrcode FROM Lokasjoner WHERE Kunde_id = '$kundeid' and Lokasjons_id='$lokk'";
        $res = mysql_query($sql);
        
        // IF THE QUERY SUCCEEDED
        if ($res)
        {
            // THERE SHOULD BE ONE ROW
            $num = mysql_num_rows($res);
            if ($num)
            {
                // RETRIEVE THE ROW FROM THE QUERY RESULTS SET
                $row = mysql_fetch_assoc($res);

                // STORE THE USER-ID IN THE SESSION ARRAY
                return $row["qrcode"];
          
            }
			else
			{return 'yy';}
        }
		else
		{
		  return 'yy';
		}
}

Thie function ->  sjekkqrkode  always return ulike ?

Have checked my DB, and are 100% on that they are equal

What is wrong ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros