Jump to content

Jiokah

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Jiokah's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys, I just got a really strange fatal error: "Using $this when not in object context" What's strange about it is that the website was working fine for a while with lots of people using it without any errors. Also, the line that the error pointed to was the $this variable, but within object context. No static calls or anything. The function that variable was in worked flawlessly for weeks untouched, with that specific variable being read all the time. Restarting lighttpd fixed the problem immediately. But does anyone know what might of caused it? Memory was the same before and after I restarted lighttpd. Thanks a lot, -Matthew
  2. Ok, something is just horribly wrong here, things are not acting right. I renamed our little function once, no difference, a second time, and I got this: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/sandbox.[website].com/classes.php:1) in /var/www/sandbox.[website].com/index.php on line 35 Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "user" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /var/www/sandbox.[website].com/index.php on line 74 I use output buffering so I should not get the headers already sent error, but I figure I screwed up somewhere with the serialization of my objects, so I re-did the serialization code as follows: function startObjects($array) { foreach ((array) $array as $class) { $object = substr($class, 0, 1); $_SESSION[$object] = isset($_SESSION[$object]) ? $_SESSION[$object] : new $class; $GLOBALS[$object] =& $_SESSION[$object]; } } startObjects(array('messages', 'user', 'processor', 'snippets')); Yes, I like to use the first letter of the class as my object name, I'm just different that way. Anyways, I get this error: <br /> <b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /var/www/sandbox.[website].com/classes.php:1) in <b>/var/www/sandbox.[website].com/index.php</b> on line <b>35</b><br /> <br /> <b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/www/sandbox.[website].com/classes.php:1) in <b>/var/www/sandbox.[website].com/index.php</b> on line <b>35</b><br /> <br /> <b>Fatal error</b>: Class 'messages' not found in <b>/var/www/sandbox.[website].com/functions.php</b> on line <b>68</b><br /> Removed cookies, no more error. I figure it was trying to unserialize an object using a class that has different properties/methods that the object was originally created with. So I run my recurse function, and the arrays merge without the code. Renamed the function again, same thing as above, renamed the class and object, SAME THING. I've SSHed into my server and checked the code first hand to make sure my desktop computer wasn't caching anything, and sure enough all the re-named junk is there. What on earth is going on???
  3. Update... The phantom code still runs even though the function is empty, regardless of the variable names in the () part of the function, although taking out the reference character breaks it's functionality! So: private function recurse_merge_unique($fromArray, &$toArray) { } ...will merge the arrays, and so will: private function recurse_merge_unique($blueberry_jam, &$banana_rum) { } But not: private function recurse_merge_unique($fromArray, $toArray) { } And one last thing, even if I rename the function, it STILL works without the code. How's that for confusing? This makes no sense at all.
  4. APC is enabled with apc.stat = 1, though I have no idea what APC is. As for bytecode cacheing, I really don't know. I've built my server from scratch and I've never looked into bytecode cacheing, so unless it's enabled by default, I don't think it's on.
  5. Nope, it doesn't echo anything, so I guess it's not being called. When it's commented out in the construct function, then the arrays are not merged, if it's not commented out and the function is empty, the arrays are merged. Also, when I take out the recurse function all together, I get a "call to undefined method". My guess is that I have a phantom recurse_merge_unique() function defined somewhere in limbo, as it's in only one place in my entire application.
  6. Ok that I know, but this function DOES do something. The empty function recursively merges the arrays even with no code.
  7. This is one horribly bizare problem: class something { function __construct() { foreach($something as $somethingelse) { $this->recurse_merge_unique($array, $array2); } } private function recurse_merge_unique($fromArray, &$toArray) { foreach ($fromArray as $key => $fromValue) { if (is_array($fromValue) && isset($toArray[$key])) { $this->recurse_merge_unique($fromValue, &$toArray[$key]); } elseif (!isset($toArray[$key])) { $toArray[$key] = $fromValue; } } } } This extremely cut down sample of my code works no problem like this, but the really screwed up fact is that is ALSO works like this: class something { function __construct() { foreach($something as $somethingelse) { $this->recurse_merge_unique($array, $array2); } } private function recurse_merge_unique($fromArray, &$toArray) { } } Empty function! And it works like a charm. I took ALL variables out of the sleep function so nothing is saved, that function isn't found anywhere in my entire application, and I've wiped the site's cookies numerous times so the object isn't getting saved, and yet it still works as if it weren't empty. If I uncomment the mystery function from the contruct function, then it doesn't act of course, but it works like a charm when called despite the fact there being NO CODE in it. Naturally, this has boggled my mind. Any ideas? I've left the recurse function exactly as it is in my script.
  8. Hah! It was the bom, wow thanks dude. I didn't think it was as I had this same problem with ascii encoding. Well who knew, stupid bom. What's the point of it anyways?
  9. Hey guys, I'm still getting this problem, if anyone has any clues I would greatly appreciate them! I don't think it's encoding anymore as I've played around a lot with that and it still does not work. It shouldn't be an error finding it's way into the output either because I use my own error system, not PHPs. This one really has me stumped! Works fine when I save it to a file instead of output. When comparing the two files in notepad, they are identical, except that the broken one has about 20 blank lines at the top. Not only do I not have any spaces in my script, but I've cleared the buffer directly before the header and imagejpeg functions.
  10. Hey guys, I seem to be missing something here, when I output an image to the browser it comes out as broken and I have no idea why. The last project I did was a business card maker that outputted tons of (working) images, and I'm doing everything the same here. I use output buffering, and wiping the buffer right before header() and imagejpeg() doesn't work. I think it may have something to do with my encoding, though I've played around with that too. The only difference between this project and the last is that I'm now using UTF-8 encoding, with the bom. I have define('_ISO','charset=UTF-8'); set as well as UTF-8 with BOM option set in my editer. Could that be affecting this? Any ideas? ???
  11. oohh, in fact....I do have notepad++ set to UTF-8. I'll have to fuddle around to see where/why it's putting that mark in only sometimes, I'm just rather curious. Thanks a ton! That little mystery was bugging me.
  12. Hey guys, Sometimes when I screw up my code, I find a Byte Order Mark (), at the top of the page, and usually (but not always) it's alone. I'm not sure, but I think I get it most when I screw something up with the output buffer. And yes, when I switch to UTF-8 is just goes away, but my question is why does it appear there in the first place? I always fix my code to get rid of it but have never really found out what ever it was that caused it. Any ideas? Thanks! -Matthew
  13. Because that's not accomplishing what I want in one expression. I'm aware of all the hundreds of ways I can accomplish this with minimal code, I'm a fairly advanced programmer. My question was simply regarding syntax, not method. Thanks though
  14. I knew (5 || 6) would return true regardless, as I explained in my previous post, I had simply included that example to give people a better understanding of what I'm getting at. I think your right lemmin, it doesn't look possible. Oh well. I don't really NEED to do this per se, but I think it'd just make my code look neater.
  15. Good suggestions, but I think they over-complicate things a bit more. I was hoping to solve this within a single expression, ie "If variable equals 3 or 6, return true" instead of "If variable equals 3 or variable equals 6, return true". I thought of this example: if ($someVariable == (5 || 6)) {//Do Something} ...but both 5 and 6 are true, therefore the expression would always return true. The actual expression I'm hoping to simplify is the following: (strlen($someNumber) > 16 || strlen($someNumber) < 6) //Returns true or false
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.