cardi777
cardi777

Reputation: 563

PHP having issues

I have made a script that run various loops and does some SQL inserts. I can't post it as it's just too big, and it's unfair for people to try and fix it.

But, as I get more and more things for it to loop, it appears to be struggling to calculate everything and failing to assign values to arrays sometimes.

For example $myvar[$i] = 'abc' just doesn't work. I echoed the values before I assigned them to make sure I wasn't trying to insert nulls, but that's not the case.

I reordered the loop to see if it was somehow related to other data problems, but the missing values were random. I have tried and tried to work out how to fix this, I bumped up the memory allowance, checked my timeout settings, it's all fine.

I tried uploading the script in binary and ASCII, didn't solve it.

I tried deleting white space around the top and bottom, didn't solve it.

I checked to see if my version was out of date, its PHP Version 5.3.4 - problem?

I gently rocked my pc from side to side, didn't solve it...

I've never seen PHP screw up like this, it's always my fault. But this time it seems like PHP is the issue here.

My questions are:

  1. Does PHP ever miss a beat like this? Perhaps I found a bug?
  2. How can I fix this sucker, you guys are my last resort. Perhaps some PHP settings I am not aware of?
  3. Does PHP drop the ball when loops are too large or too complicated?

Upvotes: 0

Views: 102

Answers (2)

Tyler Biscoe
Tyler Biscoe

Reputation: 2432

Try using addslashes() or mysql_real_escape_string() for your values and see if that works.

A while back I had a problem with something that sounds (only vaguely) similar to what your describing. Kept hitting my head against the wall until I realized what I had left out.

If that doesn't work your first step would be to figure out what values it's accepting and which it isn't. Look for a pattern. If it's truly random then that's one thing, but it rarely is.

Upvotes: 0

linepogl
linepogl

Reputation: 9355

  1. PHP sucks, but not THAT much.
  2. Use an IDE with a debugger for step by step execution with breakpoints to see what's really going on. I would suggest PHPStorm with XDebug, but there are several other tools out there.
  3. Go to 1.

Upvotes: 6

Related Questions