Salve a tutti,da poco mi sono avvicinato a php e mysql.Volevo implementare un sistema semplice di login,tramite il quale un utente,una volta autenticatosi, accede a delle risorse.Visto che è la prima volta,utilizzo easyphp 5.2.10 . Quando cerco di autenticarmi tramite root,la query viene effettuata,ma la funzione mysql_num_rows mi ritorna 0 come parametro e quindi fallisce l'autenticazione. Cosa sto sbagliando? vi posto il codice in questione

codice:
<?php 		 	     function escapeString($string) 		{ 		  if(get_magic_quotes_gpc()) 		  { 		    $string = stripslshes($string); 			return mysql_escape_string($string); 		  } 		  else 		  { 		    return mysql_escape_string($string); 		  } 		} 		 		 		session_start();         echo "<div align=\"center\"> sessione utente partita </div>"; 		 		pagina dopo il login 		if(isset($_SESSION['login'])) 		{ 		  header("location:risorse.php"); 		} 		 		 		if(isset($_POST['submit']) && (trim($_POST['submit']) == 'Login')) 		{ 	 			  		 			if(!isset($_POST['username']) || ($_POST['username'])== "") 			{ 			  echo " 			   <div align=\"center\"> 					<table width=\"400\" height=\"100\" cellpadding=\"10\" cellspacing=\"0\" border=\"1\"> 						<tr> 							<td align=\"center\"> 							    

<h2> Errore 001 : Devi inserire il nome utente </h2></p> 							</td> 						</tr> 					</table> 			   </div> 			  	 				"; 			} 			 	  			 			else 			{ 			 $username = trim(filter_var($_POST['username'],FILTER_SANITIZE_STRING)); 			 $password = trim(filter_var($_POST['password'], FILTER_SANITIZE_STRING)); 			 $password = escapeString($password); 			  			 $username = $_POST['username']; 			 echo $username." ".$password; 		   			 if($username == 'root') 			 { 			   echo "ok root"; 			   include 'config_root.php'; 			   $root = 1; 			 }              else 			 { 			    			   include 'config_utente.php'; 			   $root=0; 			 } 			  			  			 $sql = "SELECT * FROM utenti WHERE username='$username' and password ='$password'"; 			 			 			 $result = mysql_query($sql); 			  			 			 if($sql=FALSE) 			 { 			   echo"errore".mysql_error(); 			   echo "<div align=\"center\"> 					<table width=\"400\" height=\"100\" cellpadding=\"10\" cellspacing=\"0\" border=\"1\"> 						<tr> 							<td align=\"center\"> 							    

<h2> Errore 003 : Username o Password errata </h2></p> 							</td> 						</tr> 					</table> 			   </div> "; 			    			 } 			 $num_righe = mysql_num_rows($result); 			 echo $num_righe; 			 if(!$num_righe) 			 { 			   echo " ".mysql_error(); 			   echo " 			   <div align=\"center\"> 					<table width=\"400\" height=\"100\" cellpadding=\"10\" cellspacing=\"0\" border=\"1\"> 						<tr> 							<td align=\"center\"> 							    

<h2> Errore 004 : Username o Password errata</h2></p> 							</td> 						</tr> 					</table> 			   </div> 			  	 				"; 			  			 } 			 else 			 { 			   header("location:risorse.php"); 			 } 			 			} 		  	 		  		}
Ho anche aggiunto degli utenti nella tabella utenti del database login creato da me,quindi una volta autenticato non dovrebbe tornarmi 0 come risultato di mysql_num_rows. Grazie a tutti in anticipo