Re: [PHP] PHP connection to external application
hce wrote: Let me first describe the requirement more: The C program is a major business server I would not connect applications on low level. I would think of a web services type of interface - http request and xml response (Steven suggested, for example, SOAP - but it does not need to be that complicated). The has several benefits - a) Clearly defined, the web services gate will not be affected by changes in the C program. b) You can use the web services gate to plug not only your php application, but any other application that can (be made to) talk web services. c) The implementation of the php application, in this case, will be trivial, resulting in cheaper developers/development/maintenance/expansion. (ii) What is the maximum number concurrent requests in a PHP web application? Will the maximum socket number / or port number (up to 2^16) be a bottleneck for large number of concurrent requests (hundred and thousands)? Nobody can tell you this for your existing infrastructure. The only thing you can do is try and optimize. Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UK PHP Host/Developer Required
2. It's useful if the host company and the client keep the same office hours. If you have a hosting company with 9 to 5 office hours, you are dead, even if it is next door. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] class? package?
Shelley wrote: I am working on a sns site, and now my practice is grouping classes of a function classes of a function... perhaps classes related to certain functionality? (i. e. subscription) together. When I need it, just load the package: subscription. Right? ;) Hm... I do not know your project, but to have many classes just to handle subscription, sounds a bit too much to me. Why don't you have a class called subscription, which might even extend a class called person or user - the subscription class can have methods, for instance subscribe and unsubscribe, and because subscription extends person or user - it already knows who is the person/user. And then, for example, to subscribe a person/user, you do - $subscription-subscribe($list_id); Other possible actions - $subscription-un_subscribe($list_id); $subscription-is_subscriber($list_id); $subscription-lists(); etc. This way class subscription packs the methods needed to handle subscription related activities, so in your own jargon, this class is a package. Of course, if the subscription process is extremely complicated, you can have more classes. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF to images or something similar
Hi!. I need to create a pageflip magazine (you know, a flash magazine). My client ask me to do a little php program that convert a full pdf magazine into a pageflip magazine. My doubt is: It's possible with php to read a full pdf and make an image for each page? Thanks a lot. Ray. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UK PHP Host/Developer Required
Robin Vickery wrote: Out of hours technical support often gets billed at a punitive rate. Which is a bugger if their out of hours is your working day. It seems you haven't tried Rackspace (UK) yet. And while you might get tech support out of hours, accounts and billing usually keep normal office hours. True. But if you pay your bills on time, you will never talk to these. Iv PS I am NOT advocating that one should take hosting outside the UK. I do projects in Austria and I do have the hosting in the UK. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPMailer not working but Squirell mail works
Shiplu wrote: In my web server, I cant send mail by PHPMailer. What does this mean? Do you get an error message, etc.? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Canvas examples
Richard Heyes wrote: Does anyone have any more examples of the new canvas element they've written? FF only: http://www.phpguru.org/canvas.html This is a pretty interesting use of Canvas as well. Thanks for sharing! http://ejohn.org/blog/processingjs/ -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Canvas examples
Richard Heyes wrote: I guess the other browser doesn't do much with canvas ? Nope. Eg: canvas id=foo This gets shown on none supporting browsers, but not on supportive browsers. /canvas MSIE just shows the text and doesn't do anything with the canvas. One thing about using a canvas is bandwidth. If it's a big concern I would hazard a guess that a bar chart (for example) would cost less in terms of code required to build the image compared to JPGraph, and also less in terms of output (particularly if you were to use output compression). Another idea for dynamic graphing could be: http://solutoire.com/plotr/ It also uses the canvas element, but if you use excanvas for IE it'll work in most newer browsers. I've used it in a project to provide dynamic bar graphs from a queue so that they could see in semi-real time how many customer requests were in different queues. It was an internal app, or else I'd link it :( -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Search like php.net's URL thingy
Ryan S wrote: Thanks for replying m8, but if you check the rest of the thread you will see this has alraedy been solved and the result is http://ezee.se/ezeeurl.php?do=1 Cheers! Ryan How do you protect this thing from being spammed? I do not know why somebody would spam it, but I have had all kind of forms being spammed - it seem there are people out there who find immense pleasure in spamming forms, regardless of the result. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CAD file decoding
Lester Caine wrote: Has anybody seen any software that could be used with PHP to extract the preview pictures from CAD files such as DXF and the like. I'm looking to keep thumbnails of the drawings in much the same was as we generate thumbnails of images. So I can display a list of previews before downloading the whole file. It seems DXF files can be accessed with JavaScript. This sounds a bit peculiar to me, how big are these files? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] climb up the path
hi all, i need a way to get the path to the parent folder of the folder i am in. one dirty way i found is this - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . .. . DIRECTORY_SEPARATOR . config.php); i can also explode() and reassemble all folders except the last, but this looks also dirty... is there a direct way? iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] climb up the path
James Dempster wrote: Personally I use. ?php require_once(dirname(dirname(__FILE__)).'/config.php'); I think it's what most people do. A... very interesting, thanks. To get the path only I did this - $path = dirname(__FILE__); $parts= explode(DIRECTORY_SEPARATOR, $path); array_pop($parts); $INSTALL_PATH = implode(DIRECTORY_SEPARATOR, $parts); It's kind of long... If somebody has a better idea, I would be glad to hear. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] climb up the path
Stut wrote: $path = dirname(dirname(__FILE__)); That will get you the parent directory. -Stut A,... right! - me and my limited thinking... - dirname() gives the parent of a file AND of a directory, right. Thanks, Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] climb up the path
Jim Lucas wrote: Iv, tell me why you are wanting to do this? If it is the reason I think it is, I can give you a better way to accomplish this. I have the source and a configuration file, which I want outside the source - it is different from server to server. The easiest is to have the configuration file one folder up. In the same time I want the source to work wherever it is placed. So the source sees where it is, and climbs one directory up to read the configuration specific for this installation. I do not want to use ignore in the repository, in order to prevent the configuration file from being overwritten. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding a page with FPDF
Brian Dunning wrote: Anyone use FPDF? I'm trying to create a new document in memory, starting with a template document - I'm going to add some stuff to it. The template document might be any size and dimensions. Here is the code I'm using, and my problem is that the resulting document is always an 8.5x11 page. How do I get my new document to be the same dimensions as the template doc? $pdf= new fpdi(); $pagecount = $pdf-setSourceFile(templates/.$pdf_template_name); $tplidx = $pdf-ImportPage(1); $pdf-addPage('P'); $pdf-useTemplate($tplidx); I think you have to specify the page size when you create the $pdf variable. Here's how I've been using it: $pdf = new fpdi('P','pt','letter'); You might be able to use the FPDF_TPL::getTemplateSize() method to figure it out dynamically somehow though: http://www.setasign.de/support/manuals/fpdf-tpl/fpdf-tpl/fpdf-tpl-gettempaltesize/ It also looks like the useTemplate method might do some legwork for you, but I'd have to test... http://www.setasign.de/support/manuals/fpdf-tpl/fpdf-tpl/fpdf-tpl-usetemplate/ HTH -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Military Service WAS [PHP] Capitalization of variable
Dan Joseph wrote: I guess the main problem is people don't realize that there are a LOT of things you can do in the military other than just taking a gun out into the field and firing at the enemy. If you want people to believe that mandatory service is a good thing, they have to do more to get that message out. www.goarmy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Discussion of method -- config files
tedd wrote: Hi gang: More of a question of method rather than of right or wrong -- of the two methods mentioned here, which way would be better and why? Initially I used to access global variables using the global keyword - function foo() { global $bar; } However if the function code is a bit longer, it gets difficult to see if $bar is still actually used, after some revisions. So I switched to using $GLOBALS. Inside $GLOBALS I store variables, arrays and initiated objects (for instance $DB, for database access) - which I call - $GLOBALS[DB]-connect; I do not consider it polluting - it is there to be used. If your code is part of something bigger, then you need a convention, and if you convention supports this method, it's all right. For some reason I do not like the :: operator, it's visually too unstable :) Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] climb up the path
Jim Lucas wrote: Iv Ray wrote: Jim Lucas wrote: So, saying that it is outside the source does not tell me if it is outside the document root. A, right. It is outside the document root. Use your include_path php_ini setting A, right... Didn't think of it. Actually, I do not like the include_path - it is too esoteric... - kind of a fog - I prefer to know where things I call come from :) - as it is said in Harry Potter - Never trust an object of magic if you do not know where it keep its brains. ;) But thanks, anyway! Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] climb up the path
Richard Heyes wrote: i need a way to get the path to the parent folder of the folder i am in. one dirty way i found is this - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . .. . DIRECTORY_SEPARATOR . config.php); i can also explode() and reassemble all folders except the last, but this looks also dirty... is there a direct way? There's nothing dirty about dirname(), and for your issue, just call it twice: dirname(dirname(__FILE__)); I called dirty the .. in my example. Yes, dirname(dirname(__FILE__)); is the way to go - I was just too brainwashed and did not think I can apply it to a directory, too. Thanks, Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Military Service WAS [PHP] Capitalization of variable
Per Jessen wrote: Call me .. uh no, I'm getting sick ... you guys are so completely and utterly off-topic - please take it off-line. It was obviously off-topic from the beginning,... however it felt somehow OK... - I mean, it gave the list a personal touch and every successful organization dreams of its people having a more personal touch. I'd also hate it if the list goes greatly off-topic inflated, but, I think, I'd hate it exactly as much if it was a dry on-topic thing where nobody says anything personal. If we were not so divided in time and space, we would occasionally meet for a beer - for me the off-topic explosions are the digital equivalent of this. Iv -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] http response 200
joaquinbordado wrote: 'm a total newbie..i just want to know how can i display an http response 200 Don't have time to customize it for you, but that's how it can be done- header(HTTP/1.0 404 Not Found); /* * * I copied the DOCTYPE from what Apache 1.3.34 returns. * */ echo !DOCTYPE HTML PUBLIC \-//IETF//DTD HTML 2.0//EN\; echo html; echo head; echo title404 Not Found/title; echo /head; echo body; echo h1Not Found/h1; echo pThe requested URL . $_SERVER['REQUEST_URL'] . was not found on this server./p; echo hr; Note, that you must not have any output before sending header(). There is a way to check, write back, if interested how. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] http response 200
ryan gacusana wrote: here is my code when accessing this url http://localhost/podcast/podcast.php?mobile=0823172message=2343443=%3Eryan This runs on your computer, I can't access it. else echo Message has been sent successfully.; // in this part i want to respond with a status of 200,sorry i just started php last wik Actually... If you print this text, the web server sends status 200 to the browser on its own accord. Or am I missing something. The code I sent you sends custom 404 Not Found - in case you need that. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] download file from an ajax request
pere roca wrote: hi everybody! Hi! is there some way to allow downloading a PHP generated file from an ajax request? No idea, but would love to hear if/how you solved it. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF inline viewer
Mário Gamito wrote: Hi, Does someone knows of a PHP software that is an inline PDF reader ? You can view the idea here: http://www.scribd.com/doc/2025925/Clinical-chemistry-II-Biomedical-Science-practical-1 Any help would be appreciated. Warm Regards, Mário Gamito What will happen if you open the PDF file in iframe? - then you will have all controls from the Acrobat Reader plug-in. Or do you need something more elaborate? Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] download file from an ajax request
Eric Butera wrote: The only thing I can think of is using JS to create some sort of IFRAME, meta redirect, window.location, or a popup window, something that will force the page to hit your download script directly. I've never attempted it myself so I'm not sure what sort of issues IE would have with any of the above. Well, if we, the illiterate, are going to brainstorm ;) - clicking a link/button/image executes JavaScript function, which (via AJAX request) hits the php download script. The response will be received by the AJAX object. Nothing php here. As far as I see the problem, it is - how to pass this response to the browser in an elegant way, so that the browser will open a Save as... dialogue and will direct the stream there. One could ask this on a JavaScript/AJAX list. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Discussion of method -- config files
Al wrote: I freely use defined constants for all fixed variables in my config file. It insures they cannot be inadvertently reassigned by a function someplace and are available everywhere. That's a good idea, I have been thinking about this. Never thought they have global scope, though - a good reminder. define('MYSQL_HOST',localhost); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another canvas example
Richard Heyes wrote: Hi, Latest in my new series of look at me, aren't I cool canvas examples is here: http://www.phpguru.org/pie/pie.html Works in IE7 too. And Opera. Ooh. Awesome stuff. I think the canvas element will be my next adventure. I've been learning JavaScript a lot recently. That's been an interesting experience that I'm glad I did. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another canvas example
Richard Heyes wrote: Pretty sweet! My only problem with it is that I had to use the keyboard to get to the Attach button, since I couldn't click on it with it being behind the pie chart in the page's Z-order. Yes, no way around (I think). Even with the buttons z-index set to 99 it still shows up behind the beachball. TAB and the spacebar are your friends I guess... :-) You could make the z-index of the beachball at 1, and then put the rest of the page in a div with a z-index higher than 1. The beachball should then still appear, but be under the div, which allows you to click the button. I ran into the same issue with a game I've been making: http://www.primateapplications.com/trackattack/ Since you're working with the Canvas, you can be reasonably sure that the browser would support doing this. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another canvas example
Richard Heyes wrote: Pretty sweet! My only problem with it is that I had to use the keyboard to get to the Attach button, since I couldn't click on it with it being behind the pie chart in the page's Z-order. Yes, no way around (I think). Even with the buttons z-index set to 99 it still shows up behind the beachball. TAB and the spacebar are your friends I guess... :-) Oh, I forgot to mention that you'll have to make the css position attribute relative. Then the z-index will work. I think that's what I had to do for the same issue. * * I had to get up in the middle of the night to check some production issues and checked my email while waiting. My memory might not be fully functioning :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Another canvas example
Per Jessen wrote: Colin Guthrie wrote: http://www.primateapplications.com/trackattack/ Since you're working with the Canvas, you can be reasonably sure that the browser would support doing this. Dude, that's cool it's killed my productivity, but it's cool :D The Playmobil website has a very similar one, except it's water-pipes and Flash. /Per Jessen, Zürich My son likes trains, and I was using this as an excuse to learn JavaScript better. My wife's favorite NES game (yes, I collect NES games) was/is Pipe Dream, so I modeled it after that game. It uses Soundmanager2 to play the music and sounds through Flash. All the code is inline, just to make it easier for people to view the code. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another canvas example
Daniel Brown wrote: On Tue, Jun 24, 2008 at 3:53 AM, Ray Hauge [EMAIL PROTECTED] wrote: http://www.primateapplications.com/trackattack/ Ray, This displays perfectly fine, but does not function beyond looking pretty on Firefox 3 (Linux/KDE). I am, however, probably going to play that game for a bit on my non-Linux (I refuse to say the name!) machine. Maybe Rich could turn his canvas example into the first HTML/CSS/JavaScript beach volleyball game. It would be the closest some of us would probably get to detaching from our desks and getting onto a beach to play anyway. Strange, I've tested it on Kubuntu Hardy FF 3, SuSE SLED 10.1 FF2, Windows FF23 Safari Opera 9.5 IE67, Mac OSX Safari. I'd be interested in what error you got, just email me off-list if you like. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert PDF Files to PCL-Files
jogisarge wrote: Hello @all, i am running php5 on a IBM i5 V5R4. now i have to print exisiting pdf-files. the problem is, i cant use external programms like pdftops or other stuff like this, because the php core runs in the pase environment. is there any possibility to convert existing pdfs to pcl files ? bye jo I don't know if IBM has a port of the linux command pdf2ps (to post script). There should be some sort of converter from post script to PCL, but I'm not completely sure on that. I'm not currently aware of a straight converter. Sorry if that's not much of a help. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What font/size do you use for programming?
tedd wrote: Hi gang: I'm running a Mac (so I know mine is a bit different size wise) but I'm currently using Veranda at 14 point for coding. Just out of curiosity, what font and size do you ppls use for your programming? Cheers, tedd 12pt Adobe Sans MM (Zend Studio) on a 19 LCD @ 1280x1024 running Linux. I'm not doing PHP at my new job anymore (bummer), but the terminal I use to connect to the OpenVMS server uses auto font scaling to make it super huge (the programs only support 80 and 132 character screen widths). BTW, MUMPS is a very interesting language. By interesting I really mean crazy, but I suppose it is really old. F I=1:1:10 W VALUE: _I,! ; Writes VALUE: . I each on a new line Sorry for venturing off-topic, but I told you! -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Platform
Stut wrote: On 9 Sep 2008, at 18:52, Nathan Rixham wrote: Short and sweet; does anybody have any practical experience; thoughts or case studies in regards to implementing the Zend Platform. Yeah, I used it in my previous job a coupla years ago. It looks great, the marketing hype is well executed but as usual the reality is far from the promise. There are some aspects I really like, but mainly in concept. What you actually get is expensive extra bloat to install on your servers. * The bytecode cache can be replaced by one of several free solutions out there. * The job queue is a great idea but the implementation is problematic at best. Avoid this if you can. * The centralised logging and the alerting features are nice - this is probably the only but I really found useful. * The clustering features I did not use so didn't look at too closely, but it didn't appear to offer anything that couldn't be replicated pretty easily with open source tools. At the end of the day what you're buying is marketing hype, and there are people out there who fall for it hook line and sinker. My advice is that unless you have someone insisting you use ZP, don't. And even if you do I urge you to look at what you actually need from it and evaluate alternatives before making a commitment. Have you ever heard about Facebook, Yahoo or any other big player using it? Don't get me wrong, I think Zend is a great company, but I just don't see the value in ZP. For the price of the license you could add another server which will give you far better ROI and higher capacity then ZP could ever achieve. And don't get me started on what they've done to Zend Studio. I've switched to Aptana - same platform, but cheaper and a lot more stable. Shame! -Stut I agree with most of your post. The error logging features are great. I haven't used ZP for a while, but when I did it was nice to get an alert right away of what happened, and it also captured the variables in use at the time so that you could see why it happened. If the error reporting is what you're looking for, then the bytecode caching is a nice addition, but like you said there are OSS alternatives. I also completely agree with the Zend Studio comment. I've switched back to Zend Studio 5.5, because the Eclipse version was just so unintuitive... especially for debugging. -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Robert Cummings
Daniel Brown wrote: All: What was pointed as a passing mention in one thread I thought was worth note in a thread of its own. As quoted by Rob: BTW, while we're off topic... my wife delivered our third child (second boy) 3 minutes after midnight yesterday :) I'd say that deserves a round of congratulations. Many - most, probably - of you know Rob from here, and have seen his help and dedication - as well as his annoying wit ;-P - offered to any and all on this list. Quite often, it's offered when you don't especially want it. Nonetheless, it's great news, and I think we should all take a moment and wonder: why the hell aren't you at the hospital with your wife and newborn son, Rob? ;-P Congrats to the Cummings family! Oh wow, congrats Rob! We just had our second (and last after my surgery) 5 months ago. Enjoy the lack of sleep :) -- Ray Hauge www.primateapplications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CLI utility
Indeed i am looking for a tool to write my code with on a box that has no gui environment, However if a Jihad is going to ensue because of it, i shall withdraw my question, head bowed. RTC Kevin Kinsey wrote: John Nichel wrote: Ray Cantwell wrote: Hello again, I was wondering if any of you knew of a good command line utility for php5 on linux? The box i write on has no X-windows. Ray. A command line utility to do what? Indeed. Context might even indicate he's looking for something to use to write his PHP scripts on a box with no GUI. In which case, the question is better avoided as it's a terribly effective magnet for holy war. Furthermore, I didn't choose the .sig below, it's randomly generated by fortune(6), but it really speaks to me, heh KDK PS. ed(1) is the standa nah. ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
On Monday 06 March 2006 07:56, tedd wrote: So, I'm still trying to find a simple way around this problem. Either I renumber the id field OR provide an external counter to present to the user. I don't see any other solutions, does anyone? Thanks. tedd I haven't followed this thread very closely, so pardon me if I'm just repeating what's already been said. In order to have gaps in the DB, you have to delete records out of the DB. What if you do not allow people to actually remove records from the DB, but rather have a deleted or removed column. That way all the IDs are still valid, but you also have a way of knowing what's current and what is not. Just a thought. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services http://www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: what is wrong with my big array
On Tuesday 07 March 2006 08:08, Ross wrote: $region_array = array('a' ='All of Scotland', 1 ='Aberdeen City Council', 2 ='Aberdeenshire Council', 3 ='AngusCouncil', 5 ='Argyll and Bute Council', 6 = 'Clackmannanshire Council', 9 ='Dumfries and Gallowalloway', 10 = 'Dundee City Council', 11 = 'East Ayrshire Council', 13 = 'East Dunbartonshire', 14 = 'East Lothian Council', 15 = 'East Renfrewshire Council', 16 ='Edinburgh City Council', 17 ='Falkirk Council', 18 ='Fife Council', 20 ='Highland Council', 21 ='Inverclyde Council', 22 ='Midlothian Council', 23 = 'Moray Council', 24 ='North Ayrshire Council', 25 ='North Lanarkshire Council', 26 ='Orkney Islands Council', 27 ='Perth Kinross Council', 28 = 'Renfrewshire Council',29 ='Scottish Borders Council', 30 = 'Shetland Isles Council', 31 ='South Ayrshire Council', 32 = 'South Lanarkshire Council', 33 = 'Stirling Council', 34 ='West Dunbartonshire', 35 = 'West Lothian Council', 8 = 'Comhairle nan Eilean'); After the 30 element you have a space after the '=' like: = instead of = HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services http://www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Why Should I Use Zend Optimizer?
In short, Zend Optimise has *nothing* at all to do with 'making dumb programmers code better' I'm afraid. Cheers, Rich I'm not completely sure on this, and if it is true I don't have the links, but I think it does do one thing to make your code better. That is to use pre-increments wherever possible, since the post-increment requires the parser to store the value first then increment it (or something to that effect). But even then it's really only saving you milliseconds of processing time, which would only make a beneficial improvement on an enterprise system (million-plus hits). Other than that I haven't heard anything else. It won't clean up a whole bunch of loops to something more efficient. In response to your slight diversion YES! You are TOTALLY correct. If you write something that uses a loop inside of a loop instead of just one loop (while or for) then it's going to be slower... no matter if it's compiled beforehand or at runtime :) Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why Should I Use Zend Optimizer?
On Monday 27 March 2006 12:40, Richard Davey wrote: On 27 Mar 2006, at 19:10, [EMAIL PROTECTED] wrote: In short, Zend Optimise has *nothing* at all to do with 'making dumb programmers code better' I'm afraid. I'm not completely sure on this, and if it is true I don't have the links, but I think it does do one thing to make your code better. That is to use pre-increments wherever possible, since the post-increment requires the parser to store the value first then increment it (or something to that effect). But even then it's really only saving you milliseconds of processing time, which would only make a beneficial improvement on an enterprise system (million-plus hits). Sorry I should have been more explicit - I meant it won't re-write your actual source code for you, which I believe is what the OP thought it was supposed to do (if only!) Cheers, Rich -- http://www.corephp.co.uk Zend Certified Engineer PHP Development Services Still right on with the pre-compiling though ;) I find that the Optimizer has value. If you wanted to cache on top of that you could probably speed it up even further with cached responses (APC or I think Zend has one too) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script to sanitize variables
On Tuesday 28 March 2006 18:05, Matt Arnilo S. Baluyos (Mailing Lists) wrote: Hello everyone, Would anyone know a PHP script that can sanitize variables to prevent XSS and SQL injection? Thanks and best 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. Chris Shiflett has written a number of good articles on the matter. You can find them at: http://shiflett.org/articles The articles in particular would be: Security Corner: Cross-Site Request Forgeries and Security Corner: Data Filtering and Security Corner: SQL Injection Also, make sure to check out http://phpsec.org HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] int to string
On Wednesday 05 April 2006 16:47, Peter Hoskin wrote: Tanner Postert wrote: I don't think it's built in, so I was wondering ya'll would recommend as the best way to convert int to string, not basic type casting, but converting to the english word the int represents. Something like this: 5 = Five or 20 = Twenty You're right - its not built in. You could use something like this function numerictotext($numeric) { for ($i;$i strlen($numeric);$i++) { $character = substr($numeric,$i,1); switch ($character) { case 0: $return .= 'Zero '; break; case 1: $return .= 'One '; break; } } return $return; } Regards, Peter Hoskin Do I get a cookie? Actually, this isn't far off. I would think that you would have to treat the numbers in the base 10 thinking of it. (I realized this because my wife asked me how binary worked last night, and it was fresh in my head of trying to explain how base 10 actually works) This would mean find out how many characters are in the string (yes, make sure it is a string, not int). Let's assume the number is 256. So then you know that you are using 3 placeholders, btw, this would only work for int... not float. So, for each place holder you have a maximum of 10 possibilities. 2 - hundred 5 - ten 6 - one for the hundreds place you would have a nice big switch statement 1 = one hundred 2 = two hundred etc. for the tens place you have another switch statement 1 = I'm not sure how 1 would work just yet, but it's not far off 2 = 'twenty' 3 = 'thirty' and for the Ones place another switch statement 1= One 2 = Two I think the Ones place would be special depending on if the tens place is a 1 I hope I explained it good enough... working under a deadline at work ;) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IF or SWITCH
Hello World! wait, not coding... (sorry, long night) Okay, I finally finished hashing out all the logic for a very complex set of rules to determine what type an application should be set to. I won't bore you with the details of it, but the question is... I have 57 if/elseif/else statements because of all the different criteria. Is it considered better programming practice to use if/elseif/else statements over a switch(true) case (true false || true || false) syntax? Basically, I'm not too happy with the readability of the code, but I'm afraid that at this point there's not much I can do... code snippet: if($numFFELP 1 count($FFELP_Lenders) 1 $numFFELP == $numTotal){ $retVal = array(TRUE, 'A'); }elseif($numFFELP 0 $enumFFELP 0 count($FFELP_Lenders) 1 $enumFFELP + $numFFELP == $numTotal){ $retVal = array(TRUE, 'A'); }elseif($numFFELP 0 $numCONS 0 count($FFELP_Lenders) 1 $numFFELP + $numCONS == $numTotal){ etc. Any suggestions? Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IF or SWITCH
On Wednesday 05 April 2006 20:11, Robert Cummings wrote: Well I'd use if/elseif/else but I don't format like you... ?php if( $numFFELP 1 count( $FFELP_Lenders ) 1 $numFFELP == $numTotal ) { $retVal = array( TRUE, 'A' ); } else if( $numFFELP 0 $enumFFELP 0 count( $FFELP_Lenders ) 1 ($enumFFELP + $numFFELP) == $numTotal ) { $retVal = array( TRUE, 'A' ); } else if( $numFFELP 0 $numCONS 0 count( $FFELP_Lenders ) 1 ($numFFELP + $numCONS) == $numTotal ) { // Wh! } ? Yeah it's vertically sprawling, yeah it looks tedious to type, but damn is it clear *lol*. Once you get into a habit it becomes second nature. Cheers, Rob. Thanks for the input. I especially like the Wheee part. Maybe I'll add that in there... it's been a long day *lol* -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] IF or SWITCH
Original Message Subject: Re: [PHP] IF or SWITCH From: Chris [EMAIL PROTECTED] Date: Wed, April 05, 2006 8:32 pm To: Ray Hauge [EMAIL PROTECTED] Cc: PHP-General php-general@lists.php.net Ray Hauge wrote: Hello World! wait, not coding... (sorry, long night) Okay, I finally finished hashing out all the logic for a very complex set of rules to determine what type an application should be set to. I won't bore you with the details of it, but the question is... I have 57 if/elseif/else statements because of all the different criteria. Is it considered better programming practice to use if/elseif/else statements over a switch(true) case (true false || true || false) syntax? Basically, I'm not too happy with the readability of the code, but I'm afraid that at this point there's not much I can do... code snippet: if($numFFELP 1 count($FFELP_Lenders) 1 $numFFELP == $numTotal){ $retVal = array(TRUE, 'A'); }elseif($numFFELP 0 $enumFFELP 0 count($FFELP_Lenders) 1 $enumFFELP + $numFFELP == $numTotal){ $retVal = array(TRUE, 'A'); }elseif($numFFELP 0 $numCONS 0 count($FFELP_Lenders) 1 $numFFELP + $numCONS == $numTotal){ etc. Are you in a function? Maybe it'll be clearer/easier to follow if you return when you find the right condition: if ($numFFELP 1 count($FFELP_Lenders) 1 $numFFELP == $numTotal) { return array(TRUE, 'A'); } if (. PS - count($array) does a count every time, so depending on how large you expect this array to get, it could be quicker (processing time) to: $count_lenders = count($FFELP_Lenders); if ($count_lenders 1) -- Postgresql php tutorials http://www.designmagick.com/ I should change that count out. Thanks for the tip. This is actually in a function, but I prefer to only have one location of returning. I think it makes it easier to debug. Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] IF or SWITCH
Original Message Subject: Re: [PHP] IF or SWITCH From: John Wells [EMAIL PROTECTED] Date: Thu, April 06, 2006 6:08 am To: php-general@lists.php.net ...Either way, internally, switch behaves like if/elseif/else and generally only provides an advantage with respect to code organization or if you want a particular condition to drop through to other case blocks. Considering this is regarding an if/else with ***57*** conditional checks, wouldn't we be wise in suggesting switch/case if one of its benefits is code organization and readability? Imagine having to come back to this code block in a months time to trace a bug. *shudder* I would look very long and hard at how the solution may be simplified, although it's hard to offer ideas without understanding the business logic. I'm just hoping for your sake that there is a way. Good luck! John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for all the info. I think I am going to take a lot of this information in mind to make it more readable... possibly even use a switch statement, because I know that this logic is going to change, and I WILL have to come back to this. Such a pain to completely cover every possibility under the sun for so many permutations... Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IF or SWITCH
On Thursday 06 April 2006 11:20, tedd wrote: At 1:04 PM -0400 4/6/06, Robert Cummings wrote: On Thu, 2006-04-06 at 11:50, tedd wrote: Regardless of speed, I find that switch is much easier to write and debug than if/elseif -- which, regardless of my shortcomings, I never use. Umm, that you NEVER use elseif I think is strongly coupled with your shortcomings :l But I'm not judging, to each his own :| Cheers, Rob. Rob: Yes NEVER -- as for my shortcomings, they remain as obvious as is my lack of pretense otherwise. Whereas, my abilities, like most, are not as obvious. As Will Roger's once said We're all ignorant, only in different subjects. But regardless of my limitations, I still have never had to use an if/elseif for anything -- and I wrote my first line of code in 1966. I don't remember specifically just when if/elseif and switch-like conditionals first appeared in programming (they haven't always been there and my old Fortran books have been long stored) but I have one in front of me that's dated 1976 where it just mentions The Logical IF Statement with no if/else or switch-like statements. So, my programming probably predates both conditions -- however -- in 40 years I have NEVER used an if/elseif control structure by any name and I always found a way around it -- and one that was usually faster and with better readability. If your strong-comings are better than my shortcomings, then perhaps you could provide an example of where a switch could not preform what an if/elseif could -- do you have one? My gut feeling is that you can't -- as well as my gut feeling that when language developers first thought of if/elseif control, they realized that it was confusing and provided a switch to get around it. But, then again, maybe I'm wrong -- been there before. :-) tedd -- --- - http://sperling.com I'm pretty sure he's ONLY talking about IF/ELSEIF and not IF in general. That's what I got from the message. Correct me if I'm wrong. I ended up deciding to stay with the IF/ELSEIF statements... mostly because I was already done. I did clean up the COUNT()ing though. Always nice when the list helps out :) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IF or SWITCH (asinine?)
On Friday 07 April 2006 08:57, tedd wrote: Personally, as I said before, I use if/else for two conditions and switch for three or more. Your mileage may vary, but it's truly a matter of choice and is not one of asinine methodology. Thanks to all who replied. tedd -- --- - http://sperling.com I think that's a fairly good methodology to follow. I usually do that... except when I run into a huge list of multiple conditions for each possibility (TRUE FALSE OR FALSE TRUE) etc. To me IF/ELSEIF is easier to ready in that case, and SWITCH is a LOT easier to read if you have one variable and have a CASE for each possibility of that variable. Just my opinion of course :) I guess when it came down to it I just had to stick with what works for me. I cleaned up a lot of the totals and counting, so it's MUCH easier to read now :) To imitate Tedd... Thanks to all who replied -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse Error on SQL Insert
On Friday 07 April 2006 12:53, Joe Henry wrote: On Friday 07 April 2006 1:37 pm, Tom Chubb wrote: $insertSQL = INSERT INTO cars (model, `year`, details, price, image1, Not sure if this is your problem, but those look like backticks around year instead of single quotes. Should there even be quotes there? HTH -- Joe Henry www.celebrityaccess.com [EMAIL PROTECTED] The backticks should be fine. They tell MySQL that you mean the column year of the table cars and not the MySQL special word year which can be used in date calculations. The same thing would apply if you wanted a column named create. I would agree with John on the POST data. Make sure you at least run mysql_real_escape_string(). -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse Error on SQL Insert
On Friday 07 April 2006 12:56, Chrome wrote: Of course if the field in the DB isn't numeric this would be '{$_POST['model']}' Dan That's what I was thinking. Even if data is a number, I still generally put quotes around it to make sure I don't have an issue. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Zend Certification
Hello All, I've been thinking about taking the ZCE test. I want to, but I also want it to be current for as long as possible. Should I wait for it to be revised for PHP5, or are they even going to update it? I just don't want to end up taking it and then a few months later have it be outdated because it was for PHP4, and not PHP5. Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Certification
On Friday 07 April 2006 15:24, Rory Browne wrote: having both will give you that long_time_user status. Good point. Thanks :) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IF or SWITCH (asinine?)
On Friday 07 April 2006 16:41, tedd wrote: Note, it's not actually required to have a variable to be evaluated for each case statement. Each case statement stands on it's own independent from the evaluation. This has always worked for me in other languages and I am assuming that it works the same in php. Does anyone disagree or will correct me? HTH's. tedd You are right. It does work that way. My opinion just differs in that I think ELSEIF works better in that situation than SWITCH, and SWITCH is better for a single value comparison than ELSEIF. I think that by now people will have been able to form their own conclusions as to which style they prefer, and either is probably more readable than putting everyone all on one line :-P -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A question about max_execution_time
On Monday 10 April 2006 11:30, Eric Butera wrote: Dear List, I have been working with a PHP script that curls a file from another server. This works fine on my local machine, but not on our live server. The script takes about 400 seconds to execute completely. I was under the impression that my call to set_time_limit(900); was helping. Well, I took that line out and nothing changed locally or on the server. In fact I even tried this little test: ?php // header include for my config (to get Util) error_reporting(E_ALL); echo 'brmax execution time: '. ini_get('max_execution_time'); sleep(40); echo brdone!; echo brbrScript Executed Time: . Util::displayMicroTime( $_SCRIPT_START_TIME, Util::getMicroTime() ); die('br'.__FILE__.__LINE__); ? Outputs: max execution time: 30 done! Script Executed Time: 40.01 /Users/eric/Sites/test/member_get_update.php26 Now why did this work? Shouldn't the script have timed out after 30 seconds? Thanks in advance! Eric The information in set_time_limit() might help: http://us3.php.net/set_time_limit Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A question about max_execution_time
On Monday 10 April 2006 11:48, Eric Butera wrote: Ray, Thank you for your response. I did read that in the manual, I promise. That is why I included the sleep function in my example. Shouldn't the sleep function count as execution time? One thing I didn't metion earlier, for the sake of simplicity, is that my script is pulling an XML file. After I get the XML file I parse through it which also takes time too. The recordset is about 6 thousand records so it does take a while. Right after I sent that I started wondering if sleep() would be counted in the time or not. I would think it would, but it *could* in the background just run the system sleep, which might not be counted... I don't know that much about the sleep function to tell you. Parsing the XML should cause it to time out if it was longer than 9 seconds though... interesting situation... At the moment I don't have much else for you :( -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function by reference
On Monday 10 April 2006 19:19, Richard Lynch wrote: On Sun, April 9, 2006 1:17 pm, tedd wrote: Hi gang: Not that I have an immediate need for this, but in other languages one can access a function by reference (in other words, it's address -- such as call(function address) ). In php, one can pass a variable by reference by simply using the ampersand, such a $a. Is there a similar way to reference a function? Rob, was kind enough to post the following code, but I was looking for something where I could store the function's address in a variable. Something like: $a = f_a(); And then, where I could use call_user_func($a); (or something similar) and the function would do it's thing -- anything like that? Thanks tedd --- Rob's suggestion follows. Like the following? ?php function f_a() { echo 'a'; } function f_b() { echo 'b'; } function f_c() { echo 'c'; } $map = array ( 'a' = 'f_a', 'b' = 'f_b', 'c' = 'f_c', ); $map['a'](); $map['b'](); $map['c'](); ? -- - --- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm I believe you're thinking more of the C++ style of returning by reference. This article should help explain how references work, and how to return references... most specifically check the Returning References section. http://www.php.net/manual/en/language.references.php HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function by reference
I believe you're thinking more of the C++ style of returning by reference. This article should help explain how references work, and how to return references... most specifically check the Returning References section. http://www.php.net/manual/en/language.references.php HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 nevermind... I what I read and what was actually written seem to have been two entirely different things ;) Still good info though. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compacting multiple spaces...
On Friday 14 April 2006 12:15, Geoffrey E. Quelch wrote: Hi, I am running a self-compiled PHP version 4.4.2 on Apache 1.3.34 on White Box Enterprise Linux 3. I found a problem in my database access code (Oracle 9.2.0.4 if it matters) and have determined that spaces in string variables are being compacted on output in PHP. This PHP extract, when run, illustrates the problem: ?php $name = Space 9; print pLength: .strlen($name); printf(pVariable: %s,$name); print pVariable: '.$name.'; echo pVariable: .$name; for($i=0; $i strlen($name); $i++) print pCharacter: .$i.\$name[$i]\; ? even though the string does contain 9 consecutive spaces, only one is ever printed to the screen with echo, print or printf. There is nothing in the documentation for these functions that I've found that says this is the expected behavior, or how to override if one really wants those spaces honored. Why is this important? Well, the application this is in allows users to define text strings that are inserted into the database with multiple consecutive spaces, however, when constructing select lists in PHP using these same entries the spaces are compacted, so the SELECT now doesn't match what is in the database. Is there a way to override this behavior? Thanks, Geoff Quelch -- Geoff Quelch Email: [EMAIL PROTECTED] I would suggest replacing spaces with their HTML equivalent (nbsp;). You could either store it that way, or change it when you output. Then when you go to run the query change all nbsp; instances back to space. HTH -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Table formation...
On Monday 17 April 2006 14:04, Jochem Maas wrote: I thought the 'rule' around here was do a 'reply to all' - someone put me right if I've been an idiot all this time! I use Kmail, and it has a feature to just reply to the mailing list, so I generally use that. Reply to all is definitely easier than taking out the person's email address. Probably a good rule to make sure posts are posted to the list, and not just the person who you're replying to ;) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF to Text
Hello List, I am trying to find a way for a program to search through the text on a PDF. My first thought was to use pdftotext, but the PDFs generated by our commercial scanner/copier/printer machine do not seem to work with pdftotext... it just outputs two CRLFs. I've been looking around on the net for something similar that might work. Anyone know of something like that? Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF to Text
On Thursday 20 April 2006 18:06, Ray Hauge wrote: Hello List, I am trying to find a way for a program to search through the text on a PDF. My first thought was to use pdftotext, but the PDFs generated by our commercial scanner/copier/printer machine do not seem to work with pdftotext... it just outputs two CRLFs. I've been looking around on the net for something similar that might work. Anyone know of something like that? Thanks, -- Ray Hauge Things I forgot to post: It is a PHP script. I was planning on using shell_exec() to call the program and read the output from stdout. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF to Text
On Thursday 20 April 2006 19:23, Richard Lynch wrote: Actually, it's possible just bloody difficult. You're looking into a topic known as OCR (Optical Character Recognition). One OS project for this is: GOCR (aka JOCR) It's GOCR on freshmeat and JOCR on sourceforge because they name they wanted was taken by another project. :-( A commercial product known as OmniPages is probably the best solution, unfortunately. Thanks for the info. It makes sense that the scanner puts makes the image and puts that on the PDF. I'll have to look into GOCR, or just scrap the idea I had. Luckily I'm still just in the planning stage and we haven't figured out how all the processes are going to work :) Thanks again, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] re: undefined variable
Original Message Subject: [PHP] re: undefined variable From: Smart Software [EMAIL PROTECTED] Date: Sun, April 30, 2006 1:50 pm To: php-general@lists.php.net //get content of textbox $q = isset($_REQUEST['$textbox']) ? $_REQUEST['$textbox'] : 0; You should use $_REQUEST[$textbox] or $_REQUEST[$textbox]. Variables are not converted within a single-quoted string. HTH, Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Imagemagick Displaying Images
I have an application that shows thumnails of PDF files in different directories. I have so far decided that I can use convert from imagemagick to get a .jpg, .png, .gif, etc. to display as the image. The problem I'm running into is that I don't want to save these thumbnails. Instead I just want to take the binary data and display an image with it. I figure that it's possible since you can store binary data in a database and display it that way. an example of what I'm doing is: convert -resize 800x600 AR-M455N_20060420_130446.pdf[0] - The '-' makes it display the contents of the image to stdout. I want to caputre that binary data and somehow display the images inline with the website. Is this possible, or am I living in a dream world ;) Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagemagick Displaying Images
On Tuesday 02 May 2006 18:19, Ray Hauge wrote: I have an application that shows thumnails of PDF files in different directories. I have so far decided that I can use convert from imagemagick to get a .jpg, .png, .gif, etc. to display as the image. The problem I'm running into is that I don't want to save these thumbnails. Instead I just want to take the binary data and display an image with it. I figure that it's possible since you can store binary data in a database and display it that way. an example of what I'm doing is: convert -resize 800x600 AR-M455N_20060420_130446.pdf[0] - The '-' makes it display the contents of the image to stdout. I want to caputre that binary data and somehow display the images inline with the website. Is this possible, or am I living in a dream world ;) Okay, I'll admit it. I didn't STFW. I believe that if I make a seperate script to just display the images, and then display them all with img src='show_image.php?id=blah'. Of course this is just theory until I try it, but I'm pretty sure this is on the right path. Thanks for listening anyway, and maybe this will help someone else ;) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagemagick Displaying Images
On Tuesday 02 May 2006 18:24, Ray Hauge wrote: On Tuesday 02 May 2006 18:19, Ray Hauge wrote: I have an application that shows thumnails of PDF files in different directories. I have so far decided that I can use convert from imagemagick to get a .jpg, .png, .gif, etc. to display as the image. The problem I'm running into is that I don't want to save these thumbnails. Instead I just want to take the binary data and display an image with it. I figure that it's possible since you can store binary data in a database and display it that way. an example of what I'm doing is: convert -resize 800x600 AR-M455N_20060420_130446.pdf[0] - For further clarification, here is how I got it to actually convert, but still display the output to standard out: $img = shell_exec(convert -resize 800x600 /tmp/file.pdf[0] jpg:-); header(Content-type: image/jpg); print($img); Now you can dream up any sort of ideas with GET variables to define which image you want. Later, Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP-Jabber
I've been using this library for a while. I don't need to do much, so I don't know first hand how well all the features work, but it definitely will get you a list of people online and let you send messages to them. http://cjphp.netflint.net/ HTH, Ray Original Message Subject: [PHP] PHP-Jabber From: Tony Aldrich [EMAIL PROTECTED] Date: Tue, May 02, 2006 9:48 pm To: php-general@lists.php.net Hello, Can somebody recommend clean php jabber library? I must send notifications to some users. Tony. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Upgrade Question
Hey all- I'm running a SuSE 9.1 box that was built from the RPMs from the CD with Apache2.0 and PHP 4.3.4. I've made modifications to the server over the last year without using the CD's and justing installing from the source. However, I just installed PHP 4.4.2 and I used all the same path calls as the build of 4.3.4 and it seems to have upgraded without an issue. When I type /usr/bin/php -v I get the following: PHP 4.4.2 (cgi) (built: May 3 2006 16:34:27) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies However, when I restart the web server and I run my phpinfo() script, I am still seeing the 4.3.4 build information. Did I miss something with this? I've updated other servers but they were all built using source only, no rpms... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Upgrade Question
On 05.03.2006 at 16:46:21, Eric Butera [EMAIL PROTECTED] wrote: On 5/3/06, Tom Ray [EMAIL PROTECTED] wrote: Hey all- I'm running a SuSE 9.1 box that was built from the RPMs from the CD with Apache2.0 and PHP 4.3.4. I've made modifications to the server over the last year without using the CD's and justing installing from the source. However, I just installed PHP 4.4.2 and I used all the same path calls as the build of 4.3.4 and it seems to have upgraded without an issue. When I type /usr/bin/php -v I get the following: PHP 4.4.2 (cgi) (built: May 3 2006 16:34:27) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies However, when I restart the web server and I run my phpinfo() script, I am still seeing the 4.3.4 build information. Did I miss something with this? I've updated other servers but they were all built using source only, no rpms... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just a stab in the dark, but are you sure you built it the way you meant? Your php says cgi. Did you mean to compile as cgi or with apxs? That might be the problem. But I could be very wrong. Appologies if I am. No, you're not. I tried to build with apxs because that is what the phpinfo file calls on --with-apxs2=/usr/sbin/apxs2-prefork but apxs2-prefork doesn't exist there or within the apache2 directory structure. I ended up using --with-httpd2=/usr/sbin/httpd2 because thats the closest I found. It also had --without-cli in the phpinfo so that's what I used in the new configuration. Perhaps that is the problem? Another thing to consider is if you built it, you could easily have different versions installed on the machine. Issuing a locate /bin/php might prove that or not. Only one version installed on the server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Upgrade Question
On 05.03.2006 at 16:46:21, Eric Butera [EMAIL PROTECTED] wrote: On 5/3/06, Tom Ray [EMAIL PROTECTED] wrote: Hey all- I'm running a SuSE 9.1 box that was built from the RPMs from the CD with Apache2.0 and PHP 4.3.4. I've made modifications to the server over the last year without using the CD's and justing installing from the source. However, I just installed PHP 4.4.2 and I used all the same path calls as the build of 4.3.4 and it seems to have upgraded without an issue. When I type /usr/bin/php -v I get the following: PHP 4.4.2 (cgi) (built: May 3 2006 16:34:27) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies However, when I restart the web server and I run my phpinfo() script, I am still seeing the 4.3.4 build information. Did I miss something with this? I've updated other servers but they were all built using source only, no rpms... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just a stab in the dark, but are you sure you built it the way you meant? Your php says cgi. Did you mean to compile as cgi or with apxs? That might be the problem. But I could be very wrong. Appologies if I am. Ok so I can't find apxs on the server at all, even though the 4.3.4 phpinfo claims to have been configured with --with-apxs2=/usr/sbin/apxs2-prefork. I did some search via google and I reconfigured using --enable-cli and --disable-cgi but I still had to use --with-apache2=/usr/sbin/httpd2 because I need to have that correct? Since all the builds I done with PHP call on a Apache source in some way. It still compiled with it's SAPI choice being cgi then I ran 'make install-cli' and now when I do a /usr/bin/php -v I get: PHP 4.4.2 (cli) (built: May 3 2006 18:36:11) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies But when I restart apache I'm still seeing 4.3.4 in the phpinfo() information. I've even restarted the server with no luck. Can someone tell me what I missing? It seems SuSE compiled PHP with the --disable-session call in the configuration and we need Sessions enable to support Zencart and phpOpenChat for some clients. Another thing to consider is if you built it, you could easily have different versions installed on the machine. Issuing a locate /bin/php might prove that or not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Imagemagick Displaying Images
On Thursday 04 May 2006 17:41, Richard Lynch wrote: [NB: Ray said that...] It's easy if the image is all that is on the page. E. HTML and in-line images don't really work in a cross-browser compatible sort of way, and really mess with browser caching and page load times and are just such a Bad Idea that I didn't even consider that Ray might have meant image inlined with HTML I really (still) think Ray just meant: Cache and display the image in one operation without using a tempfile. Now that I think about it, you'd still want ob_start() if you want to cache and display the image inlined with HTML anyway, assuming you wanted to do something so foolish in the first place... -- Like Music? http://l-i-e.com/artists.htm Here's what I ended up doing: html ... img src='show_image.php?file=filename.pdf' / ... /html where show_image.php contains: ? $path = /path/to/files/; $filename = htmlentities($_GET['file']); $img = shell_exec(convert {$path}{$filename}[0] png:-); header(Content-type: image/png); print($img); ? I could use a cache, but I haven't yet. It's for an internal intranet application, so I'm not worried about page load times too much. With 10 pdfs it still loads in about a minute, and I don't expect there to be many more than 30 or so, and those PDFs will be moved after this application is run anyway, so caching doesn't make sense for my situation, as images will really only be shown once. If it was going to be used more caching would definitely make sense though. Thanks for the input all. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Imagemagick Displaying Images
On Thursday 04 May 2006 17:52, Ray Hauge wrote: On Thursday 04 May 2006 17:41, Richard Lynch wrote: [NB: Ray said that...] It's easy if the image is all that is on the page. E. HTML and in-line images don't really work in a cross-browser compatible sort of way, and really mess with browser caching and page load times and are just such a Bad Idea that I didn't even consider that Ray might have meant image inlined with HTML I really (still) think Ray just meant: Cache and display the image in one operation without using a tempfile. Now that I think about it, you'd still want ob_start() if you want to cache and display the image inlined with HTML anyway, assuming you wanted to do something so foolish in the first place... -- Like Music? http://l-i-e.com/artists.htm Here's what I ended up doing: html ... img src='show_image.php?file=filename.pdf' / ... /html where show_image.php contains: ? $path = /path/to/files/; $filename = htmlentities($_GET['file']); $img = shell_exec(convert {$path}{$filename}[0] png:-); header(Content-type: image/png); print($img); ? I could use a cache, but I haven't yet. It's for an internal intranet application, so I'm not worried about page load times too much. With 10 pdfs it still loads in about a minute, and I don't expect there to be many more than 30 or so, and those PDFs will be moved after this application is run anyway, so caching doesn't make sense for my situation, as images will really only be shown once. If it was going to be used more caching would definitely make sense though. Thanks for the input all. Basically I took the same principles applied to displaying images stored in a database. I figured it was obvious that's what I was saying, but figured clarification is always good. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Imagemagick Displaying Images
On Thursday 04 May 2006 17:52, Ray Hauge wrote: [SNIP] I could use a cache, but I haven't yet. It's for an internal intranet application, so I'm not worried about page load times too much. With 10 pdfs it still loads in about a minute, and I don't expect there to be many more than 30 or so, and those PDFs will be moved after this application is run anyway, so caching doesn't make sense for my situation, as images will really only be shown once. If it was going to be used more caching would definitely make sense though. Again, don't mine me. For some reason I was thinking APC cache, not output buffering... -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Upgrade Question
On 05.03.2006 at 20:34:20, Eric Butera [EMAIL PROTECTED] wrote: Ok so I can't find apxs on the server at all, even though the 4.3.4phpinfo claims to have been configured with --with-apxs2=/usr/sbin/apxs2-prefork. I did some search via google and I reconfigured using --enable-cli and --disable-cgi but I still had to use --with-apache2=/usr/sbin/httpd2 because I need to have that correct? Since all the builds I done with PHP call on a Apache source in some way. It still compiled with it's SAPI choice being cgi then I ran 'make install-cli' and now when I do a /usr/bin/php -v I get: PHP 4.4.2 (cli) (built: May 3 2006 18:36:11) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies But when I restart apache I'm still seeing 4.3.4 in the phpinfo() information. I've even restarted the server with no luck. Can someone tell me what I missing? It seems SuSE compiled PHP with the --disable-session call in the configuration and we need Sessions enable to support Zencart and phpOpenChat for some clients. Another thing to consider is if you built it, you could easily have different versions installed on the machine. Issuing a locate /bin/php might prove that or not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I run Ubuntu Dapper Drake at home (the only place I've dabbled with compiling php). To get it to compile I had to install the packages apache2-mpm-prefork and apache2-prefork-dev to get the system setup correctly. By default it had something else which did not give me apxs2. My apxs2 is in /usr/bin/apxs2. So maybe if you could figure out how to get that package /usr/sbin/apxs2-prefork on your system that might do it. I'm really not the one who should be giving any advice on this since I just kept beating on mine till it worked. ;) But then again, nobody else is replying so... Well I finally got PHP 4.4.2 installed. I ended up having to install a fresh version of Apache2 and then compiling PHP into that version. Now I have the fun task of configuring the new install of Apache2 with all the current sites on that server so they can run PHP 4.4.2 Thanks for the help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] extract text from pdf
If this is on a *nix box, I would suggest using the pdf2text command within shell_exec. It should work as long as the PDF isn't a scanned image. Obviously it won't get text off the images, and you'd want to make sure that any input to filenames (if they're dynamic) are verified and scrubbed first so people can't access different files on the filesystem. HTH, Ray Original Message Subject: [PHP] extract text from pdf From: cajbecu [EMAIL PROTECTED] Date: Thu, May 11, 2006 1:45 am To: 'PHP General (E-mail)' php-general@lists.php.net Hello, Is there any posibility to extract all text from a PDF file? (I have read all the documentation about PHP PDF-Lib but no answer...) Thanks in advance, cajbecu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tuesday 23 May 2006 13:40, Richard Lynch wrote: You have users who double-click on their submit button. Deal with it. :-) Add a token to the form and mark it used in the database on first submit. You could even go so far as to disable the form element with the onClick event. Should work for anchor tags as well. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checkbox Hidden Field to Delete Row
On Thursday 01 June 2006 12:58, Rahul S. Johari wrote: Ave, I¹m stuck on a problem here. I have a file manager kind of application and I¹m trying to add the functionality to delete multiple files. Basically, there¹s a bunch of rows generated dynamically. Each row has a checkbox for ³Delete² option, and a hidden field which contains the name of the File associated with the record. If a user checks a checkbox to delete certain rows, it should be able to delete those rows from mySQL as well as delete the files associated with that record. I created both the checkboxes the hidden fields to be Arrays. I run a loop to delete all rows (based on ID¹s) where the checkbox was Checked. It does that part fine... The problem is linking the Filename array to the Checkbox Array. It deletes the first two files uploaded no matter what rows are checked. Basically, the Filename array is not associating with the Checkbox array. So if a person checks the 3rd and 5th checkbox... The 3rd 5th row is deleted from mySQL, but the 1st and 2nd file is deleted, not the 3rd 5th. Rahul S. Johari The problem is coming from how checkboxes submit their information to the form. Only the checked checkboxes will actually send data. The unchecked ones will not send anything. Hidden fields differ, in that they ALWAYS send their data. This is probably causing a mis-match between the two arrays. You could verify that by doing a var_dump on the arrays before you delete anything. I would suggest that since you keep a record of the file in the database, include the file location in that database record. Then before you delete it, get the file name, delete the file, then delete the record. I think that would save you a bunch of headaches. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checkbox Hidden Field to Delete Row - SOLVED
On Thursday 01 June 2006 13:15, Rahul S. Johari wrote: Ave, I spent 3 hours trying to find or develop a solution for this problem... And believe it or not, within 3 minutes of sending the problem to the mailing list, I actually generated a solution!! Ray, you’re spot on with what’s actually happening, but this is what I did to resolve it... Here’s my code to generate the Dynamic Row with Checkboxes: td width=15span class=\style11\ input type=checkbox name=thisID[] value=\$myrow[ID]#imsafm/$showfilesuser/$myrow[filename]\input type=hidden name=login value=$loginINPUT TYPE=hidden name=showfilesuser value=$showfilesuser/td I completely eliminated the Hidden field... Instead, added the value of both the Row ID the Filename to the checkbox, with a seperator “#”. Here’s my code to delete the Row Corresponding File: foreach($thisID AS $value) { $pieces = explode(#, $value); $sql = DELETE FROM file WHERE ID='$pieces[0]'; $result = mysql_query($sql) or die(Fatal Error: .mysql_error()); $thefile = $pieces[1]; unlink($thefile); } As you can see, I basically explode the Array on the “#” seperator, and delete the Row File. Is working like a charm!! Tad different, but that will definitely work as well. It's a long shot, but just make sure that filenames don't have a # in them. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD
On Monday 12 June 2006 16:11, Beauford wrote: Hi, I am trying to get GD working so I can use a captcha script and not having much luck. I can get it to work in Windows, but not Linux. I have seen a few comments suggesting that PHP needs to be compiled with the GD switch. Is there another way to do this? I have PHP, MySQL and Apache installed and working great, I don't want to have to recompile PHP and have it screw up everything just for one program. Any help is appreciated. B Depending on your Linux distribution, you might be able to find a GD module for PHP. That way you don't have to re-compile PHP. If you use an RPM based distro, this would be very easy. Free-BSD you could just compile the port. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For Loop
On Tuesday 20 June 2006 15:14, Albert Padley wrote: I have a regular for loop - for($i=1; $i100; $i++) Within the loop I need to create variables named: $p1name; $p2name; $p3name; etc. The integer portion of each variable name needs to be the value of $i. I can't seem to get my syntax correct? Can someone point me in the right direction? Thanks. Albert Padley If you really want to keep the p?name syntax, I would suggest throwing them in an array with keys. $arr[p1name] $arr[p2name] Then that way you can create the key dynamically: $arr[p.$i.name] Not pretty, but it works. Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For Loop
On Tuesday 20 June 2006 15:28, Adam Zey wrote: Ray Hauge wrote: On Tuesday 20 June 2006 15:14, Albert Padley wrote: I have a regular for loop - for($i=1; $i100; $i++) Within the loop I need to create variables named: $p1name; $p2name; $p3name; etc. The integer portion of each variable name needs to be the value of $i. I can't seem to get my syntax correct? Can someone point me in the right direction? Thanks. Albert Padley If you really want to keep the p?name syntax, I would suggest throwing them in an array with keys. $arr[p1name] $arr[p2name] Then that way you can create the key dynamically: $arr[p.$i.name] Not pretty, but it works. Thanks, I haven't checked this, but couldn't you reference it as $arr[p$iname] ? Is there a reason why variable expansion wouldn't work in this circumstance? If it does, you could make it easier to read by doing $arr[p{$i}name] even though the {} aren't required. It'd be a lot easier to read than concatenations :) Regards, Adam. Both of those ways work. I think there's a question on the PHP Certification Exam about the different ways to work with strings. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XUL and PHP - what's your opinion?
I keep hearing about XUL, and I was wondering what the opinion of the masses was on this subject for an internal application where the browser is pre-determined. From my point of view I, having only read about it and not used it, is that XUL would make your applications look more like a desktop application. Some of the widgets they provide come in handy, like tables that can sort themselves instead of using AJAX/another page hit. The down sides that I see is there would be a 99.999% chance of a learning curve for any new developers that come into the company. Also, I'm not sure if XUL would cause extra programming overhead than regular HTML/JS. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shortest possible check: field is set, integer or 0
Richard Lynch wrote: On Wed, November 30, 2005 5:10 pm, Chris Lott wrote: What is the shortest possible check to ensure that a field coming from a form as a text type input is either a positive integer or 0, but that also accepts/converts 1.0 or 5.00 as input? This might be good enough: if (isset($_POST['x'])){ if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x']){ //invalid } else{ $_CLEAN['x'] = (int) $_POST['x']; } } You could also replace: if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x']) with: if(!is_numeric($_POST['x']) || $_POST['x'] 0) This would ensure that your value only contains numbers, and that it is greater than zero. Then when you put it into the $_CLEAN array, you can type-cast it as an int (as in the other script) and that would convert any doubles to an integer value. If you wanted you could also round, ceil, or floor the value. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF Generator
http://www.fpdf.org is a very good resource for PDF generation. I use it all the time. It was faster than writing up my own PDF class. It's fairly well documented as well. There's also http://fpdi.setasign.de/ if you want to put text, images, etc on an existing PDF. Jay Blanchard wrote: [snip] What is the best FREE pdf generator for PHP? [/snip] http://www.fpdf.org and you know that PHP has some built-in functionality using PDFlib http://www.php.net/pdf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Determine object type
That would be get_class( [obj] ); http://us3.php.net/manual/en/function.get-class.php Matt Monaco wrote: Is there a function or method to determine the class an object was defined from? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] references, circular references, oop, and garbage collection in PHP5
I am uncertain on this, but I believe that the $this variable is already just a reference to the class you are calling it from. Then passing the reference by-reference to the addParent() method of the Child class could be what is causing your issue. I'd be curious to see what would happen if you took out the pass-by-reference and instead pass-by-value for the addParent() method. Then again, that doesn't particularly sound correct either. This link might help. They cover a lot of advanced reference usage for PHP. http://www.onlamp.com/pub/a/php/2002/09/12/php_foundations.html Alan Pinstein wrote: So.. I am having PHP5 memory management problems. They are similar to those described in this thread: http://aspn.activestate.com/ASPN/Mail/Message/php-Dev/1555640 (so maybe this question belongs on php-dev but I figured I'd try here first... seems like a userland question) Basically I have an object model to represent db objects, and I am bulk-loading the objects via some PHP scripts. Sadly the scripts consume unbounded memory because of this problem. I have done a lot of programming in C++ and Obj-C and the normal way to handle circular references is to have parents retain (keep ref- counted links) to their kids, and have the kids have weak references (non-ref-counted) links to their parents. This way, when the parent is no longer used, it will automatically 0-out the ref counts to all children it links too and things GC correctly. Now, how to do this in PHP? Well, there are no documented weak references. However, I figured out by trial that if you obtain a php-reference to an object, it doesn't bump the refcount. Question #1: Is the fact that references to objects in the form $objRef = $obj don't bump the refcount of $obj an intended behavior that can be counted on? If so, cool! So, now that we have a way to do weak references, we should be able to implement a reasonable memory management scheme for parent-child objects. Normally from the client side the interface should look something like: $parent = new Parent(); $child = new Child(); $parent-addChild($child); Where parent can have 0,n children and child can have 0,1 parent. And all of parent's internal links to child should be refcounted, and the internal links from child to parent are weak (not ref-counted). So based on the above discovery about references, I tried to implement this as such: class Parent { public $children = array(); // add a child to our list. We want a ref-counted link here. function addChild($child) { $this-children[] = $child;// refCounted desired in parent-child link $child-setParent($this); } } class Child { public $parent; // set the parent object. We want a non-ref-counted link here. function setParent($parent) { // refCount NOT desired in child-parent link $this-parent = $parent; } } Now, you'd expect this would work, but it doesn't. On a hunch, I changed the client code to: $parent = new Parent(); $child = new Child(); $parent-addChild($child); $child-setParent($child);// new line here - you can successfully create a reference to the object when not passed in as $this Now, this works! However, it's not practical. The setParent call should work from within the parent object So what I figured out is that $this is a pseudo variable according to the docs, but I don't know what that means. Empirically I have figured out that it means you cannot create a reference to it. Is this a feature or a bug? What's the workaround? This is a serious problem for PHP scripts that need to do things that require large amounts of memory. Please advise. Thanks, Alan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing Cross Site Scripting Vulnerbilities
There's been a lot of great articles in the PHP|Architect magazine over the past 3 months or so about this (http://www.phparch.com) You do have to purchase back-issues though. Very good articles though. They cover how to make functions to filter what variables should be sent in, and how to make sure all the data is what you expect. Jason Gerfen wrote: comex wrote: Similarly is there a library function for escaping database content for inclusion in HTML pages? http://php.net/htmlspecialchars http://php.net/htmlentities Or roll your own and replace the eregi regex with data that is valid to your application: function chk_input( $string ) { if( eregi( ^[0-9a-z_ -]$, $string ) ) { return 0; } else { return 1; } } if( chk_input( $string ) == 0 ) { echo valid; } else { echo invalid; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 1 ip address go here all others go here
That would be something along the lines of: preg_match(/^192\.168/,$_SERVER['REMOTE_HOST']); I'm a little rusty on my regex, but that should do it. Dave Carrera wrote: i know about $_SERVER['REMOTE_HOST'] but i think i should of said how do i compare any address starting with 192.168. sorry if my first question was to vague David Grant wrote: Try $_SERVER['REMOTE_HOST'] instead of REFERER. Dave Carrera wrote: Jay Blanchard wrote: [snip] Is there a way of sending users with a local ip address say 127.0.0.1 and 192.168.xxx.xxx to goto one page and all other visitors to goto another? [/snip] Yes, there is. $_SERVER['REFERER'] will give you the referer mosy of the time. More info from TFM can be found here; http://us3.php.net/reserved.variables Header can then be used to redirect header(Location: http://www.example.com/;); /* Redirect browser */. More info from TFM can be found here; http://us3.php.net/header snip from TFM 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. notice the last 7 words -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 1 ip address go here all others go here
Oops... REMOTE_ADDR should have been used. Ray Hauge wrote: That would be something along the lines of: preg_match(/^192\.168/,$_SERVER['REMOTE_HOST']); I'm a little rusty on my regex, but that should do it. Dave Carrera wrote: i know about $_SERVER['REMOTE_HOST'] but i think i should of said how do i compare any address starting with 192.168. sorry if my first question was to vague David Grant wrote: Try $_SERVER['REMOTE_HOST'] instead of REFERER. Dave Carrera wrote: Jay Blanchard wrote: [snip] Is there a way of sending users with a local ip address say 127.0.0.1 and 192.168.xxx.xxx to goto one page and all other visitors to goto another? [/snip] Yes, there is. $_SERVER['REFERER'] will give you the referer mosy of the time. More info from TFM can be found here; http://us3.php.net/reserved.variables Header can then be used to redirect header(Location: http://www.example.com/;); /* Redirect browser */. More info from TFM can be found here; http://us3.php.net/header snip from TFM 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. notice the last 7 words -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] encrypt and dcrypt
I think base64 would work for you. http://us3.php.net/manual/en/function.base64-encode.php http://us3.php.net/manual/en/function.base64-decode.php Ray ganu wrote: Hi , I want a function like md5() by which I can encrypt a code and again when I need from db i can dcrypt also. but in md5() this func. is not there. I can not go in reverse way. I want to use it both the ways. Help me , 10x. (Thnx.)... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can anyone recommend a hosting company
I use SiteFlip. Their prices are really low, and they offer quite a bit. www.siteflip.com Affiliates have some special discount prices as low as $11.40/yr for 250 MB space, 5GB transfer, 1 domain (you register it), PHP, MySQL, and more (no setup fees). http://affiliates.siteflip.com Jose Miguel wrote: Try browsing the forums webhostingtalk.com, they have some pretty good reviews about several hosting companys. On 12/16/05, Marty [EMAIL PROTECTED] wrote: Can anyone recommend a fair priced, reliable hosting company that would best meet my needs as follows: Shared plan with PHP Windows server Mssql Need to host multiple domains under one account. thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jose Arce http://sinexion.com - http://josearce.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Write a FIFO file
I'm not sure, but it could have something to do with append mode instead of write mode. All I know about FIFO files and named pipes is that you cannot open them for read and write, only one or the other. The file system could detect append as reading when it's positioning your pointer at the end of the file. Robin Vickery wrote: On 12/20/05, Ruben Rubio Rey [EMAIL PROTECTED] wrote: Ok, I tried it before, it didn't work: [...] Try to execute it and execution never ends... browser is waiting for ever ... No errors in error php error log. Any ideas? I bet your script will finish as soon as you read from the other end - for example by doing 'cat fifo' from a shell. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to calculate with dates?
John Nichel wrote: Marten Lehmann wrote: Hello, I'm used to work with Date::Calc in Perl. How can I calculate with dates in PHP, like adding an hour or a year to a date? Regards Marten http://us3.php.net/mktime You could also use the PEAR Date package. I have used it in a few projects to help with manipulating dates. http://pear.php.net/package/Date -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] A curl question
I would suggest using the -d (or --data) flag. That allows you to send POST data. example: exec(curl -d name=Rafael%20Sagulaphone=3320780 http://www.where.com/guest.php) For more information, check the man page for cURL and search for POST within that document. Or check out the PHP Manual for the appropriate CURL syntax with LibCURL http://us3.php.net/manual/en/function.curl-init.php I have a script that uses the exec statement (was inherited from the last guy) and I'd be interested to know if libCURL makes the script wait on that line until CURL returns the result. Sometimes when getting data from a really slow site, scripts will take a lot longer than expected (10-15 minutes). I would assume that both ways would have the same effect, but efficiency is always king ;) HTH Ray Original Message Subject: [PHP] A curl question From: tedd [EMAIL PROTECTED] Date: Mon, January 02, 2006 9:07 am To: php-general@lists.php.net Hi: I've asked this question on the [EMAIL PROTECTED] list, but replies were few and didn't address the problem. Whereas, I've seen considerable discussion of curl on this list, so here goes. I am writing a client-side application that uses curl commands to communicate with a php application. At present I can send the php application logon, password, and variables via: curl -u userID:password --url http://mydomain.com/myApp.php?what=what That works! However, I would like to send the variables hidden instead of attached to the url. So, what would the curl command be? Many thanks for any suggestions or solutions. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] A curl question
I haven't tried it, so I don't know if -d doesn't work with -u, but if that is the case, you could change your URL to this: curl -d what=what http://user:[EMAIL PROTECTED]/myApp.php or try this: curl -u userID:password -d what=what --url http://www.mydomain.com/myApp.php; HTH Ray Original Message Subject: RE: [PHP] A curl question From: tedd [EMAIL PROTECTED] Date: Mon, January 02, 2006 5:50 pm To: php-general@lists.php.net Ray: I would suggest using the -d (or --data) flag. That allows you to send POST data. example: exec(curl -d name=Rafael%20Sagulaphone=3320780 http://www.where.com/guest.php) Yes, I understand -d -- is there a way to use that AND to provide userID and password? Thanks. tedd For more information, check the man page for cURL and search for POST within that document. Or check out the PHP Manual for the appropriate CURL syntax with LibCURL http://us3.php.net/manual/en/function.curl-init.php I have a script that uses the exec statement (was inherited from the last guy) and I'd be interested to know if libCURL makes the script wait on that line until CURL returns the result. Sometimes when getting data from a really slow site, scripts will take a lot longer than expected (10-15 minutes). I would assume that both ways would have the same effect, but efficiency is always king ;) HTH Ray Original Message Subject: [PHP] A curl question From: tedd [EMAIL PROTECTED] Date: Mon, January 02, 2006 9:07 am To: php-general@lists.php.net Hi: I've asked this question on the [EMAIL PROTECTED] list, but replies were few and didn't address the problem. Whereas, I've seen considerable discussion of curl on this list, so here goes. I am writing a client-side application that uses curl commands to communicate with a php application. At present I can send the php application logon, password, and variables via: curl -u userID:password --url http://mydomain.com/myApp.php?what=what That works! However, I would like to send the variables hidden instead of attached to the url. So, what would the curl command be? Many thanks for any suggestions or solutions. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Curl Question
Hello everyone, I just wanted to see if anyone knew if there was any difference in performance between using curl in an exec() statement and when using the libCurl functions within PHP. Thanks, Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Curl Question
Thanks for the info! Manuel Lemos wrote: Hello, on 01/03/2006 06:52 PM Ray Hauge said the following: I just wanted to see if anyone knew if there was any difference in performance between using curl in an exec() statement and when using the libCurl functions within PHP. Executing a separate program should be a little slower as it adds some overhead before executing a request. Actually, in some cases it can be a little faster to use fsockopen instead of libcurl as it is one less library to load. You may also want to take a look at this HTTP client class that uses fsockopen everytime it is possible and only uses libcurl functions in certain cases. This class takes care of cookie handling, redirection, form posting, file uploading, etc.. http://www.phpclasses.org/httpclient -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Access Client IP address
$_SERVER['REMOTE_ADDR'] http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server HTH Nilanjan Dasgupta wrote: Hi, Is there any way to client's IP address inside a php document. I am trying to generate a code that depends on the IP address of the client. thanks a lot, Nilanjan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Floating numbers truncating to two digits without rounding
On Monday 09 January 2006 03:20 pm, Mark Steudel wrote: I am calculating things like tax and want to format them so they only have 2 digits past the decimal point. I've been using sprintf but just noticed that it tends to round up. I want the same functionlity without rounding. Thanks You could try number_format() though I haven't looked to see if it rounds up or not. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services http://www.americanstudentloan.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Apache2 PHP Downloadin Code
Hello everyone, I'm having some problems with one of our servers. Recently Plesk overwrote our configuration file, and I'm trying to get the thing back online. To make a long story short, I've got PHP working with http, but now that I've got the https virtual host set up, php doesn't work with it. Instead apache just sends a file download request to the client, so I can download the entire source code, instead of viewing the results from PHP. Has anyone run into an issue like this? It's just so odd that the HTTP virtual host works just fine, but the HTTPS virtual host does not. I've got all the appropriate: LoadModule php4_module modules/libphp4.so AddHandler php-script php AddType application/x-httpd-php .php .php4 .php3 .phtml .inc DirectoryIndex index.php index.php3 in the php.conf file. I don't think I have to specify to turn the PHP engine on in the HTTPS virtual host, do I? Thanks for any help, Ray Hauge -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php