Infinitive Posted September 6, 2008 Share Posted September 6, 2008 I have come across the most baffling problem. And although it has resolved itself at the moment, I'm very much afraid that it will come back as it was a showstopper. Here's my code (irrelevant parts snipped) function prodStart( $UserID, $WHID, $TotHours, $Quant, $ProductID) { // Watchpoint 1, inserted for debugging error_log("The value of WHID in the function is " . $WHID, 3, "../Logs/myLogFile.txt"); << Snipped code that works fine >> return $Result; } << Snipped irrelevant and functional code up do this part >> $query_Info = sprintf( "SELECT WarehouseID FROM Warehouse_List WHERE UserID = %d", $varUserID); $Info = mysql_query($query_Info) or error_log(mysql_error(), 3, "../Logs/myLogFile.txt"); $row_Info = mysql_fetch_assoc($Info); // Watchpoint 2, inserted for debugging error_log("The value of WHID before the function is " . $WHID, 3, "../Logs/myLogFile.txt"); $startResult = prodStart( $varUserID, $row_Info['WarehouseID'], $varTotHours, $varQuant, $varProductID); << Snipped end >> Fairly straightforward, I would think. To begin, neither of the error_logs I labeled "watchpoint" existed. And this code has worked for weeks now, and has never stopped working on the test server. Here's what happened live though: 0) Something seemed to be going wrong inside the prodStart() function, so that update statements weren't running properly, etc. 1) I put in "Watchpoint 1" with code to list all the values. $WHID turned out to be wildly incorrect. (Should be: 1023. Reported value: 4.something) 2) I put in "Watchpint 2" to see what was getting passed in. $row_Info['WarehouseID'] reported the proper value. Not only that, the $WHID at "Watchpoint 1" also reported correctly, and the function worked! 3) Pulled out both watchpoints, and it all runs fine now. And I had a very similar problem elsewhere, occurring at the same time. It was a different function but I'll use this one for example just to reduce the clutter. Again it was a database-pulled value being passed into a function. This time it was like an extra value appeared in the calling function, because when I called inside they were all assigned one lower than they should have been. (So instead of $Quant = $varQuant, I got $Quant = $varTotHours and $ProductID = $varQuant.) And once again, echo $WHID inside the function was wrong. But echo $row_Info['WarehouseID'] outside the function not only was correct, but fixed it. I can't imagine for the life of me how this could happen. How it could get the wrong value over and over, until I echoed it, and then get the right value from then out. And it went from failing for multiple users to working for multiple users, so it wasn't just that one value. The only thing I can imagine being relevant was that we added a few new indexes to the database two days ago. But the Warehouse_List table wasn't even one of the ones we added to! Like I said, it has since resolved itself. And I've bounced the servers just for good measure. But this defies all my logic. Anyone have a guess? Link to comment https://forums.phpfreaks.com/topic/123041-it-works-when-it-knows-youre-watching/ Share on other sites More sharing options...
Infinitive Posted September 8, 2008 Author Share Posted September 8, 2008 Anyone have a guess? I know it's not strictly the PHP that's flawed but I'm hoping someone who's experieneced will know enough to say "oh yeah it's something with XYZ in the memory subframe structure. Go reconfigure the yadda yadda." Because then at least I'd know what direction to look in. Right now I'm completely lost. Link to comment https://forums.phpfreaks.com/topic/123041-it-works-when-it-knows-youre-watching/#findComment-636241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.