[PHP] Re: php mySql question
Sure that your php.ini is located correctly? I have installed php 5.0.4 on my windows 2000, IIS 6.0 server. PHP works but when I try to connect to MySQL I get the Fatal error: Call to undefined function mysql_connect(). I have uncommented the line in the php.ini file that says 'extension=php_mysql.dll'. I have path variables set for both c:\php and c:\php\ext. One very peculiar thing that I noticed when I ran phpinfo() is that it shows the extension_dir is set to c:\php5 even though in my php.ini file it is set to c:\php. I have a feeling that this is where the problem exists. Any advice would be appreciated. Thanks, NK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object Inheritance, get_class() and a static function call
Hello Jochem, > Axel lets start again. Okay. > SO: explain, please, why and what you are trying to do (DETAILS!). > don't dumb it down because that just makes the problem look moot. I need the classname to register variables in the session. It's complicated. There are a lot of inheritences. Please take a look at the code: class onObject { // ... } abstract class onAplObject extends onObject { protected static function registerVariable($key, $value) { $theRealClassName = ???; # $theRealClassName = get_class($this); # output is --> Undefined variable: this in ... # $theRealClassName = get_class(self); # output is --> Notice: Use of undefined constant self ... # $theRealClassName = __CLASS__; # => $theRealClassName=="onAplObject" # $theRealClassName = debug_backtrace()[1]['class']; # => $theRealClassName=="onDbTableEdit" # $theRealClassName = debug_backtrace()[0]['class']; # => $theRealClassName=="onAplObject" $_SESSION[$theRealClassName.'_'.$key]=$value; } } class onDbTableEdit extends onAplObject { public static function show() { self::registerVariable("listsort", "id"); } } class onUseradmin extends onDbTableEdit { // } onUseradmin::show(); Best regards Axel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object Inheritance, get_class() and a static function call
Hello Jochem, either you tested some different code to what you posted above OR (your build of?) 5.0.3 is borked. sorry, I didn't tested the code at all, because my code is more complex. I just tried to show the problem. class ClassA { public static function getClassName() { return get_class($this); // [1] // or [2] return get_class(self); // or [3] return __CLASS__; } } class ClassB extends ClassA { } echo ClassB::getClassName(); I am searching for a function to use in line [1] so that the script's output is "ClassB". I tested this on 5.0.2 and 5.0.4 and both did exactly what I expected, namely output nothing - $this is not defined when you call ClassB::getClassName() (because you make a static call) so nothing is the only logical output. my fault, again, sorry. I jumbled the different outputs. I understood that this behaviour is coherent. maybe you mean: class ClassA {function getClassName() { return get_class($this); }} class ClassB extends ClassA {} $B = new ClassB(); echo $B->getClassName(); which _does_ work but is fairly pointless because you already know the classname in order to be able to create the object in the first place. that's true. I don't want to use this. I just checked it. I don't really see what the problem is, can you give some more real world detail on what you are trying/want to do? otherwise (re-)read this chapter: http://php.belnet.be/manual/en/language.oop5.php http://php.belnet.be/manual/en/language.oop5.static.php#48234 is better. but it seems that even debug_backtrace() is not what i'm looking for... ... if you're _really_ into generic code then the reflection API no, no generic code. ;) regards axel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object Inheritance, get_class() and a static function call
Hello Richard, thanks for for your answer. a> class ClassA { a>function getClassName() { a> return get_class($this); # [1] a>} a> } a> class ClassB extends ClassA { } a> echo ClassB::getClassName(); a> this script echoes "Object" instead of "ClassB". but i would like to a> return the classname of the derived class without writing the method again. "The double colon, is a token that allows access to static, constant, and overridden members or methods of a class." Of which none of yours are (at least not in the code posted) Sure! It's the first one: i'm calling a method of the class without instantiaton. it works even though the method isn't declared static. maybe this is the fault!? class ClassA { public static function getClassName() { return get_class($this); // [1] // or [2] return get_class(self); // or [3] return __CLASS__; } } class ClassB extends ClassA { } echo ClassB::getClassName(); > Wouldn't get_parent_class() work in this situation? No, because there is no parent class of ClassA and im searching for the name of the derived class. Maybe i will found the solution on http://php.belnet.be/manual/en/language.oop5.static.php Still reading... Best regards, Axel P. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Object Inheritance, get_class() and a static function call
Hello, following code won't work in the expected way: class ClassA { function getClassName() { return get_class($this); # [1] } } class ClassB extends ClassA { } echo ClassB::getClassName(); this script echoes "Object" instead of "ClassB". but i would like to return the classname of the derived class without writing the method again. this will work: B = new ClassB(); echo ClassB->getClassName(); i tried to use line [2] instead of [1] return get_class(self); # [2] but this only returns an empty string. is there any solution for my problem? i'm using PHP Version 5.0.3 (with Apache 1, Windows XP) greetings axel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Interesting phpversion() thing.
I just upgraded to 4.3.5. I double checked and made sure I put everything in the right place. If I run php or php-cli from the command line and the script has phpversion() in it, it returns the correct string, i.e. 4.3.5. If, however, I pull the same script up in a browser it gives me 4.3.4. I've tried everything, clearing caches, etc. Can't seem to get it to do what I expect. Any one else see this? Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting Binaries
That's not bad, but I found a way to do it simply using chr() and passing it a value. It turns out the if I go 0-31 Almost nothing will get through. Even the simples html has something in there from that list. However, by just looking between 14 and 26, one more than carriage return, and one less than escape, it worked really well. I crawled a site with a large number of jpg, gif, mp3, wav, and pdf files. Of the 100's of binaries there only one pdf got through. Not a bad record. I also found that in order for this to work I have to process the URLs. This makes things really slow so I'm going to have to use both this and the "check for extension" function together. Still, I can worry a lot less about getting my index weighted down by binary files. The code is pretty basic at this point, but here it is: // Check for binaries $ckbin = 14; while($ckbin <= 26){ $ck = chr($ckbin); $cbin = substr_count($read, $ck); if($cbin > 0){ echo "Killing off binary file URL: $url\n"; $kill = mysql_unbuffered_query("DELETE FROM search WHERE url_id='$url_id'"); continue 2; } ++$ckbin; } I know it looks kind of funky out of context, but it works really great. Nick Richard Davey wrote: Hello Evan, Monday, February 23, 2004, 8:57:43 PM, you wrote: It would be wise to check for characters from 0 to 31, if they appear then it's almost certainly (but not guaranteed) binary. EN> Assuming that's decimal, you're including 0x09 0x0a and 0x0d which are, EN> respectively, tab, line feed, and carriage return. That's off the top of my EN> head, which means two things: (1) i may be forgetting something, and (2) I EN> need a life ;) Let me rephrase - check for the existence of characters 0 through 31 and count how many there are. Set a percentage weight yourself and figure out in your script if you deem the quantity too many or too few. The count_chars() function will be absolutely ideal for this.
Re: [PHP] Detecting Binaries
Thanks, that's very helpful. It beats the heck out of doing it the way I've been doing it. Richard Davey wrote: Hello Axel, Monday, February 23, 2004, 7:38:25 PM, you wrote: AIM> Thanks, you just gave me the solution, I think. I don't have to strip AIM> out every character above standard ascii, I just have to look for them. AIM> If one is there, then just get rid of it. It's true that an OS can't AIM> tell the difference between a jpg and an exe file, but that's to be AIM> expected. But the file_get_contents() function DOES open the file. Since AIM> there is a definite difference between a text file and a binary file, it AIM> should be able to detect that. The difference isn't as obvious as you might think. Opening a binary file into a hex editor will show you this. Your brain can determine if the codes in-front of you are "English" or not, but from a pure logic point of view that's a little harder. Also bear in mind that on Unix ALL files are binary files. It is up to you to determine the type of the file contents as you see fit. For example you can check for line-terminated data. It would be wise to check for characters from 0 to 31, if they appear then it's almost certainly (but not guaranteed) binary. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting Binaries
Yes, and in fact that is what I am doing now. This is a spider bot though, so I'm having to think of every single type of binary file that could be linked to on the web. So far I'm up to 28 with no end in sight. What about a .com file? I can't omit links that end in .com can I? That would be counterproductive to say the least. Also, the function that does the checking just keep getting longer and longer, which makes the spider go slower and slower. Granted, the thing is pretty fast if it has enough BW to work with, but still. This could eventually turn into a script killer. Detecting whether the stream from file_get_contents(), or fopen() for that matter, is binary or not and going with that result is the elegant solution to this problem. There has to be a way to do it. Nick Adam Voigt wrote: Couldn't you just check the extension on the file? On Mon, 2004-02-23 at 14:03, Axel IS Main wrote: Guys, this isn't THAT stupid of a question is it? From my perspective, the way PHP seems to see it is that I should already know what kind of file I'm looking at. In most cases that's not an unreasonable assumption. Unfortunately, that's only good for most cases. PHP is rich in ways to work with the HTTP protocol, but has no way of detecting whether it's opening a text file or a binary file. To me this is a glaring omission. There has to be a way to do it, even if it's a round-a-bout or backdoor kind of way. Nothing is impossible. Nick Axel IS Main wrote: I'm using file_get_contents() to open URLs. Does anyone know if there is a way to look at the result and determine if the file is binary? I'd like to be able to block binaries from being processed without having to try to think of all the possible binary extensions and omit them with a function that looks for these extensions. Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting Binaries
Guys, this isn't THAT stupid of a question is it? From my perspective, the way PHP seems to see it is that I should already know what kind of file I'm looking at. In most cases that's not an unreasonable assumption. Unfortunately, that's only good for most cases. PHP is rich in ways to work with the HTTP protocol, but has no way of detecting whether it's opening a text file or a binary file. To me this is a glaring omission. There has to be a way to do it, even if it's a round-a-bout or backdoor kind of way. Nothing is impossible. Nick Axel IS Main wrote: I'm using file_get_contents() to open URLs. Does anyone know if there is a way to look at the result and determine if the file is binary? I'd like to be able to block binaries from being processed without having to try to think of all the possible binary extensions and omit them with a function that looks for these extensions. Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Detecting Binaries
I'm using file_get_contents() to open URLs. Does anyone know if there is a way to look at the result and determine if the file is binary? I'd like to be able to block binaries from being processed without having to try to think of all the possible binary extensions and omit them with a function that looks for these extensions. Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending a http body
Hi, > Is it possible, to send the elements, so far outputed, to the browser, and > use that as keep alive, i.e. give the user already something to see:-) > And, of course, do that regular, out of my data retrieval loop. http://www.php.net/ob_implicit_flush is your friend. HTH, Axel.
[PHP] Triggers & events with objects
Hi, I would like to do the following When an objects method is called like this: $test= new Testclass; $test->someMethod ($someArgument); I'd like to have an event handler outside Testclass to log this event, like this: function event_handler ( $method_name, $obj [, mixed parameter [, mixed...]]) { switch get_class($obj) { case "testclass" : // ... if ($method_name == "someMethod " { // ... } break; } } Is that possible in any way? TIA, Axel.
Re: [PHP] hiding submitted variable values in location bar of browser !
> Hi everyone, > Is there any way to hide my form submitted variables (like > passwords etc) > in the location > bar "http://somedomain.org/checkpassword.php? > password=mypassword" > or atleast show in an encypted form n the location bar. HTH, Axel Tietje -- FLYnet FLYer Kommunikationsgesellschaft mbH Weender Landstr. 46 37073 Göttingen 0551-499750 http://www.flynet.de [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] serialize
Hi All! I use this code to create a number of fields in a form depending on what input number I use. My problem occurs when i am going to save it. Right now only the value of the last field gets stored. I want to serialize all values from all fields so that they can be saved as a stringvalue is there any friendly soul out there who knows how to do it? /Axel "; } ?> _ MSN Photos är det enklaste sättet att dela ut och skriva ut foton: http://photos.msn.se/Support/WorldWide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php
Sir, What do I do with my php? how can I compile my php with mysql support? my problem is I already compile my php what do I do do? I will remove it? axel
[PHP] Probs with browsecap.ini
Hi, I'm using the function get_browser(), but the whole thing does not seem to work properly. Please have a look at http://web.flynet.de/info.php to see what I mean. Is there anyone who could tell me what's probably wrong? I'm using PHP 4.04, which compiled ok. I seems to find the browsecap.ini, but the output is buggy. TIA, Axel. -- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]