Hardwarez Posted October 9, 2006 Share Posted October 9, 2006 ???Ok, my php is doing something weird! It seem that one of my functions will no completely run.I placed echo through-out my function and it just stops working half way throug the function.Is there some kind of buffer/size limit to a function?My Function:function IsUserValid ($ipaddr,$Usr) //--------------Check database FUNCTION{ echo '<font color="red"><P>Address: ' . $ipaddr . ', User: ' . $Usr; $query = "SELECT id FROM userlist WHERE clientip='$ipaddr' && user='$Usr'"; $result = mysql_query($query) or die (mysql_error()); $number = mysql_num_rows($result);// check time out time and kill valid IP if timeout $Utime = date("U"); $query = "SELECT Utime FROM userlist WHERE clientip='$ipaddr'"; $result = mysql_query($query) or die (mysql_error()); echo '<P>' . $result; $row = mysql_fetch_array($result) or die(mysql_error()); echo '<BR>rowTime: ' . $row['Utime'] . '</font>';xxxxxxxxxxxxxxxxxxxxxxxNOTHING BELOW THIS RUNS, THE ECHOs DO NOT EVEN WORKxxxxxxxx if ($Utime > $row['Utime']) { $query="UPDATE userlist SET clientip='1.0.0.1' WHERE clientip='$ipaddr' LIMIT 1"; mysql_query($query) or die (mysql_error()); $r='0';// clear flag to require re-validation } if ($r != '0' && $number > '0') $x='1'; else $x ='0';echo 'returning from IsUservalid with: ' . $x; return $x; //END OF FUNCTION} Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/ Share on other sites More sharing options...
roopurt18 Posted October 9, 2006 Share Posted October 9, 2006 Chances are your script has an error and you have error reporting turned off. Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/#findComment-106343 Share on other sites More sharing options...
phporcaffeine Posted October 9, 2006 Share Posted October 9, 2006 You have two conditional statements starting right after you say the method stops. 1.) if $UTime is not greater than $row['UTime'] then that statement will not fire, are you sure $UTime is assigned the right value?2.) if ($r does not equal 0 AND $number is not greater than 0 then $x will equal 0, otherwise it would be 1. Are you sure that $r AND $x are assigned the right values?3.) are you able to use display_errors = on in PHP.INII also noticed you have several OR die()'s, your method might be breaking on one of them.P.S When comparing variables to digits it's best to keep the digit outside of single/double quotes (0 Vs. '0') Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/#findComment-106349 Share on other sites More sharing options...
Hardwarez Posted October 9, 2006 Author Share Posted October 9, 2006 Is it possable to use to many IF statments? Or make them to long?I have error reporting turned on, but I'm not getting any errors..Also, moving my numbers outside the quotes did make the function run completely. Why whould this have forzen the codes execution? Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/#findComment-106470 Share on other sites More sharing options...
trq Posted October 9, 2006 Share Posted October 9, 2006 [quote]Also, moving my numbers outside the quotes did make the function run completely. Why whould this have forzen the codes execution?[/quote]Becasue numbers are not strings. Strings are defined within quotes, not numbers. Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/#findComment-106554 Share on other sites More sharing options...
Hardwarez Posted October 11, 2006 Author Share Posted October 11, 2006 Thank you for the help! :) Link to comment https://forums.phpfreaks.com/topic/23441-my-php-function-will-not-completely-run-it-seems-to-just-stop-execution/#findComment-107447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.