Re: [PHP] Hey, I have a full time PHP developer position in Chicago!
Sorry I can't relocate at the time. Thanks for sending me the notification though. : ) Matt On Tue, Sep 10, 2013 at 10:41 AM, Steve Gadlin st...@blewt.com wrote: Howdy. My name is Steve, and I run the web department for Weigel Broadcasting in Chicago. We're looking for a senior-level PHP developer to add to our team. This is a full time gig with benefits. As it's an in-house thing, we're happy to meet with people outside Chicago if they're willing to relocate for the job. What do we need? Oh, just someone who's great with PHP. We need someone who can decipher our existing homegrown CMS and work with frameworks like Kohana and Wordpress. We need a Jack or Jill of all trades... someone comfortable using SSH and messing around from the Linux prompt, and someone comfortable learning a new API. An understanding of advanced front-end coding would be swell... but we have a front-end coder on staff, so a passing familiarity will suffice. You'll be building out websites with very large built-in audiences. This is rewarding work for an amazing company. And your boss will be some guy who, off hours, draws stick figure cats for people ( http://iwanttodrawacatforyou.com). Thanks for reading, and I apologize for dropping into your PHP party to simply spout ads at you. I promise to try and participate in some meaningful way when I see an opening! Interested? Know someone who's interested? Reach out to me directly ( st...@blewt.com) and we'll skip this whole resume nonsense. Beans! Steve Gadlin -- Steve Gadlin Blewt! LLC 312-77-BLEWT http://iwanttodrawacatforyou.com/Steev.org - IWantToDrawACatForYou.com - TwoFilmTShirts.com - Blewt.com http://blewt.com
[PHP] Re: mcrypt_create_iv - why so slow?
From: Nathan Nobbe Interesting, using MCRYPT_DEV_URANDOM instead of MCRYPT_DEV_RANDOM seems practically instantaneous. Still [raises] the question though, any idea what's holding up the show w/ MCRYPT_DEV_RANDOM? /dev/random is a high quality entropy source and requires more time to generate output, as it has to retrieve random stuff from keyboard interrupts, mouse interrupts, and other sources, and make sure it's got *really* random bits. /dev/urandom will just throw out a pile of pseudo-random bits of potentially lower quality immediately. You can see that by doing time dd if=/dev/random of=/dev/null bs=16k count=5 and repeating the same command with /dev/urandom. 1.312 seconds vs. 0.019 seconds here. Not much to do with PHP, though, just the way the Linux kernel people did things. /dev/urandom is probably the way to go for most normal random data needs. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
I've been on this list since the early 2000's. I used to participate a lot back then but then took up a non-php related job and I stopped paying attention to the list. I've been working again with php for the past 4.5 years but choose to just monitor the list and haven't participated much. Perhaps I should participate more. But yeah, I've been here like 12 years or so. God I'm getting old. On Sat, Mar 2, 2013 at 11:10 AM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip] ...good conversation... [/snip] I have been on this list for years and I have watched it ebb and flow. I have heard all the bad and good about PHP. The fact remains that we use PHP in some very heavy applications and it never fails us for what we want or need to do. I always encourage devs to use the proper tool for the job, and when using that tool use it to its maximum capability. Let each tool do the heavy lifting that it is designed to do. PHP can tote some really heavy loads when asked properly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Creating an Advanced Form
Jonathan Davies jonny1dav...@btinternet.com wrote: I am attempting to create an advanced form with 9 different search fields. I am [concatenating a bunch of bits together] so I don't have to [create] over 300,000 IF statements. mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource on line 261 I cannot seem to hit the nail on the [head] to why it [doesn't] work. [snip code] When you see that particular error message, you should print the query you're executing, or log it, or something. If you have more than 1 field set, it looks like you'd be doing something like: $q = select stuff1 ... order by blah1; $q += select stuff2 ... order by blah2; ...which gives you select stuff1 ... order by blah1select stuff2 , which is bad SQL syntax, which explains the error you're getting. I am not sure whether putting another space at the end of each substring would help, but that's the first thing I'd try. (I'm sure other people will say OMGPANIC procedural code! OH NOES, using mysql_* functions! Unclean! Unclean! AH!, so be prepared for that too) -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] redefine a define ...
Can you just switch the order? Instead of... define(SOME_CONSTANT,Generic Value); define(SOME_CONSTANT,Override Value); Why not do... define(SOME_CONSTANT,Override Value); if(!defined(SOME_CONSTANT)) { define(SOME_CONSTANT,Generic Value); } This should avoid any redefinition and thus the notices. Matt On Sat, Aug 25, 2012 at 3:07 PM, Matijn Woudt tijn...@gmail.com wrote: Op 25 aug. 2012 21:03 schreef Adam Richardson simples...@gmail.com het volgende: On Sat, Aug 25, 2012 at 2:27 PM, Lester Caine les...@lsces.co.uk wrote: What I was not expecting was a string of 'Notices:' complaining about the redefines. So how does one get around this message? One can't 'if defined' as the string needs to be replaced with the more appropriate one. I would say, why is this even a problem, or alternatively I just give up on E_STRICT and make sure it's disabled again on PHP5.4? Having spent several months getting the code clean on E_STRICT, switching it off again will really pig me off, but I can't see any real alternative given the number of languages and strings that will need reworking simply to get things clean :( Well, I'd do the following to avoid issues in the future. 1) Create a function like that below, which provides global access to variables and allows you to update existing values: function val($name, $value = null) { static $values = array(); if ($value === null) { return isset($values[$name]) ? $values[$name] : null; } else { return $values[$name]; } } 2) Create a php script that searches out define(SOME_NAME_PATTERN, value) and replaces that with val(some_name_pattern, value). 3) Create a php script that searches out SOME_NAME_PATTERN and replaces with val(SOME_NAME_PATTERN); Not too bad in terms of work, as PHP's parsing capabilities are really nice. Hope this gives you ideas :) Adam That's probably quite some work given the many defines.. Fact is, constants are, as the name says, constant. Would it be possible to just not include the general file? Second, though not 100% sure if it works for E_STRICT is using @ before all defines to silence the warning. You could do a simple replace for that.. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File moving hell on Windows
Mike Mackintosh wrote: What protocol are you targeting? FTP, SFTP, SSH, SMB, etc? From: Brian Dunning br...@briandunning.com Regular Windows networking. If you're using a 'Doze box, and you want to use PHP functions like rename(), then IIRC the only real option that you have is to do something like: system(net use m: \\BORG\SHARE PASSWORD /user:DOMAIN\USER); system(net use n: \\MACHINE\SHARE2 PASSWORD2 /user:DOMAIN2\USER2); rename(n:/path/to/file,m:/path/to/otherfile); /* more stuff */ system(net use n: \\MACHINE\SHARE2 /delete); // equivalent of umount //machine/share2 However, there may be a better/easier/more elegant way to do these things. Not sure; our PHP-running machines are all running Linux. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: http_referer. what's wrong with that?
While perhaps unlikely in common users it is also possible to prevent your browser from sending the referrer. IIRC, the referrer can also get mangled when passing through HTTPS (although I don't remember on which side, HTTP-HTTPS or HTTPS-HTTP or both) Matt On Thu, Jan 12, 2012 at 1:11 AM, Ross McKay ro...@zeta.org.au wrote: On Wed, 11 Jan 2012 21:27:58 -0800, Haluk Karamete wrote: [...] Notice: Undefined index: HTTP_REFERER in D:\Hosting\5291100\html\blueprint\bp_library.php on line 16 die; [...] But I'm still curious, what configuration am I missing so that http_referer is treated like that? You only get an HTTP_REFERER when you link to a page from another page. If you go directly to the page, e.g. by typing / pasting the URL into the location bar, or linking from an email, then there is no HTTP_REFERER. -- Ross McKay, Toronto, NSW Australia Let the laddie play wi the knife - he'll learn - The Wee Book of Calvin -- 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
[PHP] re: More Error Reporting Problems
From: Floyd Resler fres...@adex-intl.com I'm still having problems with error reporting and I'm not sure why. php.ini section: error_reporting = E_ALL ~E_DEPRECATED display_errors = On log_errors = On error_log = /var/log/php_errors.log Errors are neither getting displayed nor recorded in my error log. Check that /var/log/php_errors.log exists and that the user that your webserver is running as has permission to write to that file. touch /var/log/php_errors.log chown apache:apache /var/log/php_errors.log as root may work; modify user/group if necessary. /var/log is always owned by root and is 755, meaning that the webserver user doesn't have permission to create that file if it doesn't exist. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOS CLI?
On Thu, Dec 8, 2011 at 7:16 AM, Richard Quadling rquadl...@gmail.com wrote: On 2 December 2011 21:00, Matt Neimeyer m...@neimeyer.org wrote: Is there (or is there a way to compile) a DOS CLI version of a fairly recent version of PHP? I have not been able to find one using the powers of Google. You are pretty much stuck with no network services, limited memory and restricted extensions. Can you describe your project and to why it MUST run on such an ancient OS? We have a utility disk that we use for a variety of things where I work and some of them are DOS based. We use the purely DOS ones rarely enough these days that people have trouble remembering how to use them. I wanted to see if it would be possible to write a menu type front end that would detect what OS it is running under and present the tools and options that are suitable for that OS. My thought was to use PHP because it is cross platform (to some degree) and then in theory the disk could be run under anything that can run PHP and anything that would run under the current OS can then be presented to the end user. If there is a better solution than PHP I'm open to it, but I already know PHP so I figured that would make it easier. Basically I need to be able to present a menu to the end user so they can select the tool they want to run. We currently have tool disks for DOS, Windows and OSX. If I could combine them into one big disk/usb key I would be a hero around these parts. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOS CLI?
Is there (or is there a way to compile) a DOS CLI version of a fairly recent version of PHP? I have not been able to find one using the powers of Google. Not a Windows Command Prompt CLI but an actual CLI version of PHP that can be made to run in a real DOS environment? I'm sure I could find another scripting language for DOS but to prototype this project I'd like to not have to learn a new language as well. :) Thanks in advance for ANY suggestions. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
From: David Harkness davi...@highgearmedia.com I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends. ...and when you use CCR style, you can sing, I see a bad brace a-risin'? -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best editor?
Notepad!!! LOL.. I use netbeans but eclipse is nice. A lot of it is personal opinion. On Wed, Aug 3, 2011 at 9:46 AM, Florian Müller florip...@hotmail.comwrote: Maybe an adittional information: PSPad is completely freeware and portable. You can download it right here: http://pspad.en.softonic.com/ This would be the best idea if you can't run a local server, because if there is an editor with this functionality built in, he'd have to bring a little local server with it, and I really don't know an editor which is able to do that without an external software. Regards and much fun ;) Flo From: florip...@hotmail.com To: msa...@gmail.com; sstap...@mnsi.net CC: php-general@lists.php.net Date: Wed, 3 Aug 2011 15:40:12 +0200 Subject: RE: [PHP] Best editor? I'm using PSPad since one year, and I'm very happy with it. With your description, I think it is the most simple way with it: Connect it with a webserver, and then you can edit all files right on the server, so if you save, they are live. PSPad is actually even a portable program, and there are lots of syntax highlighters, so this program is very nice! Date: Wed, 3 Aug 2011 09:32:34 -0400 From: msa...@gmail.com To: sstap...@mnsi.net CC: php-general@lists.php.net Subject: Re: [PHP] Best editor? Let me clarify a bit... I don't own my own machine - I'm using my work computer. I can install an editor, but installing a full fledged server would be verboten (like WAMP). And while its not hard to set up a VM in virtualbox, I'd prefer not to if I don't have to. I know the functionality of testing inside the editor used to be there, I'd just like to see if I can find it again :) If I have to, i'll just go the VM route. On Wed, Aug 3, 2011 at 9:26 AM, Steve Staples sstap...@mnsi.net wrote: On Wed, 2011-08-03 at 09:22 -0400, Matty Sarro wrote: Hey everyone, I am a super newbie just beginning to learn PHP. Awhile ago, I had used aptana for dabbling with php and was amazed to find out that it had a built in php interpreter so I could do some minor testing without having to upload everything to a web server, or have a web server locally. Flash forward to now, and it looks like that functionality doesn't exist anymore (at least not by default). So, I'm curious what editors are out there? Are there any out there which will let me test PHP files without having to upload everything every time I edit it? Any help would be greatly appreciated. Thanks! -Matty I personally use Komodo IDE, but there are lots out there. There is the Eclipse with PHP, or there was the way I learned, NotePad (then switched to EditPlus+) Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] notices nightmare - looking for a regex solution
You can put an @ symbol in front each item that is throwing the error. That may take some time though. You could use something like find /htdocs_folder -name \*.php -print | xargs sed -i s/\$array_name/@$array_name/g That might get you what you're looking for. But be cautious because this method does not create a backup file for you. You can do a quick check (but not fool proof) by using this command find /htdocs_folder -name \*.php -print | xargs grep \$array_name | more You may need to remove the slash in front of the $ sign. Matt On Wed, Jun 1, 2011 at 6:26 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hi there, I am working on a pretty huge site with thousands of files with php code. Unfortunatelly the app throws a ton of notices du to missing '' in arrays. Of course I could simply disable the output on the dev server to surpress notices, but I would rather like to get it fixed. Has somebody a good idea on how to fix this automated somehow with regex? The vars are right now: $var[element] and should be $var['element'] I was looking into sed, but I was hoping that there is also a way in php. Has anybody a hint on how to get the regex done? I appreciate any help on that. Best regards, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] notices nightmare - looking for a regex solution
I was thinking about this a little more and thought that the method I sent before will work, but it has the potential of clobbering variables that are not related to this warning/notice. Best bet would be to create a list of file names that contain the offending variables then feed that to sed using cat file_name | sed... You can use the find | xargs grep method to create the initial list, then work from there. On Wed, Jun 1, 2011 at 6:26 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hi there, I am working on a pretty huge site with thousands of files with php code. Unfortunatelly the app throws a ton of notices du to missing '' in arrays. Of course I could simply disable the output on the dev server to surpress notices, but I would rather like to get it fixed. Has somebody a good idea on how to fix this automated somehow with regex? The vars are right now: $var[element] and should be $var['element'] I was looking into sed, but I was hoping that there is also a way in php. Has anybody a hint on how to get the regex done? I appreciate any help on that. Best regards, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: postgresql database access failure
Florin Jurcovici wrote: My personal recommendation, however, is to drop old-style procedural drivers and switch to PDO - it's much more convenient to use, IMO. Just be careful. PDO's implementation of MySQL doesn't implement the mysql_set_charset() function, or at least it didn't a while back according to my reading the PDO source. Setting a charset in the DSN was possible, but PDO didn't *do* anything with that setting. There are probably other minor holes out there. (Everything in these tables is UTF-8! Are you *sure* about that? It looks a lot like CP-1252 here, and here, and here) you use PDO, you don't need to study the API of various different DB drivers, and your code can easily switch from one database to another. This is true to some extent. There are probably a few odd cases where the native functions do more, or do it better than whatever the latest and greatest layer of abstraction does. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code quest
From: Kirk Bailey kbai...@howlermonkey.net OK, now here's a giggle; I like ssi includes. If I put the script in as an ssi include, will it still work? If you're using Apache, and you do !--#include virtual=something.php -- ...the PHP in something.php will execute and produce output, but something.php will not have any access to $_GET or $_POST or $_SESSION or any of those things. This is generally not what you want. If you do ?php include(something.php); ? ...then something.php will be able to see and work with the superglobals that have been set up further up the page, which is *usually* what you want. You could try both approaches in a test env and see what you get. I'll use SSI for dumb blocks of text and php include for smart blocks of code, because IME that tends to produce fewer instances of gross stupidity. Note that YMMV on all this and ICBW. -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Template engines
On Mon, Nov 8, 2010 at 9:39 PM, David McGlone da...@dmcentral.net wrote: On Mon, 2010-11-08 at 16:51 -0500, Steve Staples wrote: On Mon, 2010-11-08 at 14:41 -0700, Hansen, Mike wrote: I really like the idea of using a templating engine. Which one do you use? Why? For those that don't use templating engines, why don't you use them? for the longest time, i didn't know about them, and was breaking in and out of php, as well as didn't use ANY classes... then i was starting to play with phpbb, and found out a little about templates... so i borrowed the template engine from them for a personal project... and was pretty impressed. then shortly after that, i got a job with a company who used smarty templates... and was VERY impressed with them :) ever since then, i've been using smarty, and have been very happy since. I dont know of any others out there, but that is mostly becuase i am content with what smarty does for me (and prolly becuase i am too lazy to change now ;) ) all of my projects now consist of smarty, pear mdb2, phpmailer, jquery, fpdf (if needed), and pchart (again, if needed). these are my personal choices, and I have been happy with them so far ;) I agree 100%!! Everyone here pretty much knows how much I've ranted about smarty :-) IMHO it's smart to use smarty! ;-) -- Blessings, David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I have to agree with David here. Smarty may be an added layer to the whole mix, but it makes maintaining the template and application much simpler. Much better than mixing html/php all together in a single file. That and a single template is easily used in multiple applications if needed, ore in multiple files within the same application. IMHO the benefits far out way the negatives of using a template engine.
RE: [PHP] Pros/Cons of using mysqli prepared statments
Jay Blanchard jblanch...@pocket.com didst scribe: using stored procedures has a lot of advantages. If you need to change your SQL you can do it in one spot. It reinforces MVS or modular coding behavior, the SP becomes very re-usable. Security is improved. Performance can be improved. You can put the bulk of the data handling on the database where it really belongs because SP's can perform complex operations complete with control structures. Lastly it simplifies your PHP code. Just don't go too far. Years and years ago, I worked on a project where there were about 100 stored procedures, many of which were 200-300 lines long, many of which called other stored procedures which called other stored procedures. These procedures were frequently modified. Attempting to debug this can of worms full of Pandora's boxes was like pulling hen's teeth. The initial idea was for the app to do almost nothing but call stored procedures and display results; this caused a number of problems which were ignored or solved badly. (I'd almost forgotten that horrible mess where I had no input on anything design-related, thank you for reminding me) -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Receiving Live data
look at Prototype's PeriodicalUpdater: http://prototypejs.org/api/ajax/periodicalUpdater -- matt On Wed, Oct 27, 2010 at 5:10 PM, Cameron Mc Gorian came...@sbarow.comwrote: Hi, I want to find out if it is possible to receive live data using PHP and MySQL. I have am developing a website that will allow user to input data which will then be inserted into a MySQL database. What I want to do is when some one is viewing a page and new information has been inserted into the MySQL database it can trigger a notification letting the viewer know instead of them having to refresh the page to view new data. Any help would be appreciated and if this is not the correct list please advise where I should start looking. Thanks in advance. -- MySQL PHP Mailing List For list archives: http://lists.mysql.com/php To unsubscribe:http://lists.mysql.com/php?unsub=mander...@gmail.com
Re: [PHP] Eclipse, Komodo, Netbeans, Zend Studio, PHP Storm, other?
I've tried Eclipse and Netbeans and have found Netbeans to fit my needs well. On Wed, Oct 13, 2010 at 1:40 PM, James Diamond djdiam...@gmail.com wrote: Hey Mike, I use zend eclipse, love it. What I love about it is what I love about any IDE, code complete, project configurations, customizable preferences of the editor, etc. I have used Eclipse (Pre-Zend), Zend Eclipse, Zend Studio, Komodo, and Easyclipse. James On Oct 13, 2010, at 12:58 PM, Hansen, Mike wrote: I'm about to do a lot of work on an existing code base and I think I'd like to try an IDE. I currently use VIM for most editing. What IDE are you using? What do you like about the one you are using? Which ones have you tried? Mike -- 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
[PHP] Re: Is it possible to create a global namespace alias?
I'm assuming there is no way to make a global alias. Can anyone confirm/deny this? Matt Palermo wrote in message news:5e7b8989448b45dbbeeb6fb89b3f3...@rachet... Is it possible to create a global namespace alias in PHP or does the alias have to be defined in EVERY file that I use? Here is an example: file: main.php ?php use \this\is\my\custom\namespace\Item as nsItem; ? file: index.php ?php require_once “main.php”; // Attempt to use namespace alias defined in main.php file nsItem::test(); ? The above code doesn’t work for me. The namespace alias defined in the main.php file isn’t accessible in the index.php file. Is there a way to make the “nsItem” alias a “global” one, so that I don’t have to define it in EVERY file that I want to use? -Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is it possible to create a global namespace alias?
Is it possible to create a global namespace alias in PHP or does the alias have to be defined in EVERY file that I use? Here is an example: file: main.php ?php use \this\is\my\custom\namespace\Item as nsItem; ? file: index.php ?php require_once “main.php”; // Attempt to use namespace alias defined in main.php file nsItem::test(); ? The above code doesn’t work for me. The namespace alias defined in the main.php file isn’t accessible in the index.php file. Is there a way to make the “nsItem” alias a “global” one, so that I don’t have to define it in EVERY file that I want to use? -Matt
[PHP] Is it possible to create a global namespace alias?
Is it possible to create a global namespace alias in PHP or does the alias have to be defined in EVERY file that I use? Here is an example: file: main.php ?php use \this\is\my\custom\namespace\Item as nsItem; ? file: index.php ?php require_once “main.php”; // Attempt to use namespace alias defined in main.php file nsItem::test(); ? The above code doesn’t work for me. The namespace alias defined in the main.php file isn’t accessible in the index.php file. Is there a way to make the “nsItem” alias a “global” one, so that I don’t have to define it in EVERY file that I want to use? -Matt
[PHP] Downgrading HTML
I know I could possibly hack something together using the Tidy libraries... (maybe...) but are there any existing php libraries / projects that already have the ability to take some HTML and downgrade the version of HTML being used. One example: turn this... p style=font-weight: boldBlah/p ... into ... pbBlah/b/p This is for an eReader I love but is long out of production and the converter tool only works with HTML 3.2 Thanks in advance. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] adduser php
I am using php 5 on OpenBSD 4.7 I have a script which takes a username and password from $_POST, and is supposed to add the user to the system database. The problem is, adduser creates a username with the same name as the group. The code is: $username=$_POST['username']; $password=$_POST['password']; $output=exec('/usr/bin/sudo adduser -unencrypted -batch $username hosting $firstname $lastname $password'); echo result: . $result . output: . $output; The output is: Added user ``hosting'' I have validated that $username and $password contain the correct values from the form, by outputting them as well above the line which calls the adduser command. Any help is appreciated. Matt
Re: [PHP] adduser php
The only thing is, when I execute this command from a shell, it works. Obviously I'm replacing $username and $password with something valid when doing this manually. It's like the script clears the $username variable just before it executes the command, or because the variable is inside quotes, it is not getting through. From: Ashley Sheridan Sent: Saturday, July 10, 2010 2:01 PM To: Matt Morrow Cc: php-general@lists.php.net Subject: Re: [PHP] adduser php On Sat, 2010-07-10 at 13:45 -0500, Matt Morrow wrote: I am using php 5 on OpenBSD 4.7 I have a script which takes a username and password from $_POST, and is supposed to add the user to the system database. The problem is, adduser creates a username with the same name as the group. The code is: $username=$_POST['username']; $password=$_POST['password']; $output=exec('/usr/bin/sudo adduser -unencrypted -batch $username hosting $firstname $lastname $password'); echo result: . $result . output: . $output; The output is: Added user ``hosting'' I have validated that $username and $password contain the correct values from the form, by outputting them as well above the line which calls the adduser command. Any help is appreciated. Matt I'm not entirely sure about the syntax you're using here, as it doesn't quite match up with what I see on the useradd (which is what adduser synonyms to) man page (type 'man useradd'). Aside from that, be very, very, very careful with this command. In your example you've not sanitised the user input, and the useradd command is used to update details as well as add new users, and you're running it with root privileges under sudo. Maybe enforce some specific name mechanism (a prefix like 'yoursystemname_username') to ensure that people aren't unwittingly or deliberately trying to overwrite existing system user details. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Will PHP ever grow up and have threading?
unsubscribe
Re: [PHP] Will PHP ever grow up and have threading?
ok, how do I get off this list?
Re: [PHP] Fun with Streams
Basically... I built the stream encapsulation to do two things for me: 1. Keep track of the row I was on. 2. Keep track of the columns by name. So if I wrote columns Foo, Bar, Baz one time and Foo, Baz the next it would automatically keep the Baz in column three the second time. In other words, it makes it simple to just dump row after row of data into it for exports and simple reports. Matt On Mon, Feb 22, 2010 at 4:14 AM, Rene Veerman rene7...@gmail.com wrote: just curious, why did you choose to use it from behind a stream wrapper? On Sun, Feb 21, 2010 at 11:03 PM, Matt Neimeyer m...@neimeyer.org wrote: I created a stream wrapper around the php_writeexcel library found at http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fun with Streams
I created a stream wrapper around the php_writeexcel library found at http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/ My code can be seen at http://www.pastebin.com/m7212eaa2 I'm trying to add an option that will allow us to lower or uppercase the column headers we create by calling ftell on the Excel stream but when I do something like... $xls = fopen(xlsfile://../data/measurables.xls,wb); echo ftell($xls); ...I get 0 returned even though I've hard coded a return of 123 in my stream_tell function (which I did to see if my stream_tell was even being called). Can anyone tell me what I'm doing wrong or suggest another way to communicate into the stream wrapper that will be compatible with PHP 4 and 5 on OSX, Linux and Windows? Thanks Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Magnetic Stripe Reader or Barcode to PHP
If the scanning device hooks into the keyboard somehow it should be easy. I believe that's called a keyboard wedge. Basically, you scan and it types. My only exposure to this is using one of the old CueCat scanners to index my personal library into a php app I cobbled together. The CueCat hooked in line with the keyboard. You'd bring up the scanning page and an onload Javascript would place the cursor into the Scan ISBN Here text box. Scan the book and the input went where it was needed. I believe it also sent an enter keystroke which submitted the form. It's been a couple years since I played with it so there might have been some additional software that kicked the enter. Then you process the data as you would for any other text field submission. It worked well enough to catalog a couple thousand books in a single evening. Hope this helps Matt On Thu, Feb 18, 2010 at 5:42 PM, Daevid Vincent dae...@daevid.com wrote: So we're opening a new super-club here in Seattle. One of the ideas we'd like to pursue is that people are assigned a card. This can be a magstripe card or something with a barcode. Not really sure at the moment which way to go. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] storing a mysql query in mysql
Whats the best way to store a mysql query in mysql. I'm trying to store a mysql query in a debug log table if there is a problem with the query. I've tried using addslashes and a few other commands. I don't have a problem putting the data into the database but when I view it with sqlyog its f'ed up beyond belief. Is there another/better way to store this information? Thanks, Matt
Re: [PHP] Change styling depending on var value
Mari Masuda wrote: This may be a dumb question, but did you actually fetch the db query's results and put them in $row before trying to use $row? In MySQL you could do something like: $query = select * from my_table; $result = mysql_query($query); $row = mysql_fetch_array($result); //this statement would need to be inside of a loop if there is more than one result Thanks, Mari. That was it: I usually declare the variables first, then on with the rest of the code. I had inserted the $row conditional values right after the vars, before the rest of the query...just plain dumb. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CSS and variables
De-lurking here. I'm trying, with no success, to use some CSS styling on my PHP output. Here's the code I want to style: echo 'trtd class=spacer'.$row[0].'/tdtd'.$row[1].'/td I want to use a CSS style for the second td cell, picking up the style from the value of a variable. I tried this: $newcolor = color: red; td style= ? echo($newcolor): ?'.$row[1].'/td But it doesn't work. No problem with th spacer class, works fine. I just can't get the syntax for pulling a CSS style from a PHP var. TIA for your help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: Copying back the phplist *again*! Sorry. I'll remember to copy in... what does your code currently look like now, with the right == in? $entree=meat; $beverage=coffee; if ($row[3] == $entree) { $newcolor=color:red; } elseif ($row[3] == $beverage) { $newcolor=color:red; } else { $newcolor=color:green; The result is that all of the text in the styled cell is green. td style='.$newcolor.''.$row[3].'/td I know the script is running through the conditional statement, because if I change the ELSE value of $newcolor, all of the styled cells change to whatever color I specify there. I went back and browsed the db table to see to make sure I had the right row and that the entries matched my references - no probs there. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Dan McCullough wrote: To add to what Ashley said about $row[3], remember that when you are returning from the db the counter for fields will start at 0 not 1, so if its the 3rd field that will be $row[2]. You might also want to do switch rather then elseif but thats always a good debate. Thanks, Dan. I had checked that a while ago. I also tried the same script on a different row, changing the strings in the variables to match the data in the fields - same result, always defaults to the ELSE color. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] CSS and variables
Jônatas Zechim wrote: Try: echo 'td style=' . $newcolor .'' . $row[1] . '/td'; Thanks, Jônatas. This was the solution. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: copy the results of this: vardump($row); Sirloin Steak freshAcmemeat Chicken Breast frozen Acmemeat Decaf Columbianpantry Giant coffee Ice Cream frozen Giant dessert All looks as expected. NB: This is just test data until I get the formatting right. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: That's not a vardump, a vardump would contain the type of variable. I wanted to see the whole thing. I played with this for a while and checked the PHP manual; not sure how to use this. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: As Mike pointed out, I meant var_dump(), sorry! Is the idea to put the variable in question within the parentheses? I tried the statement, var_dump($row[3]; And I got in the output: NULL Also tried var_dump(); And I got in the output: Warning: Wrong parameter count for var_dump() in... I reread the PHP manual for var_dump. I still don't see where it goes in the PHP script or how to implement it. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: put var_dump($row); I inserted this line in the script at the end of the html table, still inside the PHP echo statement. This yields: bool(false) Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!
Probably a year or so ago I asked on this list before and basically the response was that this should be impossible that it shouldn't happen... So I'm asking again hoping someone new to the list can suggest something that might lead to a fix or that someone else has run across the problem in the intervening time frame. One of our products allows you to mail merge using an uploaded data file and have the results emailed to the recipients. IE works fine, always has. Firefox at some point started having the data disappear halfway through the merge and now the most recent version of Safari ALSO has the data disappear halfway through the merge. This means that users of Macs don't really have any options where before at least we could point them to Firefox. (Not our favorite option but at least it worked) Here's the process: 1. Menu of what type of merge you want to do. (Initialize working table) 2. Process Data File (Initialize working table and then load in new data) 3. Build Email 4. Send out Email And by disappear I mean that when the end user gets to step 3 and hits preview with data to see what their final email will look like our program basically responds No data in your merge table OR the user hits the Merge button and again it says No records to merge... I've checked both using the app and by watching the underlying MySQL tables... I added a line to the Initialize function to email me every time it's called (for debugging users) and I get 2 emails for IE users and 4 emails for Firefox. I USED to only get 2 emails from Safari uses but with the latest version I get 4 now. I've always been told it shouldn't matter what browser is being used... but I have no other explanation of why it DOES matter... I've tried disabling prefetching in Firefox (thinking MAYBE the browser was prefetching the bailout link back to step 1 from step 3). The initialize in step 1 fixed another problem we were having but I did try disabling it temporarily to no avail. Does anyone have any ideas on what could possibly be causing this? Thanks! Matt Neimeyer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!
No answers - just more questions to maybe point you in a direction you haven't been Anything is appreciated... Is it possible that the query/script is taking too long to build the response page and FireFox/Safari is asking for an empty query result? I don't think so... the tracer emails I get from the initialize function are usually a couple seconds apart. It's almost like the browser is trying to make two simultanious requests which is why I was thinking maybe prefetching... You mention MySQL but is there any JavaScript involved in the data/result set. I am not a JS expert, but there could be differences in IE/FF/Saf JavaScript that could cause this. The only javascript is from the upload screen a popup window is created that says wait patiently please and then on the next screen a javascript that closes that popup window. (The email editor is javascript heavy but the data is already gone by the time you get to that point. And the only reason the popup exists is because the email editor requires popups and we have impatient users...) When you duplicate this with your data and get the error response, does the script show a records in the response query, even though it reports no records? No. By the time the editor screen loads the data really IS gone. If I sit in a mysql session and keep refreshing the table I see data... data... data... data... no data... I only mentioned the error responses as a way (not phrased the best) to indicate that it didn't see any correlation to this branch of code or that branch of code (for example if I could narrow it down to it disappears when I preview then I would know to look at the preview pages) Sorry but no definitive answers... Thanks though... the reason I keep pounding my head on the desk is that we deliberatly try to keep all the processing on the server side to avoid cross-browser and cross-platform issues. So sure... maybe a style sheet breaks... maybe a minor javascript doesn't work quite right... maybe the font sizes change and things are out of alignment... but the heavy lifting happens behind the scenes where they don't need to worry about it. Not very Web 2.0 but it's been steady (with this exception) so far. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!
If it were prefetching, or another request clobbering your current request then you would see a second hit in your server logs. I will admit... I have made (at least) one assumption... Since... 1. This is a difference between IE and Firefox/Safari... 2. I was seeing a tracer email for each hit to the Initialize function... I have been assuming that it is the browser that has been the cause. I'm 90% certain that last year we DID check and we DID see multiple web hits... That said I will make an explicit check and see if there are multiple hits in the web server logs now for the Safari as well. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm not crazy I swear it... IE vs Safari and Firefox - The impossible!
In circumstances like this, I would instrument the code with echo/print statements all around where you think the problem is. We did that with no luck. We only saw one call to the initialize function which is why I switched to tracer emails because we knew the initialize function was the only possible explanation but couldn't prove it based on any output to the browser. As with other responders, I have to say that if you're doing the processing on the server, it doesn't make any sense. Um... one other wild possibility I almost hate to mention. I don't recall if you mentioned whether your server was running Windows or not. I did not mention... Sorry... according to phpinfo() it's PHP 5.2.5 on Apache/2.0.52 on CentOS under Plesk 8.2.0. SELECT version() on MySQL reports 4.1.20-log. The MySQL API version in phpinfo() is 4.1.20. If it matters from what I can tell the entire toolchain is 64-bit (for example the php configure command reports --build=x86_64-redhat-linux-gnu) But I wouldn't put it past Microsoft to barf under certain circumstances if the user agent (browser) isn't IE. Neither would I... but unless I have to for some other reason I prefer PHP 5+, MySQL 5+, Apache 2+ and a *nix of some flavor for my web serving needs. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Determining Calling Script Information
Hi, Is there a way (other than using __LINE__ and __FILE__) to determine which file line called a function/method? I would like to add some debugging information to a method but I don't want to have to go through to each line that calls it and add the __LINE__ and __FILE__ parameters. Guess I'm looking for a simple solution. Anyway, if there is a way just point me in the right direction and I'll take it from there. Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Determining Calling Script Information
Thanks for the pointers! Matt Robert Cummings wrote: Matt Giddings wrote: Hi, Is there a way (other than using __LINE__ and __FILE__) to determine which file line called a function/method? I would like to add some debugging information to a method but I don't want to have to go through to each line that calls it and add the __LINE__ and __FILE__ parameters. Guess I'm looking for a simple solution. Anyway, if there is a way just point me in the right direction and I'll take it from there. See the help for debug_backtrace() Cheers, Rob. -- Matt Giddings Web Programmer Information Technology Services Saginaw Valley State University Phone: 989.964.7247 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script to Compare Database Structures
I finally got a chance to play with this and it looks like it is exactly what I need. Thanks! On Fri, Jul 31, 2009 at 11:50 PM, German Geekgeek...@gmail.com wrote: have you tried mysqldiff? I want to be able to compare the structure of two different clients databases that might be on different servers that are firewalled away from each other. Given the two structures it will list all the SQL commands needed to make the database structure the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: This isn't infinitely recursive is it?
I like it... Thanks! On Thu, Jul 30, 2009 at 8:04 PM, Ben Dunlapbdun...@agentintellect.com wrote: I don't THINK I need to worry about circular mappings... but I'm not sure how to check for it if I did... Would the following work? It avoids recursion entirely and also checks for circular mappings. You can plug in your own code where the comments are to do whatever is appropriate when a circular mapping is detected. function GetMappedField($Field) { $OriginalField = $Field; while (isset($FieldMap[$Field])) { $Field = $FieldMap[$Field]; if ($Field === $OriginalField) { /* * circular mapping has been detected; * report an error or explode or whatever */ break; } } return $Field; } Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script to Compare Database Structures
I know I CAN hack something together but I hate to reinvent the wheel. I want to be able to compare the structure of two different clients databases that might be on different servers that are firewalled away from each other. Given the two structures it will list all the SQL commands needed to make the database structure the same. In a perfect world on one side you would pull up a PHP page that does a generate structure which would create a downloadable file which you could then upload to the other system which would then give a listing of the SQL commands needed to make the local structure match the uploaded structure. Thanks in advance... Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] This isn't infinitely recursive is it?
I'm cleaning up some inherited code in our data import module. For a variety of reasons we have to support old standards of the import format. Since some of those old versions were created we have since renamed some fields in our data structure. So right now I've a hard map for some field names... function GetMappedField($Field) { $FieldMap[A] = B; $FieldMap[C] = D; return isset($FieldMap[$Field])?$FieldMap[$Field]:$Field); } But I've just spent a while tracking down a bug where someone mapped A to B and then someone else mapped B to C. I'm thinking of changing the return to... return isset($FieldMap[$Field])?GetMappedField($FieldMap[$Field]):$Field); ...but I'm worried about the recursion. (Which isn't a strength of mine) I don't THINK I need to worry about circular mappings... but I'm not sure how to check for it if I did... Any suggestions? Thanks! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Broken IF behavior? (Changing the branch changes the evaluation)
$Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; } I'm assuming that you are calling my_fetch_array() in a loop of some sort and so at some point there are no more records in the result. Oh... Um... Yeah... Well... headdesk So... Checking the docs... Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. Is there a way to differentiate between a FALSE for no more rows and an error? Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Broken IF behavior? (Changing the branch changes the evaluation)
Background: I'm converting a webapp from Visual FoxPro as a backend to MySQL... However one part of our app (a system status checker) is common code between the versions. I've got the following function... In English (in case it's not apparent), if the version of the app is 2.0 or higher, then use MySQL functions, otherwise use the ODBTP function to connect to VFP. function my_fetch_array($result) { global $Version; if(version_compare($Version,2.0,=)) { $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; } } else{ $Ret = odbtp_fetch_array($result); if(!$Ret) { } else { return $Ret; } } } This feels like a hack but works perfectly. Data is returned and all is right with the world. Until I added in extra error reporting. When I change the if(!$Ret) portion as such... if(!$Ret) { die(myError.mysql_error()); } else { return $Ret; } It ALWAYS dies... and I see myError on the screen... If I change it like such... if(!$Ret) { } else { echo notError; return $Ret; } I always see the notError on the screen and $Ret gets returned. WHY does adding the die() inside the { } change the way the if is evaluated? By the way I've tested this on 4.4.x on OSX and Windows, and on 5.2.5 on Windows... Thanks Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken IF behavior? (Changing the branch changes the evaluation)
It's exactly what I would expect... The content of the row... But in any case, what does changing the content of the { } branch have to do with how the IF() itself is evaluated? array(4) { [0]= string(8) CustName [config]= string(8) CustName [1]= string(11) Sample Cust [value]= string(11) Sample Cust } On Tue, Jul 28, 2009 at 2:56 PM, Eddie Drapkinoorza...@gmail.com wrote: On Tue, Jul 28, 2009 at 2:48 PM, Matt Neimeyerm...@neimeyer.org wrote: Background: I'm converting a webapp from Visual FoxPro as a backend to MySQL... However one part of our app (a system status checker) is common code between the versions. I've got the following function... In English (in case it's not apparent), if the version of the app is 2.0 or higher, then use MySQL functions, otherwise use the ODBTP function to connect to VFP. function my_fetch_array($result) { global $Version; if(version_compare($Version,2.0,=)) { $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; } } else { $Ret = odbtp_fetch_array($result); if(!$Ret) { } else { return $Ret; } } } This feels like a hack but works perfectly. Data is returned and all is right with the world. Until I added in extra error reporting. When I change the if(!$Ret) portion as such... if(!$Ret) { die(myError.mysql_error()); } else { return $Ret; } It ALWAYS dies... and I see myError on the screen... If I change it like such... if(!$Ret) { } else { echo notError; return $Ret; } I always see the notError on the screen and $Ret gets returned. WHY does adding the die() inside the { } change the way the if is evaluated? By the way I've tested this on 4.4.x on OSX and Windows, and on 5.2.5 on Windows... Thanks Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What's the output of var_dump($Ret) right before that if statement? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting SQL Dialects
You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''. MySQL seems to be pretty forgiving with its implicit type-casting. Hmm... The new system I've written properly handles the datatype and EMPTY... So this would be a hack to much around with regexs to replace EMPTY in customer built selects. Now I fiddled around with this on 5.1.33-community on Windows and I get the following odd results... select coalesce(0,)=0,coalesce(,)=0,coalesce(0,)=0,coalesce(,)=0; returns 1, 1, 1, 1 but... select coalesce(0,)=,coalesce(,)=,coalesce(0,)=,coalesce(,)=; returns 0, 1, 0, 1 Which implies that in certain circumstances = 0 but 0 != (unless I'm missing something). Either way it looks like I can use coalesce(X,)=0 which should be useful! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Converting SQL Dialects
Has anyone come across / written a script that will convert one flavor or Dialect of SQL to another? I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL. For the most part the problems are converting VFP functions to the equivalent SQL. For example, Visual FoxPro has a function inlist() that is used like inlist(X,1,2,3) which converts to the MySQL query X IN (1,2,3). That's easy enough (relatively speaking) but VFP also has stuff like EMPTY(X) where any of Null, the Empty String (for Char), -00-00 (or the VFP equivalent anyways for dates), False (for Boolean), 0 (for Numeric) are considered empty without needing to know the data type. So that starts getting a lot more complex since I'd need to check the data type of the field in the right table... to be able to convert it to something like (X is null OR X=) or (X is null OR x=0) etc... These are for customer stored queries... I've already manually converted system queries and I'm frustrated to the point of giving up and adding a column untested and let the end user figure it out but that seems bad from the standpoint of lazy and poor customer experience. Thanks! Matt P.S. I'm also going to post this to the MySQL general list but my fear is that they MIGHT say We only know MySQL so we can't help you with that other DBMS I'm hoping that by posting here someone might say well it's not to MySQL but I ran script XYZ to convert my VFP to PostgreSQL... or similar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and FoxPro
What I did to handle memos... and it's a HACK... was to create a function DoMemo that took as arguments the table, the primary key field of the table, the value of said pk, the field to update, and the string. Take the first 200 characters of the string. Replace all newlines in that substring with +CHR(13)+ (Or CHR(13)+CHR(10)?) Then do something like: UPDATE table SET field=First200 WHERE pk=pkvalue Then take the next 200 characters of the string. Replace all newlines as above Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE pk=pkvalue Repeat until you've consumed the entire string. This works because you never put in more that 250 odd characters at a time. It can still fail though if you have enough newlines to push your 200 characters up over the 250 odd character limit. It DOES work if you use RECNO() as the pk field and the appropriate recno() that you would get if you did something like SELECT recno() AS myrecno,* FROM sometable (I use the myrecno because otherwise you get some weird exp_1 field name) It just popped into my head... I wonder if something like this would work... UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y You might be able to limit the total number of calls to the database that way... If I wasn't in the process of migrating to MySQL I might give it a whirl... :) Hope this helps whatever you decide to do. On Tue, Jul 21, 2009 at 8:27 AM, Floyd Reslerfres...@adex-intl.com wrote: Matt, Thanks for the information. I'll look into using ODBTP. I noticed you mentioned the problem with memos. I currently have that problem with the set up we're using and it is a pain! Thanks! Floyd On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote: We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro database. The problem is that the bridge, after a while, starts consuming a ton of system resources and we have to reboot the machine. Afterwards, it can take upwards to two hours before everything is running quickly again. We need another solution. Does anyone know of a any other way to connect to a remote FoxPro database (or any ODBC source that isn't a database server)? We've had a LOT a luck using ODBTP. Which can be found at http://odbtp.sourceforge.net Here's the rough outline... 1. Install Visual FoxPro odbc driver (or whatever drivers you want) on a Windows machine. 2. Install the ODBTP Server on the windows machine 3. Install a PHP module in your php. (Common ones included in the download) 4. Once you connect the functions are ALMOST exactly the same in usage as the mysql_xyz functions. A couple gotchas: 1. If you need to compile the PHP ODBTP module from source on x64 (OS X Leopard at least) it can be a pain. 2. The VFP 6.0 ODBC driver (not sure about higher versions) does not allow more than 250 odd characters to be inserted at a single time so memo's can be a PAIN. 3. It does require a port be opened on the Windows machine's firewall... (Uses TCP/IP for communication) 4. By default the ODBTP server can use up to 32 threads. The VFP ODBC driver is by nature single threaded. We've never had a problem with that directly but I assume it is what causes threads to slowly hang and disappear... eventually a message comes up Unable to create thread. At that point you simply need to restart the ODBTP service in the Windows Services Control Panel. The bigger the tables and the more heavily used it is the more often this will happen. Other than that... Works like a charm. Looking forward, once you bite the bullet and convert to MySQL (at least for us) you can almost change odbtp_ to mysql_ and be up and running. (Assuming you limit yourself to pure SQL and not invoke VFP functions.) Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting SQL Dialects
Um... It depends? :) These are customer entered queries and vary based on the end user and the customizations they have. It could be as simple as WHERE inlist(SalesPerson,Bob,Bill,Fred) OR it could be something 12 lines long that pulls in criteria from multiple tables each of those with their own criteria. And by easy I meant simply that I would feel comfortable hacking together something to handle inlist(x,1,2,3) and change it to X in (1,2,3) it's the rest that worries me. Having slept on it, I'm probably going to write something that converts IN, checks for a list of forbidden words and then flags the resulting updated query if it contains any of those words. This way I can catch some of the low hanging fruit. My hope is that if X% of queries don't contain foxpro specific functions, and IN auto-conversions covers another X% of upgrades, and auto-convert FunctionX (whatever it is...) gives us another X% of upgrades... that this will result in a hopefully small number of saved queries that are flagged for manual upgrading. (And not be so painful in development that it still nets us saved time) Matt On Tue, Jul 21, 2009 at 1:54 PM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote: Has anyone come across / written a script that will convert one flavor or Dialect of SQL to another? I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL. For the most part the problems are converting VFP functions to the equivalent SQL. For example, Visual FoxPro has a function inlist() that is used like inlist(X,1,2,3) which converts to the MySQL query X IN (1,2,3). That's easy enough (relatively speaking) but VFP also has stuff like EMPTY(X) where any of Null, the Empty String (for Char), -00-00 (or the VFP equivalent anyways for dates), False (for Boolean), 0 (for Numeric) are considered empty without needing to know the data type. So that starts getting a lot more complex since I'd need to check the data type of the field in the right table... to be able to convert it to something like (X is null OR X=) or (X is null OR x=0) etc... These are for customer stored queries... I've already manually converted system queries and I'm frustrated to the point of giving up and adding a column untested and let the end user figure it out but that seems bad from the standpoint of lazy and poor customer experience. Thanks! Matt P.S. I'm also going to post this to the MySQL general list but my fear is that they MIGHT say We only know MySQL so we can't help you with that other DBMS I'm hoping that by posting here someone might say well it's not to MySQL but I ran script XYZ to convert my VFP to PostgreSQL... or similar. I'm not sure it's as easy as you think it might be. As you get more into the various flavours of SQL, you notice their little idiosyncrasies that only exist within that one particular language branch. As such, it's often a task best left to people to try and convert from one to the other, rather than leave it to a machine. How complex are the queries that you are trying to convert anyway? Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and FoxPro
We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro database. The problem is that the bridge, after a while, starts consuming a ton of system resources and we have to reboot the machine. Afterwards, it can take upwards to two hours before everything is running quickly again. We need another solution. Does anyone know of a any other way to connect to a remote FoxPro database (or any ODBC source that isn't a database server)? We've had a LOT a luck using ODBTP. Which can be found at http://odbtp.sourceforge.net Here's the rough outline... 1. Install Visual FoxPro odbc driver (or whatever drivers you want) on a Windows machine. 2. Install the ODBTP Server on the windows machine 3. Install a PHP module in your php. (Common ones included in the download) 4. Once you connect the functions are ALMOST exactly the same in usage as the mysql_xyz functions. A couple gotchas: 1. If you need to compile the PHP ODBTP module from source on x64 (OS X Leopard at least) it can be a pain. 2. The VFP 6.0 ODBC driver (not sure about higher versions) does not allow more than 250 odd characters to be inserted at a single time so memo's can be a PAIN. 3. It does require a port be opened on the Windows machine's firewall... (Uses TCP/IP for communication) 4. By default the ODBTP server can use up to 32 threads. The VFP ODBC driver is by nature single threaded. We've never had a problem with that directly but I assume it is what causes threads to slowly hang and disappear... eventually a message comes up Unable to create thread. At that point you simply need to restart the ODBTP service in the Windows Services Control Panel. The bigger the tables and the more heavily used it is the more often this will happen. Other than that... Works like a charm. Looking forward, once you bite the bullet and convert to MySQL (at least for us) you can almost change odbtp_ to mysql_ and be up and running. (Assuming you limit yourself to pure SQL and not invoke VFP functions.) Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Launch Windows Program from PHP
I'm probably just not Googling right... Short version: How can I launch a program for the current user sitting in front of a windows web server? Longer version: I've written a PHP app to migrate data from the FoxPro version of our product to the upcoming MySQL version. I have a self contained setup on an XP box consisting of XAMPP, DBConvert (a data conversion program) and the ODBTP client/server. Phase 1 is a PHP app the pre-preps the data through ODBTP to a local FoxPro DBC. Phase 2 is the DBConvert and Phase 3 is a PHP app again doing post-conversion stuff in MySQL. To help in automating the whole shebang I'd like to automatically launch DBConvert with a command line argument (for the right data conversion stored session). Whenever I Google I find stuff about launching background tasks or using things like popen to launch processes inside the web server. I don't care if the owner of the process is the user at the keyboard just that they can interact with it. And if its Christmas and I can get everything I want :)... I'd love for PHP to be able to watch the process and stay resident until it exits so at that point I can send a final bit of javascript that will cause phase 3 to automatically start. Any ideas? Thanks! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Split up Date Range
I haven't been able to find anything by googling... Does anyone know of any libraries that will split up date ranges? We've got a project where Date Of Attendance is moving from a single type in character field to an automatically built field based on a DateBegin date field and a DateEnd date field. Some examples of what I'd like ideally... Given: July 19-22, 2009 Return: 7/19/2009 and 7/22/2009 Given: July 19th and 20th Return: 7/19/2009 and 7/20/2009 (we can safely assume current year for this project) Given: Sept 19, 2009 - Sept 22, 2009 Return: 9/19/2009 and 9/22/2009 Given: July 19th, 2009 Return: 7/19/2009 and 7/19/2009 Given: 7/19/2009 Return: 7/19/2009 and 7/19/2009 I could probably hack something together that would work most of the time... but why reinvent the wheel if some poor shlub has already done it. If such a thing doesn't exist... then I'm considering an algorithm like such... (and advice... yays and nays are appreciated) Replace the names (and variations thereof) of the months with their numeric equivilants followed by a comma. So the above would become... 7, 19-22, 2009 7, 19th and 20th 9, 19, 2009 - 9, 22, 2009 7, 19th, 2009 7/19/2009 Then replace all the th and nd and st with nothing... replace all the ands with a dash... and eliminate spaces... and change / to , Giving... 7,19-22,2009 7,19-20 9,19,2009-9,22,2009 7,19,2009 7,19,2009 Then explode on commas. If you have two elements populate the third with the current year. (This fixes 7,19-20 to 7,19-20,2009). Not a given example, but it would also fix 7/19 to 7,19,2009. When you have three elements then you have a valid date. Loop over each element and populate begin and end, if you find a dash in the current element then split on the dash and populate as needed. Yes this would allow 7-8,19-20,2009 to create 7/19/2009 and 8/20/2009 but I think its as safe as any assumption that regular people wouldn't enter that as a date range. If you have more than three elements then split on the dash and as long as you have have only two elements then consider each item by itself. If it's not handled by the above rules then don't split it up. Thanks in advance. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT mysql pivot table problem
Ummm yeah, its going to take me a while to wrap my head around that one. thanks though! Matt On Thu, Jun 25, 2009 at 5:07 PM, Andrew Ballard aball...@gmail.com wrote: On Thu, Jun 25, 2009 at 4:21 PM, Andrew Ballardaball...@gmail.com wrote: On Thu, Jun 25, 2009 at 3:20 PM, Matt Giddingsmcgid...@svsu.edu wrote: I know this is the off topic (sorry), but it is a php project that I'm working on! I need some pointers on how to pivot a mysql column (containing comma delimited data) into an equal number of rows (see example). Any direction (pointers to links, etc. would be appreciated). From this: user.table uid|name|groups 1|mcgiddin|1,4,7,10,12 To this: pivot.table uid|group 1|1 1|4 1|7 1|10 1|12 The best performance I've seen for a SQL solution uses a tally table. CREATE TABLE Tally ( N int not null, PRIMARY KEY (N) ) The table holds a sequence of numbers from 1 to some large number. Then you can write a query something like this: SELECT uid, SUBSTRING(user.table.groups,N+1,LOCATE(',',user.table.groups,N+1)-N-1) FROM Tally, user.table WHERE N LENGTH(user.table.groups) AND SUBSTRING(user.table.groups,N,1) = ',' Andrew OK, I actually tested this and it appears I missed something. For this query to work, the string has to begin and end with the delimiter. So I just replaced user.table.groups with CONCAT(',', user.table.groups, ','). SELECT uid, SUBSTRING(CONCAT(',', user.table.groups, ','),N+1,LOCATE(',',CONCAT(',', user.table.groups, ','),N+1)-N-1) FROM Tally, sample WHERE N LENGTH(CONCAT(',', user.table.groups, ',')) AND SUBSTRING(CONCAT(',', user.table.groups, ','),N,1) = ',' For more in-depth information, check out some of the links in this search: http://www.google.com/search?q=sql+split+tally+table Andrew -- Matt Giddings Web Programmer Information Technology Services Saginaw Valley State University Phone: 989.964.7247 http://www.svsu.edu
[PHP] OT mysql pivot table problem
I know this is the off topic (sorry), but it is a php project that I'm working on! I need some pointers on how to pivot a mysql column (containing comma delimited data) into an equal number of rows (see example). Any direction (pointers to links, etc. would be appreciated). From this: user.table uid|name|groups 1|mcgiddin|1,4,7,10,12 To this: pivot.table uid|group 1|1 1|4 1|7 1|10 1|12
Re: [PHP] OT mysql pivot table problem
Thanks for taking the time to provide an example. I'm going to take the advice given by you and others and simply do this in php instead of looking for a fancy mysql solution. ; ) Dang, and I was really wanting to wow myself today... Thanks again! Matt On Thu, Jun 25, 2009 at 3:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Thu, 2009-06-25 at 15:20 -0400, Matt Giddings wrote: I know this is the off topic (sorry), but it is a php project that I'm working on! I need some pointers on how to pivot a mysql column (containing comma delimited data) into an equal number of rows (see example). Any direction (pointers to links, etc. would be appreciated). From this: user.table uid|name|groups 1|mcgiddin|1,4,7,10,12 To this: pivot.table uid|group 1|1 1|4 1|7 1|10 1|12 I don't know of any fancy ways of doing it just in MySQL, but if the records are all as simple as that, something like this should do the trick: $query = SELECT * FROM `user`; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $uid = $row['uid']; $groups = explode(','$row['groups']); for($i=0; $icount($groups); $i++) { $query2 = INSERT INTO `pivot` VALUES($uid, $groups[$i]); $result2 = mysql_query($query2); } } Also, I'd recommend having some sort of auto increment value on that pivot table, so you can manipulate specific rows at a later date. Thanks Ash www.ashleysheridan.co.uk -- Matt Giddings Web Programmer Information Technology Services Saginaw Valley State University Phone: 989.964.7247 http://www.svsu.edu
[PHP] PHP module portability on OSX 10.4
I know this is a bit OS specific but it's for PHP so I'm hoping someone here has run into it before and can answer. I've compiled php_gd.so for use on an XServe running OSX 10.4. It works fine there. When I copy it to another XServe it fails because of missing dependencies (don't remember the exact error but that was the jist of it). I used otool -L php_gd.so and got the following... php_gd.so: /usr/local/lib/libpng12.0.dylib (compatibility version 33.0.0, current version 33.0.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.1.11) libz.1.dylib and libSystem.B.dylib exist on a raw machine so I assume it's just the libpng. So... Can I just ALSO copy the libpng file, drop it in the right place and have it work? It seems like it should work... but at the same time, something in my head is telling me it shouldn't work... Barring that does anyone have steps written down that I can follow to compile php_gd.so with libpng compiled in somehow so it is only one file? Thanks in advance! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Same Page, Fundamentally Different Behavior OR is Firefox broken?
I'd have to check... But am I to understand that no-cache works with pre-caching? I always assumed it basically meant when you get this page, don't keep it for next time? Thanks! On Fri, Jun 12, 2009 at 2:04 AM, Manuel C.hippopotam...@gmail.com wrote: Matt Neimeyer a écrit : I'm at a complete loss... So I'm hoping someone can point me in the right direction to even start looking. We have an application written in PHP that lets users send out emails. The basic process is as follows. 1. Go to start screen. (This resets anything currently in process for the current logged in user) 2. Upload email addresses and other info (Names, etc) 3. Build Email 4. Send In Step 3 the user can click a Live Preview button to see what the email will look like with the merged data. Here's the problem, this works fine in all versions of IE, versions 1.5 or less of FireFox and versions 3 or less of Safari. However, starting in FireFox 2, and now Safari 4, when you get to step four OR click the live preview button in step three there is no more data in the merge. In those browsers the system is acting like the end user went BACK to the start page (in another window?) and reinitialized all the data. I immediately thought it might be pre-fetching so I tried using the system before and after toggling the network.prefetch-next setting in about:config with FireFox 2.0.0.20 and restarting the browser. No luck. So I added code to my reset function to email me the output of phpinfo() when the reset function is called. Using IE I get 1 notification. Using FF I get two notifications. This reinforces my theory that FireFox is prefetching the menu item to start a new mailing (just an a link...) from the top of the composer page. Even still... I've disabled prefetch so it SHOULDN'T even be considering those links right? I've also tried adding artificial ?now=timestamp fakes to the end of all menu links since I read somewhere (don't remember where) that FireFox only prefetches pages with no query section in the address. Has anyone run into this behavior before? Any recommendations on how to stop it? Preferably from the server with code of some sort... Thanks in advance. Matt Hi Matt, Have you tried to put this two lines in the HEAD section of your HTML pages : META http-equiv=Cache-Control content=no-cache META http-equiv=Pragma content=no-cache Hope it helps you. BR -- 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
[PHP] Same Page, Fundamentally Different Behavior OR is Firefox broken?
I'm at a complete loss... So I'm hoping someone can point me in the right direction to even start looking. We have an application written in PHP that lets users send out emails. The basic process is as follows. 1. Go to start screen. (This resets anything currently in process for the current logged in user) 2. Upload email addresses and other info (Names, etc) 3. Build Email 4. Send In Step 3 the user can click a Live Preview button to see what the email will look like with the merged data. Here's the problem, this works fine in all versions of IE, versions 1.5 or less of FireFox and versions 3 or less of Safari. However, starting in FireFox 2, and now Safari 4, when you get to step four OR click the live preview button in step three there is no more data in the merge. In those browsers the system is acting like the end user went BACK to the start page (in another window?) and reinitialized all the data. I immediately thought it might be pre-fetching so I tried using the system before and after toggling the network.prefetch-next setting in about:config with FireFox 2.0.0.20 and restarting the browser. No luck. So I added code to my reset function to email me the output of phpinfo() when the reset function is called. Using IE I get 1 notification. Using FF I get two notifications. This reinforces my theory that FireFox is prefetching the menu item to start a new mailing (just an a link...) from the top of the composer page. Even still... I've disabled prefetch so it SHOULDN'T even be considering those links right? I've also tried adding artificial ?now=timestamp fakes to the end of all menu links since I read somewhere (don't remember where) that FireFox only prefetches pages with no query section in the address. Has anyone run into this behavior before? Any recommendations on how to stop it? Preferably from the server with code of some sort... Thanks in advance. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Software to read/write Excel to CD?
Ashley Sheridan wrote: Paul M Foster wrote: On Thu, May 14, 2009 at 03:22:12PM -0500, Skip Evans wrote: One of the things the other company said was possible, and I'm not familiar with... if I understand correctly, is to create a CD with not just an Excel spreadsheet, but software on that CD that when placed in another computer will open the spreadsheet, allow it to be modified and rewritten back to the CD. It has to be a CD-RW, the CD-RW has to be in UDF format, and the host machine has to be able to read and rewrite CD-RWs in UDF. This is actually not that tough to arrange--it just has nothing to do with PHP. 'DozeXP should be able to do this, and Linux will do this if the right kernel options are on. Don't know about OS X. Second, include some other program which would do the same thing. Good luck with that. OOO Calc, which should be just fine for basic tasks and is Free. And now the kicker-- write the spreadsheet back to CD. Okay, maybe, if it's a CD-RW. But who's going to pay attention to that little detail? And as far as I know, writing to a CD is far more complicated than writing to a hard drive. You can't overwrite data on a CD-RW. UDF, which has been a standard for quite some time, allows this. The main thing you lose is some space on the CD-RW. I've never heard of anything like that, there are so many unknown variables that I would really feel for the poor team who had to take that project on! It sounds like whoever defined the requirements was trying to solve a problem in the wrong way. Why drag physical media into this when you have the Net available? And if the clients don't have the Net available, *why not*? -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Boolean Parameter to 3 Options?
I have a function that currently takes a boolean value as a parameter. But now I want to expand it to 3 options... So if I have... function doFooBar($doFoo = false) { if($doFoo) { echo Did Foo; } else { echo Did Bar; } } Is it as simple as changing it like follows to avoid having to change existing code that won't use the new values. function doFooBar($doFoo = 0) { if($doFoo == 2) { echo Did Baz; } else if($doFoo == 1) { echo Did Foo; } else { echo Did Bar; } } Something about that disturbs me. Perhaps because any time I think Oh it will be as simple as... it usually isn't. Thanks in advance! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean Parameter to 3 Options?
On Wed, Apr 29, 2009 at 1:30 PM, Shawn McKenzie nos...@mckenzies.net wrote: Philip Thompson wrote: On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote: I have a function that currently takes a boolean value as a parameter. But now I want to expand it to 3 options... So if I have... function doFooBar($doFoo = false) { if($doFoo) { echo Did Foo; } else { echo Did Bar; } } Is it as simple as changing it like follows to avoid having to change existing code that won't use the new values. function doFooBar($doFoo = 0) { if($doFoo == 2) { echo Did Baz; } else if($doFoo == 1) { echo Did Foo; } else { echo Did Bar; } } Something about that disturbs me. Perhaps because any time I think Oh it will be as simple as... it usually isn't. Thanks in advance! Matt Unless you're doing a strict comparison (===), it probably won't make a lot of difference. However, if you sent true to the function, I believe it will reach the last else condition. You may revisit all the locations you call it and update them appropriately. Those are my initial thoughts ~Philip No, true will match the first condition. If you're using true and false now and just want to add a second option then continue using true/false. Don't mix and match. 1 == true and 2 == true. function doFooBar($doFoo = false) { if($doFoo === 2) { //something } elseif($doFoo === true) { //something true } elseif($doFoo === false) { //something false } } Ah. I somehow missed the direction of the typecasting. Not that the documentation isn't completely explicit on the matter but for some reason I was thinking that the bool got cast to 1 or 0... not that the string/number got cast to a bool (following the standards there). Good to know. Thanks Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Connecting to dBase using ODBC on Mac OS X
I know this isn't exactly what you were probably looking for but... If you have a Windows machine available I would recommend taking a look at the ODBTP project at http://odbtp.sourceforge.net. ODBTP stands for Open DataBase Transport Protocol. The short version is that you add a client module to PHP which allows you to connect to a server on the windows machine. Using this client/server you can connect to any ODBC source on the windows machine from the Mac. I know it's not perfect (since you need Windows running) but we've used it to add Web acessibility to a legacy VFP app with some success. Caveat: These are, all things considered, relatively small installations. By small I mean 5-100 users per intranet accessing 100-20,000 customer records. I could not imagine using this solution for any major, publicly accessible web site. (We have one client that tracks 300,000+ records and performance is NOTICABLY slow) Pro: Allows you to access any odbc compliant database from any web server that you can compile the client for. Con: Requires Windows (works reasonably well with a Parallels installation though...) Only as stable as the underlying ODBC driver (the VFP driver is single threaded and locks up after a while... but restarting the ODBTP service frees it all up.) Overall: Good for transitioning from a Legacy application or for infrequent tasks like importing from windows only file formats (like VFP). We've used this in several installations where the client doesn't want to lose their legacy app, refuses to upgrade and wants to provide web access to sales people on the road. We've seen the best performance using PHP under IIS on Windows connecting to the same machine. Our worst case for performance is an installation that uses a Mac OSX 10.4 XServe Web Server connecting to a Windows 2003 Server which then accesses VFP data files on a Novell Server of some flavor. (From that client I learned that apparently Windows ALWAYS tries the Microsoft network file redirectors before it will try any available Novell network file redirectors. At least that's what the Client's IT department tells me whenever we relay user complaints about the speed at that site) Hope this helps. Matt On Thu, Apr 9, 2009 at 10:53 AM, Rahul S. Johari sleepwal...@rahulsjohari.com wrote: Ave, Does anyone have any knowledge on connecting a FoxPro table (.dbf, dbase) using ODBC on a Mac OS X? I've been googling but not much is turning up. Some information is available on ODBC Connections using PHP ... very little on Mac OS X ... and absolutely none to do with a FoxPro dBase table. Thanks. --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On Tue, Mar 24, 2009 at 9:15 AM, Per Jessen p...@computer.org wrote: TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. I can't tell you how many times I've had data that contained and got all kinds of screwed up when data disapeared when really the browser was just turning it into an HTML tag. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading from a COM port in Windows blows up
I just recently got a new Onkyo TX-SR706 Audio Receiver that has an RS232 interface and I thought... cool... Build a Web Interface so I can control it from several rooms away. The code below works using PHP 5.2.8 under Apache (XAMPP) on Windows XP to change the current input of my Audio Receiver. So I know at least one way communication works. If I swap out !1SLI01 (SeLect Input 01) for !1SLIQSTN which should query the current input and uncomment the lines that are commented out below COM1 Replied. That PHP session and the COM Port itself lock up until I reboot the machine. Being able to query the device would be nice... but isn't strictly necessary... So I just want to make sure I'm not doing something crazy / wrong. -- $Set_Mode = MODE COM1: BAUD=9600 PARITY=N DATA=8 STOP=1 DTR=OFF RTS=OFF; exec($Set_Mode, $Output, $Result); echo pre.implode(\n,$Output)./pre; echo brbr; switch($Result) { case 0: echo COM1 Configuredbr; $BadConfig = false; break; default:echo COM1 not configuredbr; $BadConfig = true; break; } if(!$BadConfig) { $ComPort = fopen(COM1, wb+); if(!$ComPort) { echo COM1 not openedbr; } else { echo COM1 Openedbr; $Command = !1SLI01\n; $result = fwrite($ComPort,$Command); if(!$result) { echo COM1 Errorbr; } else { echo COM1 Replied:br; // $Buffer = fgets($ComPort,1024); // while(trim($Buffer) != ) // { // echo $Buffer.br; // $Buffer = fgets($ComPort,1024); // } } if(fclose($ComPort)) { echo COM1 Closedbr; } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sanitizing Numbers
I'm trying to sanitize some numeric data that's coming to us from another system which I have no control over where all fields are character fields with no formatting from the end user so data is a mishmash of clean and mixed types of dirty. I know I can use intval and floatval to sanitize if the numeric data is at the front of the string but what about when it's not? For example, Jersey Number = #45 or Dues = $1,234.56 I see in the comments at php.net for floatval a lot of very complex solutions... am I missing something about the following that wouldn't cover me? ?php $output = floatval(ereg_replace([^-0-9\.],,$input)); ? I'm willing to assuming only US formatted numbers... and knowing that if they put in 45/46 for jersey it would come out 4546 (but I might put in additional code for that specific case on that specific field...). I'm also looking for something that I can generically apply to any numeric field. Thanks for your collective guidance. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function_exists question
Is there a way to check not only if a function exists, but also to check that the number and types of parameters desired match a function definition? The reason being that additional options have been added in php 4 and 5 to various standard function calls, but I'm still running a php3 and php4 server in addition to a php5 server. I would like to make sure that certain extended function calls still work in all versions (or I'll perform the tasks manually, albeit less efficiently). One example I can think of is the round() function. The $precision parameter was added in php4, so will not work in php3. However, function_exists would return TRUE for both 3 and 4, but round itself would fail if I tried to send a precision level to the php3 server. Thanks much, Matt P.S. Of course the modified function_exists would unfortunately have to be a recognized function/method in php3 in order for me to call it to check parameter counts on a php3 server :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Accessing mysql_fetch_object with variable names
I have been thumped with the clue bat and now have a solution. Thanks for your time! -- Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP job available, Phoenix, AZ, USA
I just saw this. If someone is in the Phoenix, AZ, USA area and wants a job writing/maintaining PHP code, this may be right for you. Contact details below: --- azcentral.com, Arizona's leading online source for up to date news and information, is seeking a Senior Online Developer to join our highly successful team! On a day to day basis, this individual will be responsible for providing Web-based technology solutions that support the objectives and mission of azcentral.com, a Gannett property. Participates in the creation and ongoing support of software applications, tools and technologies to enhance the development and growth of Digital Media services running in a Linux, Apache, MySQL, and PHP environment. Participates in cross-functional and/or cross-unit IT projects. Works in a team environment to ensure customer's needs are met. Works as the customer's primary contact for specific applications. Specific Requirements: To be qualified for this position the ideal candidate will have two years experience in online development or publishing, with an emphasis on coding, troubleshooting, and supporting a Linux Apache environment. Advanced or expert level Linux/Apache/MySQL/PHP. Must have experience in the development and support of a heavily trafficked, load balanced web environment, and basic HTML/CSS and web/interface design experience. Familiarity with commercial online services. Basic understanding of networking and systems infrastructure concepts. Strong communications and teamwork skills will be critical. Contact: jim.lindsey[AT]azcentral[DOT]com with a resume. - ...I don't really know any more than what's posted above, but will try to answer any questions if you send me an e-mail *off-list*. Hope this helps, -- For every complex problem, there is a solution that is simple, neat, and wrong. My blog: http://crow202.org/wordpress/ Matt G|There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] rfc822_write_address() / CVE-2008-2829 problem
Hello, list. A few days ago, a security scan said that our machines that were running PHP had potential vulnerability CVE-2008-2829 , a buffer overflow in rfc822_write_address(). Discussions about this are relatively easy to find with Google, but check out http://bugs.php.net/bug.php?id=42862 for a reasonable discussion and an (unofficial) patch. I'm just curious as to what other PHP users are doing about the problem, since Redhat says meh even though the company doing the security scan says OMG PANIC!!1! Let me know what you guys think. Thanks, -- The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: rfc822_write_address() / CVE-2008-2829 problem
From: M. Sokolewicz [EMAIL PROTECTED] Matt Graham wrote: PHP had potential vulnerability CVE-2008-2829 http://bugs.php.net/bug.php?id=42862 for a reasonable discussion and an (unofficial) patch. I'm just curious as to what other PHP users are doing about the problem, since Redhat says meh even though the company doing the security scan says OMG PANIC!!1! it's doesn't look that dangerous to me, I'd personally rather side with Redhat in their meh than with the security-scan-company's OMG PANIC!!1!. This is what I thought. However, they would rather believe the security scan company for some reason. If you want the patch to appear in the next version of PHP (5.2.3), make some noise about it on the internals list. ? I thought they were up to 5.2.6 it hasn't been applied until one of the devs gets so annoyed with you spamming him with it that he'll either apply it (thus getting it into the next release) or tell you what's wrong with it so you'll finally leave him alone. A simple solution :) Yep. I prefer to avoid annoying and spamming developers, though :-] P.S. note: the potential vulnerability only occurs if you actually use the imap functions. If you don't: don't worry, you're still safe. Aye. However, I mangled the source and compiled a version of PHP 5.2.6 such that the IMAP stuff wasn't even compiled, then installed that mangled version on a test box. The security scan company then scanned that test box, and said, Problem CVE-2008-2829 still exists. I do wonder what they're doing when they're scanning -- The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execute command line as a different user
My PHP is running as a user with limited rights. I'd like to execute a command line as a different user. I'm trying to delete a file and the PHP user doesn't have access to do this. I know the username and password for the admin user that has rights to delete a file. Is there a command I can use to make PHP run a delete command as the admin user? If so, how can I do this? Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Execute command line as a different user
Okay, I'll have to look into that. I have very limited knowledge with shell scripts. You wouldn't have an example of one that can do what I need do you? Thanks, Matt Shawn McKenzie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Matt palermo wrote: My PHP is running as a user with limited rights. I'd like to execute a command line as a different user. I'm trying to delete a file and the PHP user doesn't have access to do this. I know the username and password for the admin user that has rights to delete a file. Is there a command I can use to make PHP run a delete command as the admin user? If so, how can I do this? Thanks, Matt There are several ways on *nix systems. I would probably write a shell script to do the deletions and setuid of the script to root or a user with rights to delete the files. Then just exec() the shell script. On winbloze you can use the runas command. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Execute command line as a different user
I'm using the following command and I'm not getting any feedback: exec(echo 'adminPass' | sudo -u adminAccount -S whoami, $f, $r); Both $f and $r don't contain any data. This leads me to believe that the command is not being run for whatever reason. Is there something wrong with this command? Is there a different way to do it? Thanks, Matt Matt palermo [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] My PHP is running as a user with limited rights. I'd like to execute a command line as a different user. I'm trying to delete a file and the PHP user doesn't have access to do this. I know the username and password for the admin user that has rights to delete a file. Is there a command I can use to make PHP run a delete command as the admin user? If so, how can I do this? Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Recursion... Sort of...
Wow! Thanks guys! Here's what I ended up doing... To get... Black on White - 1 White on Black - 2 Black on White - 3 Black on White - 3 White on Black - 2 Black on White - 3 I had to do something like... function doStuff() { static $callCount = 0; $callCount++; if($callCount%2) { echo 'white on black - '.$callCount; } else { echo 'black on white - '.$callCount; } // Stuff that uses the depth count $callCount--; } If I didn't put in the $callCount--; I ended up with something like this... Black on White - 1 White on Black - 2 Black on White - 3 White on Black - 4 Black on White - 5 White on Black - 6 I saw where it was said that oh he said it wasn't recursive... Sorry I wasn't clearer. In my mind a true recursive function is a function that operates on it's own output like a factorial... Not just a function that is called inside itself. This got me where I needed to be and it is GREATLY appreciated! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Recursion... Sort of...
Is there a way to tell if a function has been called that has resulted in a call to the same function? We have an in-house CRM app that has a function that draws a tabbed panel on a screen... BUT if there are sub-sub-tabbed panels we want to invert the tab colors and panel colors... So... DrawSubTab($Set) - Black on White Content DrawSubTab($Set) - White on Black Content DrawSubTab($Set) - Black on White Content DrawSubTab($Set) - Black on White Content Etc... I suppose I could rewrite EVERY call to the function with a recursion count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE commit... whereas if the function can determine itself... All that said I can't think of a good way to do it without a bastardized global variable that track how deep we are and there is something that bothers me about that approach... Unless that really is the easiest way. Thanks in advance! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ldap_search results limited
Thanks for the tips. phpLDAPAdmin was hanging while trying to authenticate, but I'll give it a try again later. Nathan: splitting up the search; I hadn't considered this! It is working nicely for the time being, thanks. - MB On Wed, May 7, 2008 at 3:23 PM, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] I am running into a problem with my queries returning a limited number of result entries. [/snip] Most LDAP servers set a limit, it is usually not a PHP problem. One way to solve is to query by first letter of last name and throw into an array (iterating through the alphabet). function ldapUserList($username, $password, $ip=127.0.0.1){ $arrLetters = array(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z); /* connect to AD server */ if(!$ds=ldap_connect($ip)){ echo did not connect...please contact system administrator or go back to try again; } /* set LDAP option */ $un = domain\\.$username; $upw = $password; ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ds, LDAP_OPT_REFERRALS, 0); ldap_set_option($ds, LDAP_OPT_SIZELIMIT, 0); /* bind to AD server */ if(!$r=ldap_bind($ds, $un, $upw)){ echo 'You are not authorized and or, your login information was incorrectbr /'; echo $un.: .$upw.br /\n; } else { $userArray = array(); foreach($arrLetters as $letter){ /* * search AD for users with surnames (sn), valid e-mail addresses (mail) * and make sure that they are valid (msExchHideFromAddessLists) */ $sr= @ldap_search($ds, dc=domain, dc=local, (((sn=.$letter.*)([EMAIL PROTECTED]))(!(msExchHideFromAddressLists= TRUE; $info = ldap_get_entries($ds, $sr); if(0 != count($info)){ /* place all valid entries into a usable array */ for ($i=0; $icount($info); $i++) { /* make sure the item being pushed into the array is not empty */ if('' != $info[$i][mailnickname][0]){ //array_push($userArray, $info[$i][mailnickname][0] . +.$info[$i][cn][0] . +.$info[$i][mail][0]); $fullname = $info[$i][cn][0]; $arrFN = explode( ,$fullname); $fullname = $arrFN[1]., .$arrFN[0]; $readname = $arrFN[0]. .$arrFN[1]; $tusername = strtolower($info[$i][samaccountname][0]); $tempArray = array(username=$tusername, fullname=$fullname, readname=$readname); array_push($userArray, $tempArray); } } } } } /* sort the user array alphabetically and re-align numeric key */ array_multisort($userArray[1], SORT_ASC, SORT_STRING); return $userArray; } $userArray = ldapUserList($_SESSION['user'], $_SESSION['password'], 127.0.0.1); Sorry about the funky line breaks
[PHP] TLS transport for Windows
Hi all, I'm looking for a PHP environment for Windows (like XAMPP), that already has TLS transport built-in. Would anyone know of something like it? If not, any pointers on how to get TLS transport for a PHP Windows environment? Thanks, Matt -- Stand before it and there is no beginning. Follow it and there is no end. Stay with the ancient Tao, Move with the present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which PHP-Editor to use?
Does Eclipse already have word-wrap? To my disappointment, it was still lacking that basic functionality the last time I tried it. On 8/3/07, Nathan Nobbe [EMAIL PROTECTED] wrote: eclipse with php eclipse, but i may be switching to eclipse pdt once it becomes stable if there is no support for xdebug in php eclipse when it does. -nathan On 8/2/07, Merlin [EMAIL PROTECTED] wrote: Hi there, I have worked now for several years happily with homesite 4.5, but now it looks like I have to switch to another system as homesite will not run without admin rights on a XP machine. What editors do you use? Do you have any recomendations on a special one? I have looked into eclipse, but I would hear from your experience which one would you recommend me to switch to? Thank you for any comment. Best regards, Merlin -- Stand before it and there is no beginning. Follow it and there is no end. Stay with the ancient Tao, Move with the present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which PHP-Editor to use?
On 10/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: 2007/10/18, Matt Arnilo S. Baluyos (Mailing Lists) [EMAIL PROTECTED]: Does Eclipse already have word-wrap? To my disappointment, it was still lacking that basic functionality the last time I tried it. PHP Eclipse's auto format code? Hmmm. Not so sure if that's the name they use for such feature. But something that does basic word-wrapping for Eclipse. -- Stand before it and there is no beginning. Follow it and there is no end. Stay with the ancient Tao, Move with the present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which PHP-Editor to use?
That is why I believe in a disposable system I have 2 main computers, one running XP and the other running Ubuntu Linux. I make regular backups to secure server online via FTP and regularly burn backups to CD. At any time if I got a virus that was by some (small) chance powerful enough to cause damage to my PC that could not easily be cleaned up - I would simply reformat the HD and reinstall the OS ;) (and that process of reformatting and reinstalling takes a mere 30 minutes to 2 hours - latter being the Windows and former being Ubuntu) -Matt On 10/16/07, Bastien Koert [EMAIL PROTECTED] wrote: In the same boat here...waiting for a guinea pig to ok it Bastien Date: Tue, 16 Oct 2007 08:56:16 -0500 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: Re: [PHP] Which PHP-Editor to use? On 10/16/07, Stut [EMAIL PROTECTED] wrote: Zoltán Németh wrote: 2007. 10. 16, kedd keltezéssel 04.59-kormooor ezt írta: I recommed you Codelobster php edition. Very good free php editor. It reminds me a mix of Zend Studio and MS Visual Studio. If to the basic features they are: syntax highlighting, an intelligent outocomplete, step by step debugger, help on php, html, mysql; jump to funtion's or class's declaration in the project; search within the project; highlighting of paired tags and brackets; Calss View. I like that it has small size - only 5 mb. Free. I've downloaded from: http://www.codelobster.com Good luck! wow I haven't seen that thread for several weeks. this is really thread resurrection lol :) anyway, this thread has been talked to death a million times, so we could just let it drop finally (I thought we already did it...) ;) Nahh. I wanna hear more about the Drug and Drop function for loading a new file. Cause everyone knows that for best results you've gotta drug files before you drop them into an application. http://www.codelobster.com/details_phped.html (end of page) -Stut Outta curiosity... is this a legit piece of software? I went to the site and it *looks* real but we all know how looks can be. =P I wasn't interested in downloading a virus this morning. any takers? =D ~Philip _ Express yourself with free Messenger emoticons. Get them today! http://www.freemessengeremoticons.ca/?icid=EMENCA122 -- -Matt Livingston
[PHP] Two MySQL instances in one server
Hi all, Would it be possible to have two MySQL instances running on one server (each having different ports) and then have only one running Apache server with PHP? I have tried this once but PHP can only connect to one MySQL server because it can only read one socket file at a time. As much as possible, I would prefer a purely mod_php solution as opposed to one that would have PHP running on CGI. Thanks in advance, Matt -- Stand before it and there is no beginning. Follow it and there is no end. Stay with the ancient Tao, Move with the present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using PHP to determine if user has Java installed
Hey List, I want to know if it is possible to use PHP to find out if a visitor has Java Runtime Environment installed on a computer. Is there a way to use PHP to find this similiar to how PHP can be used to find out browser info? Thanks in advance for your help. -- -Matt Livingston
Re: [PHP] Using PHP to determine if user has Java installed
Thanks, http://www.php.net/manual/en/ref.java.php has the information I needed. The purpose of this script is on a website I will be managing we distribute software written in Java, so when they go to download the software I thought it would be a nice touch to alert them if they do not have JRE installed and provide a link to the Java site where they can download it. Thanks again all! -Matt On 9/5/07, David Powers [EMAIL PROTECTED] wrote: tedd wrote: At 3:17 PM -0600 9/5/07, Matt Livingston wrote: I want to know if it is possible to use PHP to find out if a visitor has Java Runtime Environment installed on a computer. But you can attempt to run a js script from php to see if javascript is enabled. Java Runtime Environment == Java JavaScript != Java There is a PECL extension for Java, allows you to get the version of Java installed. I have never used it, but details are here: http://www.php.net/manual/en/ref.java.php -- David Powers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Matt Livingston
[PHP] ORM framework suggestion
Hello All, I'm thinking of using an ORM framework for a new project. From my research, I've found Propel and Doctrine (of course, there might be others). Would anyone suggest what ORM framework they're using right now? I am experienced with OOP and am just looking for a framework to speed things up. I can perhaps test-drive both frameworks above and see what works better for me but maybe there are users here who's have had experience with either one (or better, both). Regards, Matt -- Stand before it and there is no beginning. Follow it and there is no end. Stay with the ancient Tao, Move with the present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] compose html body with variables
Hello, I'm trying to compose the body of an html email to use with the mail() function. I'm running into problem because I'm not sure how to quote the multi-line body. Here is what I have: $body = echo Hello, here is your quote from Freight Services.br /br /; echo Shipping from: tab $origin to $destinationbr /; echo br; echo Shipping subtotal $ . number_format($subtotal,2); echo br; echo br; echo Freight charges $ . number_format($freightCharges,2); echo br; echo Fuel surcharge $ . number_format($fuelSurcharge,2); echo br; echo Pickup and delivery $ . number_format($pickupDelivery,2); echo br; echo br; echo Miscellaneus costs (e.g. liftgates, etc.) below $ . number_format($miscCost,2); echo br; echo br; if ($liftgatePickup == 50){ echo Adding liftgate on pickup $50.00; echo br; } if ($liftgateDelivery == 50){ echo Adding liftgate on delivery $50.00; echo br; } if ($spectimeDelivery == 35){ echo Adding cost of specific-time delivery $35.00; echo br; } if ($conventionDelivery == 35){ echo Adding cost of convention delivery $35.00; echo br; } if ($dreyageWait != 0){ echo Adding cost for wait $ . $dreyageWait; echo br; } if ($insideDelivery == 25){ echo Adding cost for inside delivery $25.00; echo br; } if ($notifyClient == 10){ echo Adding cost for client notification $10.00; echo br; } echo Total cost is $ . number_format($totalcost,2); echo br /br /; echo a href=\www.foo.net\foo Services/a; $subject = Online Freight Quote; mail($email, $subject, $body, From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: [EMAIL PROTECTED]: PHP 4.x\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=iso-8859-1\r\n); If anyone could assist me I'd appreciate it very much, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] compose html body with variables
Edward Kay wrote: -Original Message- From: Matt [mailto:[EMAIL PROTECTED] Sent: 06 August 2007 15:38 To: php-general@lists.php.net Subject: [PHP] compose html body with variables Hello, I'm trying to compose the body of an html email to use with the mail() function. I'm running into problem because I'm not sure how to quote the multi-line body. Here is what I have: $body = echo Hello, here is your quote from Freight Services.br /br /; echo Shipping from: tab $origin to $destinationbr /; echo br; echo Shipping subtotal $ . number_format($subtotal,2); echo br; echo br; echo Freight charges $ . number_format($freightCharges,2); echo br; echo Fuel surcharge $ . number_format($fuelSurcharge,2); echo br; echo Pickup and delivery $ . number_format($pickupDelivery,2); echo br; echo br; echo Miscellaneus costs (e.g. liftgates, etc.) below $ . number_format($miscCost,2); echo br; echo br; if ($liftgatePickup == 50){ echo Adding liftgate on pickup $50.00; echo br; } if ($liftgateDelivery == 50){ echo Adding liftgate on delivery $50.00; echo br; } if ($spectimeDelivery == 35){ echo Adding cost of specific-time delivery $35.00; echo br; } if ($conventionDelivery == 35){ echo Adding cost of convention delivery $35.00; echo br; } if ($dreyageWait != 0){ echo Adding cost for wait $ . $dreyageWait; echo br; } if ($insideDelivery == 25){ echo Adding cost for inside delivery $25.00; echo br; } if ($notifyClient == 10){ echo Adding cost for client notification $10.00; echo br; } echo Total cost is $ . number_format($totalcost,2); echo br /br /; echo a href=\www.foo.net\foo Services/a; $subject = Online Freight Quote; mail($email, $subject, $body, From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: [EMAIL PROTECTED]: PHP 4.x\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=iso-8859-1\r\n); If anyone could assist me I'd appreciate it very much, Matt Hi Matt, The problem here is that you're using echo statements, which output directly. Instead you need to build a string containing this output, for example: $body = Hello, here is your quote from Freight Services.br /br /; $body .= Shipping from: tab $origin to $destinationbr /; etc. Note the use of the .= operator. This is the same as saying $body = $body.'whatever'; At the end, $body will then contain the HTML body of your email which you pass to the mail function. Hope this helps, Edward Very good! Thank you so much Edward. That worked perfectly. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to implement a plugin system?
You might want to take a look at stickleback: http://sourceforge.net/projects/stickleback Documentation is very thin on the ground right now, but there's a presentation here: http://www.appulsus.com/resources/stickpres200706/img0.html mz On Mon, 6 Aug 2007, Hamza Saglam wrote: Hello Boro, Thanks for your response. However I am looking for something a bit more comprehensive :) I could do it as you suggested if I had only a few plugins. As I am going to add loads of plugins over the time, rather than adding all the plugins one by one, could something like a 'loader' class be implemented? What I mean by that is, it will take the requested plugin names (with their own parameters necessary) and load/initialise them. In semi-psuedo-code, it would be something like: foreach plugin suplied as the argument include the plugin initialise it end Perhaps I should change the question to: Do you think something like this would be efficient and useable? If not what sort of pattern would you follow? Warm regards, Hamza. Borokov Smith [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey Hamza, require_once($chosenPlugin . '.class.php'); $obj = new $chosenPlugin(); return $obj; And you can start from there. hth, boro Hamza Saglam schreef: Hello all, I am working on a project which needs to have some sort of plugins architecture and I am kinda stuck. Basically I want to give a list of items to the user, and according to his/her selection, I want to load relevant functionality into my application. I was thinking of having an abstract plugin class, and have the plugins implement that but then how would I actually load the plugins? Say for instance I want to load plugins X,Y,Z (and lets say i implemented them as [X|Y|Z].class.php) , should I just 'include' (or require) them? Or should I initialize all possible plugins and just pick the ones user has chosen (which sounds a bit pointless as it would load unnecessary stuff)? How would you go about doing something like this? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- getInstance() http://www.getinstance.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Find file version
Ya, I'm thinking it will be all exe's. I found microsoft's Filever program, but I can't get exec working properly (well, I can't get the results properly). I'm gonna keep searching, and hope I find how it determines file info. - Original Message From: Richard Lynch [EMAIL PROTECTED] To: Matt Carlson [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Friday, July 27, 2007 12:52:08 AM Subject: Re: [PHP] Find file version On Wed, July 25, 2007 12:26 am, Matt Carlson wrote: I've been recently toying with the idea of creating a php script to emulate the function of File Hippo's program checker (checks certain programs for their version, and then uploads to file hippo to compare with what it is released to show a list of available updates. I've hit a brick wall though. I know binary files have version information available, but can't find anything for php to read this. Has anyone run across something like this in the past? Anyone have any hints of where to go to start reading this info? I don't think there is any magical incantation that works for all binary files... They all store their version info in whatever portion of the file they felt like it... Unless you mean .exe files specifically, in which case it's probably always in the same place in those... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Find file version
I've been recently toying with the idea of creating a php script to emulate the function of File Hippo's program checker (checks certain programs for their version, and then uploads to file hippo to compare with what it is released to show a list of available updates. I've hit a brick wall though. I know binary files have version information available, but can't find anything for php to read this. Has anyone run across something like this in the past? Anyone have any hints of where to go to start reading this info? Thanks Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions VS MySQL
I've recently begun work on a web-based RPG game with some friends, and have recently been thinking about the best solution for loading and saving persistent variables like player life/stats and other information. I am both familiar with sessions and mysql for saving and loading variables, and that's not my question, but I am instead interested in which method would be more efficient to use. If the data is getting reloaded on each individual page, would it be more efficient on the system hosting the game to save certain numbers and variables in a session, or to reaccess the database each time it needs those numbers. My biggest concern with using sessions, is if someone were to exit the browser mid saves to the database, all information would be lost. Since it is web-based, there is no real way for me to be able to expect everyone to follow certain procedures to load/save, and I would really like to stay away from that as well, as it's not as user-friendly and intuitive as an auto-save feature. I guess my main question here is, are there ways to auto-save and guarantee data wouldn't be lost without having to load, read, write, and close a connection to mysql on each page load? I appreciate any tips, insight, thoughts, stories, or help in absolutely any fashion that I can get. Even a tip of a nature outside my question related to my project would be great. it's my first project of this kind, and I'd like to avoid any problems I can, so I'm putting a lot of forethought into it all. Also, I'm the only coder, so to have to go back and rewrite a ton of code from one save method to another is just way too much work.
Re: [PHP] Sessions VS MySQL
As far as scalability goes, there's actually a game we're referencing a lot to help us make it work at the get go called Kingdom of Loathing ( http://www.kingdomofloathing.com ). This game seems to have on average around 1,000-1,500 users on at any given time. I've noticed when visiting the page also, that is sends you to a random mirror of the site such as www2..., www3..., etc.. I'm not sure if those shows that it's directing people to various servers for the website, and that the database is possibly stored on one server by itself. This seems a bit bulky a solution for an online text/2d low res image rpg game, even with 1,000 users playing simultaneously. The point of saving only when I need to I get, and was planning to implement. Such things as exploring around the game world, and, well, that's all really, don't need to be saved as you'll start at the main location each time you log in, but other things like battle, buying/selling/upgrading items and inventory, and quest locations on the map, all need to be saved. I guess one of my bigger concerns about saving is if it would seem natural or strange to have it only save after the end of each battle, because the way the battle system is planned to work is that you attack, it loads the page, says how much dmg you did and the enemy did, then you may have to attack again, loading the page howveer many more times is needed until you die, or the enemy dies. There will be a function to run built in, but aside from that the only other way to get out is to exit the browser. It seems a bit cumbersome to have to access the db everytime an attack takes place, but at the same time the player will be limited to a number of moves per day, to make the game more fun, and help the server from dying. From what I recall, mysql database calls take only .002 seconds, or something very quick like that, so I suppose I shouldn't be too worried about the database overloading from people using it, or should I? That's really one of my main concerns. Anyways, thanks for all the help and input so far, it's greatly appreciated.