lmcm2008 Posted August 2, 2013 Share Posted August 2, 2013 Hi: I have an error that will be very basic, but I don´t see it... I have this first php: <?php session_start(); require ("connecting.php"); require ("searchprofile.php"); connect(); $miuser=$_SESSION['usu']; $supas=$_SESSION['pas']; echo " Welcome: $miuser $supas<br />"; if ( busca_perfil_activo($miuser)==1) { echo "show $miuser<br />"; muestra_perfil($miuser); } else { echo "creating $miuser<br />"; crea_perfil($miuser); } mysql_close(); ?> Ok.... maybe the problem is here: if ( busca_perfil_activo($miuser)==1) { echo "show $miuser<br />"; muestra_perfil($miuser); } else { echo "creating $miuser<br />"; crea_perfil($miuser); } and the function "busca_perfil_activo($miuser) is the following: function busca_perfil_activo($activo) { $sql="SELECT * FROM perfil WHERE USUARIO='$activo' "; $result = mysql_query($sql); $totalreg=mysql_num_rows($result); if($result == 1) { return 1; } else { return 0; } } Why this function always return 0 ?? I have a record that is ok with the search... and will return 1 in that case, but never do it... Why?? Can you help me?? thanks. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 2, 2013 Share Posted August 2, 2013 Your logic is checking if the MySQL query result is an integer, which it isn't. You want to check the number of rows: Change, if($result == 1) to: if($totalreg == 1) Quote Link to comment Share on other sites More sharing options...
Solution lmcm2008 Posted August 2, 2013 Author Solution Share Posted August 2, 2013 Yess... perfect!! What an idiot error!!!! Sorry and thanks.! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.