this has been driving me nuts. It should work. $value2 is an array with two strings in it. mysql_num_rows should return 1 row for each string. instead it returns zero. I simplified it below and cannot get it to work. it should echo "equals one".

$value2 = $_POST['topic'];
               
				foreach($value2 as $key) {
				mysql_connect("localhost", "USER", "PWD");
mysql_select_db("ustackc1_Ustack");
	  
	  
	  	$updatestable = mysql_query("SELECT * FROM `Stacks` WHERE keywords LIKE '%$key%' ORDER BY id DESC LIMIT 1")or die (mysql_error());
			
			$upnum = mysql_num_rows($updatestable); 
				if($upnum==0){ echo "equals zero"; } else { echo "equals one";}
				
				}

For the future, I would recommend that you don't say your mysql password. You can open a connection to a mysql server through the web.

Try this:

$value2 = $_POST['topic'];
               
foreach($value2 as $key)
{
    $con = mysql_connect("localhost", "USER", "PWD");
    mysql_select_db("ustackc1_Ustack", $con);
	  
    $updatestable = mysql_query("SELECT * FROM `Stacks` WHERE keywords LIKE '%".$key."%' ORDER BY id DESC LIMIT 1", $con) or die (mysql_error());
			
    $upnum = @mysql_num_rows($updatestable); 
    if($upnum==0)
    {
        echo "equals zero";
    }
    else
    {
        echo "equals one";
    }

}