php-general Digest 15 Dec 2009 13:44:52 -0000 Issue 6489
php-general Digest 15 Dec 2009 13:44:52 - Issue 6489 Topics (messages 300506 through 300519): Re: Class not functioning 300506 by: Nirmalya Lahiri Re: PHP + ODBC 300507 by: James McLean Re: MySQL Appeal from Monty 300508 by: Joseph Masoud 300509 by: Lester Caine 300517 by: Ashley Sheridan Re: PHP live chat 300510 by: Angelo Zanetti 300511 by: Ghodmode 300519 by: Angelo Zanetti Re: Best ajax library 300512 by: Ali Asghar Toraby Parizy 300513 by: Joseph Masoud Re: ErrorException and set_exception_handler() 300514 by: Richard Quadling Parsing JSON; back-slash problem 300515 by: Andrew Burgess 300518 by: Ashley Sheridan Debian Lenny: Which 5.3 package should I use? 300516 by: Wouter van Vliet / Interpotential Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-gene...@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other classes that should be adding to the $q array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The Database!', 'error');) However, when I try to get my webpage to display them using: $Notify-printQ(); it does not seem to want to loop through this array (and print the messages). I am getting NO error message, in fact everything 'looks' fine, I'm just not seeing the appropriate message. Any help would be appreicated! Allen, You have made a small typing mistake in function printQ() where you would like to checked the array for its existence. By mistake you have wrote if (isset($q)). But your array variable is not an freely accessible array,the array is embedded into an object. So, you have to write the like if (isset($this-q)). Another point, you can't add a message into the array by calling the member function addtoQ() using scope resolution operator ::. If you really want to add message into the array, you have to call the member function from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error Updating The Database!', 'error');). --- নির্মাল্য লাহিড়ী [Nirmalya Lahiri] +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536] ---End Message--- ---BeginMessage--- On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson philthath...@gmail.com wrote: My head hurts from hitting it on my desk all day, so I thought I'd turn to a fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I can get it to work using isql from the command line. Can you verify my settings: [snipped] I've tried the above DSNs and many other versions of it ad nauseum. The specific error I'm getting is... [unixODBC][Driver Manager]Data source name not found, and no default driver specified. I really have searched high and low for a solution, but to no avail. Any thoughts? Why not just use the built in MySQL libraries or PDO? ---End Message--- ---BeginMessage--- On 14 Dec 2009, at 22:01, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2009-12-14 at 15:59 -0600, Philip Thompson wrote: On Dec 14, 2009, at 12:51 AM, Lester Caine wrote: Lenin wrote: You might also like this: Come on Monty - Lukas Smith http://bit.ly/5lmwwD I've been watching some of this debate with interest, but I'll stay with a database that has none of the baggage that MySQL has always had, and IS currently replacing Oracle in many large sites :) -- Lester Caine - G8HFL Do share your db of interest... (and please don't say MSSQL). ~Philip MSSQL has nearly brought me to tears and could have easily made me bald through hair pulling! I have to say, I do like MySQL, it's very flexible and fast, and being able to choose different storage engines for different tables in the same DB is brilliant! I really don't think there's
Re: [PHP] Best ajax library
Which one is more active than others? I mean which project extends faster and better, in future? On Tue, Dec 15, 2009 at 1:37 AM, Philip Thompson philthath...@gmail.com wrote: On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote: Hi I think the best choice is jquery until now. But, is it reasonable to combine jquery and other library to client side and server side scripting respectively? By the way, where i can find good lessons about jquery and php? I really like this js library. http://mootools.net/ It's based off of jquery or prototype... I can't remember. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best ajax library
On 15 Dec 2009, at 08:50, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: Which one is more active than others? I mean which project extends faster and better, in future? On Tue, Dec 15, 2009 at 1:37 AM, Philip Thompson philthath...@gmail.com wrote: On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote: Hi I think the best choice is jquery until now. But, is it reasonable to combine jquery and other library to client side and server side scripting respectively? By the way, where i can find good lessons about jquery and php? I really like this js library. http://mootools.net/ It's based off of jquery or prototype... I can't remember. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php JQuery and Mootools are two very different approaches of creating a JavaScript framework. Both shine in different ways. I use JQuery when I want to get things done quickly (using the Yii framework or on custom projects). I use mootols when I develop Joomla! Extensions and it's amazing. Which is more suitable boils down to what your project needs. I'm messing around with Ext at the moment and it's really nice too! The ultimate answer to your question is; it depends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Re: ErrorException and set_exception_handler()
-- Forwarded message -- From: Randall Girard randallgir...@hotmail.com Date: 2009/12/14 Subject: RE: [PHP] Re: ErrorException and set_exception_handler() To: rquadl...@googlemail.com I understood exactly what was going on in the code! (I'm no fool when it comes to this) I just thought (logically) that if the ERROR_HANDLER forces you to end the script when necessary, that the EXCEPTION_HANDLER would have a similar function... Rather, there is not a way at all to continue execution. Now that I contemplate this further, I think I prefer this anyway as I would NOT want errors firing for ANY reason on a production website! Additionally when one error happens it often triggers a number of errors (if execution continues) and when logging of course they are all logged. I would rather have just the one backtraced error log, and so forth. Thank you for your help however! It is much appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing JSON; back-slash problem
This seems like a pretty basic question, but it has me stumped. Here's my scenario: I'm using Douglas Crockford's JSON2.js to parse an object in JavaScript, which I then pass to a PHP script to store in a file. I use JSON.stringify() on the object, which logs to the console as this: {employees:{data:{John:{fname:John,lname:Doe,city:Toronto,country:Canada Then I use the jQuery POST function to send it to a PHP script. Before doing anything with it in PHP, I log the received value to the console, and this is what I get: {\employees\:{\data\:{\John\:{\fname\:\John\,\lname\:\Doe\,\city\:\Toronto\,\country\:\Canada\ The problem is, when I call the script to retrieve this data from a file, JSON.parse can't parse it because of the back-slashes. I'm pretty sure my problem is on the PHP side (since it's fine coming out of JS); what do I need to do to fix this? is a preg_replace enough? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Debian Lenny: Which 5.3 package should I use?
Hi Guys Gals, I've been playing around with PHP 5.3 for a while now on development servers and servers solely used for start-ups and lower-profile apps. But now I'm about to upgrade the servers for a high profile/high traffic website and with this upgrade I'd also like to make the switch from 5.2 to 5.3. But - which package should I choose? I want to rely on community tested builds, so compiling myself is out of the question. The server will run on Debian Lenny. The Two and a Half options I've been able to find are: DotDeb: http://www.dotdeb.org/2009/12/06/the-php-5-3-1-packages-have-been-updated/ Debian Experimental: http://packages.debian.org/source/experimental/php5 ~raaa Launchpad: https://launchpad.net/~raaa/+archive/ppa Are there any others? Which is the best when it comes to: - Security? - Stability? - Ease of upgrade to Debian Squeeze later next year? Thanks in advance for any help you're able to offer! Regards, Wouter -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] MySQL Appeal from Monty
On Tue, 2009-12-15 at 02:53 +, Joseph Masoud wrote: On 14 Dec 2009, at 22:01, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2009-12-14 at 15:59 -0600, Philip Thompson wrote: On Dec 14, 2009, at 12:51 AM, Lester Caine wrote: Lenin wrote: You might also like this: Come on Monty - Lukas Smith http://bit.ly/5lmwwD I've been watching some of this debate with interest, but I'll stay with a database that has none of the baggage that MySQL has always had, and IS currently replacing Oracle in many large sites :) -- Lester Caine - G8HFL Do share your db of interest... (and please don't say MSSQL). ~Philip MSSQL has nearly brought me to tears and could have easily made me bald through hair pulling! I have to say, I do like MySQL, it's very flexible and fast, and being able to choose different storage engines for different tables in the same DB is brilliant! I really don't think there's anything to overly worry about from Oracle, as the two DB's have different audiences. Thanks, Ash http://www.ashleysheridan.co.uk Unfortunately, I do not share your optimism. I believe that Oracle taking over MySQL would be a disaster of epic proportions. The different audiences theory has been bought up several times but I haven't [to date] seen a sound justification for it. Oracle wants everyone to use ... Oracle, I can't see how this different audiences theory is going to make Oracle promote MySQL, perhaps someone can tell me? I don't think the EU would be able to do anything about it. The powerful companies almost always get what they want. I don't think Monty wouldn't be doing this unless he felt that something [put mildly] bad is coming. What has happened, has happened. Trying to figure out who is to blame for this mess is pointless. Ideally, It would be nice if Oracle took its claws off MySQL and found another project to ruin. Note: I am *not* trying to spread FUD I've always been led to believe that you go with MySQL if you want speed, Oracle if you want data integrity. I know they both handle each one admirably, but Oracle is known more for guarding the data against mishaps and MySQL is known more for performance. I just think it may be a little early to be condemning Oracle yet, we should wait a little to at least see what stance they have on the whole thing. And before you ask, no I have no connection to Oracle, I'm an avid MySQL fan! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Parsing JSON; back-slash problem
On Tue, 2009-12-15 at 06:52 -0500, Andrew Burgess wrote: This seems like a pretty basic question, but it has me stumped. Here's my scenario: I'm using Douglas Crockford's JSON2.js to parse an object in JavaScript, which I then pass to a PHP script to store in a file. I use JSON.stringify() on the object, which logs to the console as this: {employees:{data:{John:{fname:John,lname:Doe,city:Toronto,country:Canada Then I use the jQuery POST function to send it to a PHP script. Before doing anything with it in PHP, I log the received value to the console, and this is what I get: {\employees\:{\data\:{\John\:{\fname\:\John\,\lname\:\Doe\,\city\:\Toronto\,\country\:\Canada\ The problem is, when I call the script to retrieve this data from a file, JSON.parse can't parse it because of the back-slashes. I'm pretty sure my problem is on the PHP side (since it's fine coming out of JS); what do I need to do to fix this? is a preg_replace enough? Turn off magic quotes, as it looks like they are enabled on your server. You can turn them off from the .htaccess file if you don't have access to the php.ini Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] PHP live chat
-Original Message- From: Ghodmode [mailto:ghodm...@ghodmode.com] Sent: 15 December 2009 09:41 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP live chat I've played around with CraftySyntax LiveHelp, but I haven't deployed it in a production environment. It definitely looks like it's worth a try, though. http://www.craftysyntax.com/ thanks Ghomode, I will have a look at it now. Regards Angelo http://www.elemental.co.za http://www.wapit.co.za On 14/12/09 21:14, Angelo Zanetti wrote: Hi all, I know there are a lot of scripts that one can pay for, for live chat - website support. Are there are any free open source ones that work well? I found: www.phplivechat.com But still waiting to evaluate it. Please send you comments, good or bad and what you would recommend or not recommend and why Thanks in advance. Angelo http://www.wapit.co.za http://www.elemental.co.za -- *Vince Aggrippino* a.k.a. Ghodmode www.ghodmode.com http://www.ghodmode.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] PHP live chat
http://www.livezilla.net/ -Mensagem original- De: Angelo Zanetti [mailto:ang...@zlogic.co.za] Enviada em: terça-feira, 15 de dezembro de 2009 09:59 Para: 'Ghodmode'; php-general@lists.php.net Assunto: RE: [PHP] PHP live chat -Original Message- From: Ghodmode [mailto:ghodm...@ghodmode.com] Sent: 15 December 2009 09:41 AM To: php-general@lists.php.net Subject: Re: [PHP] PHP live chat I've played around with CraftySyntax LiveHelp, but I haven't deployed it in a production environment. It definitely looks like it's worth a try, though. http://www.craftysyntax.com/ thanks Ghomode, I will have a look at it now. Regards Angelo http://www.elemental.co.za http://www.wapit.co.za On 14/12/09 21:14, Angelo Zanetti wrote: Hi all, I know there are a lot of scripts that one can pay for, for live chat - website support. Are there are any free open source ones that work well? I found: www.phplivechat.com But still waiting to evaluate it. Please send you comments, good or bad and what you would recommend or not recommend and why Thanks in advance. Angelo http://www.wapit.co.za http://www.elemental.co.za -- *Vince Aggrippino* a.k.a. Ghodmode www.ghodmode.com http://www.ghodmode.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip tags but preserve title attributes
On Mon, Dec 14, 2009 at 6:43 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I'm looking for a way to strip HTML tags out of some text content (sourced from a web page) to leave just the text which I'll be running some basic analysis on. The thing is, I want to preserve text that is in alt and title attributes. I can't use any DOM functions, as I can't guarantee that the content will be valid XHTML, although it should be valid HTML. I'm happy doing this with string functions and regular expressions, but I was wondering if something for this already existed? The server I plan on putting this on does not have access to the shell (although it is a Linux server) so I won't be able to have Lynx or Elinks parse the content for me either :( Thanks, Ash http://www.ashleysheridan.co.uk Are you sure you can't use DOM? It has a function specifically for parsing HTML that does not have to be well-formed to load. http://www.php.net/manual/en/domdocument.loadhtml.php If that doesn't work, you might look at Zend_Filter_StripTags in ZF. I don't know if it will do exactly what you're after, but it seems to be more flexible than the strip_tags function built into PHP. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing JSON; back-slash problem
Ashley Sheridan wrote: On Tue, 2009-12-15 at 06:52 -0500, Andrew Burgess wrote: This seems like a pretty basic question, but it has me stumped. Here's my scenario: I'm using Douglas Crockford's JSON2.js to parse an object in JavaScript, which I then pass to a PHP script to store in a file. I use JSON.stringify() on the object, which logs to the console as this: {employees:{data:{John:{fname:John,lname:Doe,city:Toronto,country:Canada Then I use the jQuery POST function to send it to a PHP script. Before doing anything with it in PHP, I log the received value to the console, and this is what I get: {\employees\:{\data\:{\John\:{\fname\:\John\,\lname\:\Doe\,\city\:\Toronto\,\country\:\Canada\ The problem is, when I call the script to retrieve this data from a file, JSON.parse can't parse it because of the back-slashes. I'm pretty sure my problem is on the PHP side (since it's fine coming out of JS); what do I need to do to fix this? is a preg_replace enough? Turn off magic quotes, as it looks like they are enabled on your server. You can turn them off from the .htaccess file if you don't have access to the php.ini Thanks, Ash http://www.ashleysheridan.co.uk If you don't have access to do this, look at stripslashes() -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip tags but preserve title attributes
I've had quite some luck using the html2text class by Jon Abernathy http://www.chuggnutt.com/html2text.php It's targetted to php 4, and rather old code - but it does the job for me. Where the 'job for me' is converting html to text for when I'm sending out emails in HTML format and want to offer the proper plain text alternative. To be honest, I haven't checked how it handles title/alt attributes on images - but I'm confident that it does it nicely, and if it doesn't that you can add it yourself. And if that doesn't suit your needs - you might want to take a look at this: http://sourceforge.net/projects/simplehtmldom/ Regards, Wouter 2009/12/15 Andrew Ballard aball...@gmail.com On Mon, Dec 14, 2009 at 6:43 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: I'm looking for a way to strip HTML tags out of some text content (sourced from a web page) to leave just the text which I'll be running some basic analysis on. The thing is, I want to preserve text that is in alt and title attributes. I can't use any DOM functions, as I can't guarantee that the content will be valid XHTML, although it should be valid HTML. I'm happy doing this with string functions and regular expressions, but I was wondering if something for this already existed? The server I plan on putting this on does not have access to the shell (although it is a Linux server) so I won't be able to have Lynx or Elinks parse the content for me either :( Thanks, Ash http://www.ashleysheridan.co.uk Are you sure you can't use DOM? It has a function specifically for parsing HTML that does not have to be well-formed to load. http://www.php.net/manual/en/domdocument.loadhtml.php If that doesn't work, you might look at Zend_Filter_StripTags in ZF. I don't know if it will do exactly what you're after, but it seems to be more flexible than the strip_tags function built into PHP. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Parsing JSON; back-slash problem
If you don't have access to do this, look at stripslashes() And if you absolutely want to be on the safe side - check* if the magic_quotes option is enabled - if so; do stripslashes. If not - then obviously don't. * http://www.php.net/manual/en/function.get-magic-quotes-gpc.php -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] How to pronounce PHP code over the phone?
2009/10/16 Dotan Cohen dotanco...@gmail.com: It's called vacation away from the 'net but there is an emergency. I'm certain that a fair portion of the list is familiar with that! I haven't the slightest idea what you are talking about. Vacation? Away from the net? We must be from different planets... How to do you vacation from something implanted into your brain? http://www.imdb.com/title/tt0100802/ -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Surely Johnny Moronic would have been a better example? -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + ODBC
On Dec 14, 2009, at 8:47 PM, James McLean wrote: On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson philthath...@gmail.com wrote: My head hurts from hitting it on my desk all day, so I thought I'd turn to a fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I can get it to work using isql from the command line. Can you verify my settings: [snipped] I've tried the above DSNs and many other versions of it ad nauseum. The specific error I'm getting is... [unixODBC][Driver Manager]Data source name not found, and no default driver specified. I really have searched high and low for a solution, but to no avail. Any thoughts? Why not just use the built in MySQL libraries or PDO? Oh, that would be my preference. However, the database that I really need to connect to is an MSSQL one and the allowed connection type is ODBC. I was just testing first with a MySQL connection to get it working (I don't have the MSSQL credentials yet). Turned out I was VERY close with my solution, which a coworker figured out this morning. The [ODBC Data Sources] entry for MySQL needed to specified correctly in /etc/odbc.ini. [ODBC Data Sources] MySQL = MySQL [MySQL] Description... Driver... I could have sworn I tried that, but who knows Thank you! ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pronounce PHP code over the phone?
2009/10/16 Dotan Cohen dotanco...@gmail.com: How would you read this out loud if you were to read it to someone over the phone? ($item-getServiceId() ? $item-getServiceId() : $item-getId(; Thanks! -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I would optimize this though. ($item-getServiceId() || $item-getId()) Unless you REALLY need to call $item-getServiceId() twice. So, this should be a little easier to say. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best ajax library
On Dec 15, 2009, at 3:12 AM, Joseph Masoud wrote: On 15 Dec 2009, at 08:50, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: Which one is more active than others? I mean which project extends faster and better, in future? On Tue, Dec 15, 2009 at 1:37 AM, Philip Thompson philthath...@gmail.com wrote: On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote: Hi I think the best choice is jquery until now. But, is it reasonable to combine jquery and other library to client side and server side scripting respectively? By the way, where i can find good lessons about jquery and php? I really like this js library. http://mootools.net/ It's based off of jquery or prototype... I can't remember. ~Philip JQuery and Mootools are two very different approaches of creating a JavaScript framework. Both shine in different ways. I use JQuery when I want to get things done quickly (using the Yii framework or on custom projects). I use mootols when I develop Joomla! Extensions and it's amazing. Which is more suitable boils down to what your project needs. I'm messing around with Ext at the moment and it's really nice too! The ultimate answer to your question is; it depends. Along those lines of it depends... to my knowledge, most of the larger/more popular js frameworks consider other libraries when being developed. Meaning, the chances of a naming conflict are lowered. Not that I recommend it, but it does allow for using multiple libraries for a single project - that's another thread. I can't speak for the other libraries, but I know that MooTools is constantly being updated and improved. I doubt that it will be leaving anytime soon. Check out some extended functionality of MooTools... Clientcide. It's created by the same author of MooTools to work with it. http://www.clientcide.com/ ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't retrieve more than 1 record at the time still
2009/12/14 Catherine Madsen cmad...@berkeley.edu: Hi Again, Following the suggestions I received from a earlier post, I've closed the statement while ($stmt-fetch(PDO::FETCH_BOUND)) before $stmt = NULL; I don't get an error anymore, but still retrieve only one record. To check that the array was being filled correctly, I inserted in several places $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); and the count is always 0 for $ndocid and 1 for $ncand. Now I believe that the array is not being filled, and that's why only the last record gets processed. Can anybody see what I'm doing wrong in the for each statement? The updated code is below. Thank you for your help. Catherine Earlier message: I'm really in need of help. I'm not a PHP programmer, but I've been given the privilege of customizing a script written by somebody else and can't get it to work right. I have to query 2 different tables in 2 different Oracle 10G DBs, one's mine (my_schema.my_table), the other (otherdb.other_table) belongs to another department. In my_table, I have the doc_id and the app_id for a record. In other_table there's the doc_id and pdf to retrieve. The goal is to make a PDF file from each BLOB in other_table and store them in the right directory under hash(app_id). PDO has been installed and working, and I can connect to both DBs without a problem. If my query limits the retrieval to one record, the script works, but if I try to run it for all records, one pdf file is correctly created in the right directory then I get the following error: PHP Fatal error: Call to a member function fetch() on a non-object in /my_location/my_script.php on line 154. It the while ($stmt-fetch(PDO::FETCH_BOUND)) line. I've pasted my script below. I thought my problem was that maybe I was in the wrong directory after creation of the first pdf, but several tries changing the directory didn't make a difference. Right now, I'm running the script at the command line. Soon I'm going to have a few hundred records to deal with and cannot do it one by one! Any help would be very much appreciated. Thank you! ?php /* First Oracle DB connection info removed */ try { $dbh1 = new PDO(oci:dbname=.$tns1,$db1_username,$db1_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; } if (empty($_SESSION['docIDs'])) { $_SESSION['DOCIDs'] = array(); $_SESSION['msgs'] = array(); $sql = SELECT COUNT(*) all_rec FROM myschema.mytable where academic_year = 2010; $_SESSION['numberCand'] = 0; /* initialize ctr for stack popping */ $_SESSION['PHPulled'] = 0; /* number new personal histories pulled */ if ($res = $dbh1-query($sql)) { /* Check the number of rows that match the SELECT statement */ if ($res-fetchColumn() 0) { /* Issue the real SELECT statement and work with the results */ $sql = select doc_id, app_id from myschema.mytable where academic_year = 2010; foreach ($dbh1-query($sql) as $row) { $cand = array(); $cand['DOC_ID']= $row['DOC_ID']; $cand['APP_ID'] = $row['APP_ID']; $_SESSION['DOC_IDS'][] = $cand; } } $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); print Cand Number: . $ncand . \n; print DOCid Number: . $ndocid . \n; } } if (!empty($_SESSION['DOC_IDS']) and $_SESSION['numberCand'] count($_SESSION['DOC_IDS'])) { $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); print Cand Number: . $ncand . \n; print DOCid Number: . $ndocid . \n; /* if have doc_IDs, pick next one off array */ $cand = $_SESSION['DOC_IDS'][$_SESSION['numberCand']]; if ($cand['DOC_ID'] == 0) { /* redirect to self to get next candidate with updated numberCand */ $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1; exit; } $dirname = md5($cand['APP_ID']); $curdir = '/my_location/'.$dirname; print App_id/Dir: . $row['APP_ID'] . $curdir . \n; if (!(is_dir($curdir))) { if (!mkdir($curdir,0775)) print error: . $curdir . \n; exit; } /* Second Oracle DB connection info removed */ try { $dbh2 = new PDO(oci:dbname=.$tns2,$db2_username,$db2_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; } $stmt = $dbh2-prepare('select PERSONAL_HIST_PDF_CONTENT from
Re: [PHP] PHP + ODBC
2009/12/15 Philip Thompson philthath...@gmail.com: On Dec 14, 2009, at 8:47 PM, James McLean wrote: On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson philthath...@gmail.com wrote: My head hurts from hitting it on my desk all day, so I thought I'd turn to a fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I can get it to work using isql from the command line. Can you verify my settings: [snipped] I've tried the above DSNs and many other versions of it ad nauseum. The specific error I'm getting is... [unixODBC][Driver Manager]Data source name not found, and no default driver specified. I really have searched high and low for a solution, but to no avail. Any thoughts? Why not just use the built in MySQL libraries or PDO? Oh, that would be my preference. However, the database that I really need to connect to is an MSSQL one and the allowed connection type is ODBC. I was just testing first with a MySQL connection to get it working (I don't have the MSSQL credentials yet). Turned out I was VERY close with my solution, which a coworker figured out this morning. The [ODBC Data Sources] entry for MySQL needed to specified correctly in /etc/odbc.ini. [ODBC Data Sources] MySQL = MySQL [MySQL] Description... Driver... I could have sworn I tried that, but who knows Thank you! ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can use a DNS-string too ... odbc_pconnect(Driver={SQL Server Native Client 10.0};Server={$s_Server};Database={$s_DB};MARS_Connection=Yes;, $s_User, $s_Pswd, SQL_CUR_USE_DRIVER); -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Appeal from Monty
On Tue, Dec 15, 2009 at 12:03:23PM +, Ashley Sheridan wrote: snip I've always been led to believe that you go with MySQL if you want speed, Oracle if you want data integrity. I know they both handle each one admirably, but Oracle is known more for guarding the data against mishaps and MySQL is known more for performance. PostgreSQL generally matches MySQL in performance, and maintains referential integrity (foreign keys and such) without the need for multiple backend storage engines. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
2009/12/14 Ashley Sheridan a...@ashleysheridan.co.uk On Mon, 2009-12-14 at 17:03 +0200, Cafer Şimşek wrote: René Fournier m...@renefournier.com writes: On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote: René Fournier m...@renefournier.com writes: 4.as per php.ini, allow_url_fopen On Look at from phpinfo() the settings is already On. Yes, I know. Which is why it's odd that the function fails on URLs. try to get url content from any browser or (if you use Linux / Unix) curl. -- Cafer Şimşek DEV Staff Leader http://pazar.com/ He already said Curl works, and changing the browser won't affect what PHP is doing. Thanks, Ash http://www.ashleysheridan.co.uk Do you have a default stream context defined for the http stream? A _LONG_ time ago, when I was using a firewall with NTLM authentication (which PHP doesn't deal with), I had to route all my calls through a local proxy. This was the code I had ... ?php // Define the default, system-wide context. $r_default_context = stream_context_get_default( array( 'http' = array( // All HTTP requests are passed through the local NTLM proxy server on port 8080. 'proxy' = 'tcp://127.0.0.1:8080', 'request_fulluri' = True, ), ) ); // Though we said system wide, some extensions need a little coaxing. libxml_set_streams_context($r_default_context); Now, you may not see this in your code, but may be in a script which is loaded via auto_prepend_file. I would also suggest running something like WireShark at the same time as your script. See if there is ANY traffic over the wire. Do the cURL and file_get_contents() code generate identical requests? -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing JSON; back-slash problem
Thanks guys; I've got it working now! On Tue, Dec 15, 2009 at 9:54 AM, Wouter van Vliet / Interpotential pub...@interpotential.com wrote: If you don't have access to do this, look at stripslashes() And if you absolutely want to be on the safe side - check* if the magic_quotes option is enabled - if so; do stripslashes. If not - then obviously don't. * http://www.php.net/manual/en/function.get-magic-quotes-gpc.php -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strip tags but preserve title attributes
Ashley Sheridan wrote: I'm looking for a way to strip HTML tags out of some text content (sourced from a web page) to leave just the text which I'll be running some basic analysis on. The thing is, I want to preserve text that is in alt and title attributes. I can't use any DOM functions, as I can't guarantee that the content will be valid XHTML, although it should be valid HTML. I'm happy doing this with string functions and regular expressions, but I was wondering if something for this already existed? The server I plan on putting this on does not have access to the shell (although it is a Linux server) so I won't be able to have Lynx or Elinks parse the content for me either :( Thanks, Ash http://www.ashleysheridan.co.uk Sounds easy with a simple regex expression, certainly easier than twisting a class or DOM function to do the job. How do you want to retain the text that is in the alt and title attributes? What form do you want it in? e.g., img alt=foo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip tags but preserve title attributes
On Tue, Dec 15, 2009 at 6:44 AM, Wouter van Vliet / Interpotential pub...@interpotential.com wrote: And if that doesn't suit your needs - you might want to take a look at this: http://sourceforge.net/projects/simplehtmldom/ +1 I've never used the html2text library, but simplehtmldom is very easy to use and has worked very well for me. Brady -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class not functioning
Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... ?php $Notify-printQ() ? On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri nirmalyalah...@yahoo.comwrote: --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-general@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other classes that should be adding to the $q array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The Database!', 'error');) However, when I try to get my webpage to display them using: $Notify-printQ(); it does not seem to want to loop through this array (and print the messages). I am getting NO error message, in fact everything 'looks' fine, I'm just not seeing the appropriate message. Any help would be appreicated! Allen, You have made a small typing mistake in function printQ() where you would like to checked the array for its existence. By mistake you have wrote if (isset($q)). But your array variable is not an freely accessible array,the array is embedded into an object. So, you have to write the like if (isset($this-q)). Another point, you can't add a message into the array by calling the member function addtoQ() using scope resolution operator ::. If you really want to add message into the array, you have to call the member function from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error Updating The Database!', 'error');). --- নির্মাল্য লাহিড়ী [Nirmalya Lahiri] +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536]
Re: [PHP] can't retrieve more than 1 record at the time still
Thank you so much for sending me in the right direction. I've re-written the first part of the script using PDO statements and it works great. Catherine Richard Quadling wrote: 2009/12/14 Catherine Madsen cmad...@berkeley.edu: Hi Again, Following the suggestions I received from a earlier post, I've closed the statement while ($stmt-fetch(PDO::FETCH_BOUND)) before $stmt = NULL; I don't get an error anymore, but still retrieve only one record. To check that the array was being filled correctly, I inserted in several places $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); and the count is always 0 for $ndocid and 1 for $ncand. Now I believe that the array is not being filled, and that's why only the last record gets processed. Can anybody see what I'm doing wrong in the for each statement? The updated code is below. Thank you for your help. Catherine Earlier message: I'm really in need of help. I'm not a PHP programmer, but I've been given the privilege of customizing a script written by somebody else and can't get it to work right. I have to query 2 different tables in 2 different Oracle 10G DBs, one's mine (my_schema.my_table), the other (otherdb.other_table) belongs to another department. In my_table, I have the doc_id and the app_id for a record. In other_table there's the doc_id and pdf to retrieve. The goal is to make a PDF file from each BLOB in other_table and store them in the right directory under hash(app_id). PDO has been installed and working, and I can connect to both DBs without a problem. If my query limits the retrieval to one record, the script works, but if I try to run it for all records, one pdf file is correctly created in the right directory then I get the following error: PHP Fatal error: Call to a member function fetch() on a non-object in /my_location/my_script.php on line 154. It the while ($stmt-fetch(PDO::FETCH_BOUND)) line. I've pasted my script below. I thought my problem was that maybe I was in the wrong directory after creation of the first pdf, but several tries changing the directory didn't make a difference. Right now, I'm running the script at the command line. Soon I'm going to have a few hundred records to deal with and cannot do it one by one! Any help would be very much appreciated. Thank you! ?php /* First Oracle DB connection info removed */ try { $dbh1 = new PDO(oci:dbname=.$tns1,$db1_username,$db1_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; } if (empty($_SESSION['docIDs'])) { $_SESSION['DOCIDs'] = array(); $_SESSION['msgs'] = array(); $sql = SELECT COUNT(*) all_rec FROM myschema.mytable where academic_year = 2010; $_SESSION['numberCand'] = 0; /* initialize ctr for stack popping */ $_SESSION['PHPulled'] = 0; /* number new personal histories pulled */ if ($res = $dbh1-query($sql)) { /* Check the number of rows that match the SELECT statement */ if ($res-fetchColumn() 0) { /* Issue the real SELECT statement and work with the results */ $sql = select doc_id, app_id from myschema.mytable where academic_year = 2010; foreach ($dbh1-query($sql) as $row) { $cand = array(); $cand['DOC_ID']= $row['DOC_ID']; $cand['APP_ID'] = $row['APP_ID']; $_SESSION['DOC_IDS'][] = $cand; } } $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); print Cand Number: . $ncand . \n; print DOCid Number: . $ndocid . \n; } } if (!empty($_SESSION['DOC_IDS']) and $_SESSION['numberCand'] count($_SESSION['DOC_IDS'])) { $ncand = count($_SESSION['numberCand']); $ndocid = count($_SESSION['DOCIDs']); print Cand Number: . $ncand . \n; print DOCid Number: . $ndocid . \n; /* if have doc_IDs, pick next one off array */ $cand = $_SESSION['DOC_IDS'][$_SESSION['numberCand']]; if ($cand['DOC_ID'] == 0) { /* redirect to self to get next candidate with updated numberCand */ $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1; exit; } $dirname = md5($cand['APP_ID']); $curdir = '/my_location/'.$dirname; print App_id/Dir: . $row['APP_ID'] . $curdir . \n; if (!(is_dir($curdir))) { if (!mkdir($curdir,0775)) print error: . $curdir . \n; exit; } /* Second Oracle DB connection info removed */ try { $dbh2 = new PDO(oci:dbname=.$tns2,$db2_username,$db2_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; }
Re: [PHP] Class not functioning
Allen McCabe wrote: Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... Several ways to do it. One would be to make the Meetgreet a singleton if it really is, and then use its static getInstance. I would probably use a registry pattern though. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class not functioning
Allen, The short answer (but don't follow this): ?php class Meetgreet { public function deleteSingle($id, $number) { // do something global $Notify; $Notify-addToQ( .. ); } } ? The long(er) answer: I assume your Notifier object functions as singleton? Ie; accross your entire application, there is only one instance of that class? Why not go-static? That is, to my experience, the sweetest way to make something globally accessible - without making something global. Like so ?php class Notifier { protected static $queue = Array(); // make sure it can't be instantiated private constructer __construct() { } public static function addToQ( $arg, $anotherArg) { self::$queue[] = $arg.' - '.$anotherArg; } } // and then from within any method anywhere, call Notifier::addToQ('foo', 'bar'); ? Does that work for you? Regards, Wouter (ps. call me a purist, but a function defined in a class is no longer called a function, but a *method*) 2009/12/15 Allen McCabe allenmcc...@gmail.com Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... ?php $Notify-printQ() ? On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri nirmalyalah...@yahoo.comwrote: --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-general@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other classes that should be adding to the $q array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The Database!', 'error');) However, when I try to get my webpage to display them using: $Notify-printQ(); it does not seem to want to loop through this array (and print the messages). I am getting NO error message, in fact everything 'looks' fine, I'm just not seeing the appropriate message. Any help would be appreicated! Allen, You have made a small typing mistake in function printQ() where you would like to checked the array for its existence. By mistake you have wrote if (isset($q)). But your array variable is not an freely accessible array,the array is embedded into an object. So, you have to write the like if (isset($this-q)). Another point, you can't add a message into the array by calling the member function addtoQ() using scope resolution operator ::. If you really want to add message into the array, you have to call the member function from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error Updating The Database!', 'error');). --- নির্মাল্য লাহিড়ী [Nirmalya Lahiri] +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536] -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Class not functioning
Wouter, Implementing your static idea was pretty easy, I was already referencing Notifier with the :: operator in my other methods, however I am running into trouble assigning new values to the static array. I am getting a syntax error, unexpected '[' on this line of my Notifier class: Notifier::notifyQ[] = 'div class='.$message; . . . Any ideas why this is causing an error? (note: I did try using $this-Notifier, and it said I cannot do what-not to a non-object, can't remember the exact message at the moment) On Tue, Dec 15, 2009 at 2:30 PM, Wouter van Vliet / Interpotential pub...@interpotential.com wrote: Allen, The short answer (but don't follow this): ?php class Meetgreet { public function deleteSingle($id, $number) { // do something global $Notify; $Notify-addToQ( .. ); } } ? The long(er) answer: I assume your Notifier object functions as singleton? Ie; accross your entire application, there is only one instance of that class? Why not go-static? That is, to my experience, the sweetest way to make something globally accessible - without making something global. Like so ?php class Notifier { protected static $queue = Array(); // make sure it can't be instantiated private constructer __construct() { } public static function addToQ( $arg, $anotherArg) { self::$queue[] = $arg.' - '.$anotherArg; } } // and then from within any method anywhere, call Notifier::addToQ('foo', 'bar'); ? Does that work for you? Regards, Wouter (ps. call me a purist, but a function defined in a class is no longer called a function, but a *method*) 2009/12/15 Allen McCabe allenmcc...@gmail.com Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... ?php $Notify-printQ() ? On Mon, Dec 14, 2009 at 6:07 PM, Nirmalya Lahiri nirmalyalah...@yahoo.comwrote: --- On Tue, 12/15/09, Allen McCabe allenmcc...@gmail.com wrote: From: Allen McCabe allenmcc...@gmail.com Subject: [PHP] Class not functioning To: phpList php-general@lists.php.net Date: Tuesday, December 15, 2009, 6:17 AM Hey everyone, I just delved into classes recently and have been having moderate success so far. I have a puzzler though. I have the following class decalred and instantiated: class Notify { var $q = array(); public function addtoQ($string, $class) { $message = 'span class='. $class .''. $string .'/span'; $this-q[] = $message; } public function printQ() { if (isset($q)) { echo 'p align=center class=notification'; foreach($this-q as $msg) { echo $msg .\n; } echo '/p'; } return; } function __destruct() { if (isset($q)) { unset($this-q); } } } // END CLASS Notify And in my script, I call it like so: $Notif = new Notify; I have run other statements in other classes that should be adding to the $q array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The Database!', 'error');) However, when I try to get my webpage to display them using: $Notify-printQ(); it does not seem to want to loop through this array (and print the messages). I am getting NO error message, in fact everything 'looks' fine, I'm just not seeing the appropriate message. Any help would be appreicated! Allen, You have made a small typing mistake in function printQ() where you would like to checked the array for its existence. By mistake you have wrote if (isset($q)). But your array variable is not an freely accessible array,the array is embedded into an object. So, you have to write the like if (isset($this-q)). Another point, you can't add a message into the array by calling the member function addtoQ() using scope resolution operator ::. If you really want to add message into the array, you have to call the member function from within the object. (ie. $Notif-addtoQ('ERROR! There Was An Error Updating The Database!', 'error');). --- নির্মাল্য লাহিড়ী [Nirmalya Lahiri] +৯১-৯৪৩৩১১৩৫৩৬ [+91-9433113536] -- http://www.interpotential.com http://www.ilikealot.com Phone: +4520371433
Re: [PHP] Class not functioning
Sorry, and then I didn't keep it on list :-( Shawn McKenzie wrote: Please reply to the list. Just google for php registry pattern. Here is a very basic example. There are better OOP people here than I. class Registry { protected $_objects = array(); function set($name, $object) { $this-_objects[$name] = $object; } function get($name) { return $this-_objects[$name]; } } // in main code somewhere $Registry = new Registry; $Meetgreet = new Meetgreet; $Notify = new Notifier; $Registry-set('Meetgreet';, $Meetgreet); $Registry-set('Notify', $Notify); // in Meetgreet $Registry = new Registry; $Notify = $Registry-get('Notify'); I'll post a singleton when I have more time. Allen McCabe wrote: Thank you for your response! Your answer is intriguing, and I would love some extrapolation! Meetgreet is only needed on 1, maybe 2 pages, so including it globally is not needed, and because all meetgreet business is done on a single page, so it is currently uncessary (however I will admit it isn't extendible this way). So what is this registry pattern you speak of? Thanks! Allen On Tue, Dec 15, 2009 at 2:30 PM, Shawn McKenzie nos...@mckenzies.net mailto:nos...@mckenzies.net wrote: Allen McCabe wrote: Hey all (and Nirmalya, thanks for the help!), I have a question that I just can't seem to find via Google. I want to be able to add messages to a qeue whenever my classes complete (or fail to complete) specific functions. I think have a call within my html to my Notifier class to print all qeued messages (via a function 'printQ'). How do I access a globally instantiated class from within another class? Example: ?php // INSTANTIATE $Meetgreet = new Meetgreet; $Notify = new Notifier; ... ... $Meetgreet-deleteSingle($id, 1); // This completes a function within Meetgreet class. That function needs to be able to use the Notifier function addtoQ(), how would this be accomplished? ? ... ... Several ways to do it. One would be to make the Meetgreet a singleton if it really is, and then use its static getInstance. I would probably use a registry pattern though. -- Thanks! -Shawn http://www.spidean.com http://www.spidean.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
On 2009-12-15, at 11:55 PM, Richard Quadling wrote: Do you have a default stream context defined for the http stream? Nope. A _LONG_ time ago, when I was using a firewall with NTLM authentication (which PHP doesn't deal with), I had to route all my calls through a local proxy. This was the code I had ... ?php // Define the default, system-wide context. $r_default_context = stream_context_get_default( array( 'http' = array( // All HTTP requests are passed through the local NTLM proxy server on port 8080. 'proxy' = 'tcp://127.0.0.1:8080', 'request_fulluri' = True, ), ) ); // Though we said system wide, some extensions need a little coaxing. libxml_set_streams_context($r_default_context); Now, you may not see this in your code, but may be in a script which is loaded via auto_prepend_file. Wish it were, but my test code is bare bones. I would also suggest running something like WireShark at the same time as your script. See if there is ANY traffic over the wire. Do the cURL and file_get_contents() code generate identical requests? cURL -- both PHP and command-line -- fetches files and URLs (remote and local) w/o issues. file_get_contents() fetches files, but fails on all URLs (remote and local). This is why I believe the problem lies with the machine's configuration and not the Firewall. It's pretty confounding, isn't it? I'm not sure what to do at this point. ...Rene
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
On 2009-12-15, at 11:55 PM, Richard Quadling wrote: Do you have a default stream context defined for the http stream? Nope. A _LONG_ time ago, when I was using a firewall with NTLM authentication (which PHP doesn't deal with), I had to route all my calls through a local proxy. This was the code I had ... ?php // Define the default, system-wide context. $r_default_context = stream_context_get_default( array( 'http' = array( // All HTTP requests are passed through the local NTLM proxy server on port 8080. 'proxy' = 'tcp://127.0.0.1:8080', 'request_fulluri' = True, ), ) ); // Though we said system wide, some extensions need a little coaxing. libxml_set_streams_context($r_default_context); Now, you may not see this in your code, but may be in a script which is loaded via auto_prepend_file. Wish it were, but my test code is bare bones. I would also suggest running something like WireShark at the same time as your script. See if there is ANY traffic over the wire. Do the cURL and file_get_contents() code generate identical requests? cURL -- both PHP and command-line -- fetches files and URLs (remote and local) w/o issues. file_get_contents() fetches files, but fails on all URLs (remote and local). This is why I believe the problem lies with the machine's configuration and not the Firewall. It's pretty confounding, isn't it? I'm not sure what to do at this point. ...Rene
Re: [PHP] Highlighting image map on load
I'm not sure if you can use CSS alone to highlight, but if you can, just give the area a class as you output it with PHP That's the problem, area itself isn't visible, so giving a CSS class won't highlight it. -- View this message in context: http://old.nabble.com/Highlighting-image-map-on-load-tp26777088p26807008.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php