Re: [PHP] E-Mail Attachment Filename Encoding Problem
On Tue, 2009-02-17 at 10:19 +, Richard Heyes wrote: There's no reason not to use it - it works for a good many people. And a few cats too. The *other* white meat? -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
On Tue, Feb 17, 2009 at 12:27:58PM +, Stuart wrote: 2009/2/17 Paul M Foster pa...@quillandmouse.com: On Mon, Feb 16, 2009 at 08:34:22PM +, Stuart wrote: snip This is your problem, you're not understanding where the paths are being resolved. Apache has absolutely no involvement in resolving relative paths in your HTML files to absolute URLs. The browser does this. All you need to do is use absolute URLs and everything will work fine. By absolute, in case you don't know, I mean starting with a / and being from the document root in the web server. FWIW, I've been doing computers since before the CP/M days (pre-pre-DOS), so I do know the difference between absolute and relative paths. FWIW I've been doing computers for a long time also, and am well aware of CP/M. Based on what you said it didn't appear that you did know the difference, but I apologise for the mistake. I'm sure if you look at the URLs being requested by the browser it should be pretty clear that it's simply adding the paths you have in your HTML to the end of the existing URL. The fact that you didn't appear to have seen that informed my assumption. Well, the only way I know this is to look at the Apache logs. I was getting a lot of 3xx and 4xx errors (which don't show up directly in the browser), and looking at the requests, it appears that the browser is indeed dictating the place to find images, etc., based on the odd URL. I'm a little doubtful about the browser specifying things like the URLs for links within a HTML page. However, this would explain why there are separate entries for image fetches in the Apache logs, occurring after the main page has been requested. Do you have some reference for this? I'd like to read more about the server-client interaction in depth. I couldn't find any references so I wrote a quick overview of what the process is. Note that this is over-simplified but should get the basic process across. * Browser connects to the HTTP server on www.google.com and requests / * Server resolves / to a resource, commonly an HTML file, PHP script or whatever, processes it if necessary and sends the output back to the browser. * Browser receives the HTML content, parses it, builds a list of referenced URLs (images, scripts, stylesheets, etc) * Browser normalises each referenced URL according to a fairly simple set of rules... If the URL is not already in the form scheme://... If the URL does not start with a / // The URL is relative to the current location If current_url ends with / URL = current_url + URL Else URL = dirname(current_url) + '/' + URL Fi Else // The URL is absolute on the current domain // current_domain is everything needed to hit the same web server, so scheme://[[username]:passw...@]domain.com URL = current_domain + URL Fi Else // URL is already absolute, including the scheme, domain name, etc Fi * Browser then (usually) fires off a couple of threads to request the additional URLs, renders the page and executes any scripts it contains. The server has absolutely no involvement in resolving referenced URLs to complete URLs - this is all done by the browser. HTTP is stateless to the extreme, meaning that each request gets a single resource, even if they're done through the same connection. Hope that makes it clearer. Thanks for the summary. snip So specifying absolute links might be a bit much. I'm not happy with the way DW handles this stuff, but I have to strike a balance between my vim-handcoding-command-line method and my wife's click-and-drag-gotta-be-GUI method. We've covered this in the other thread. I can't speak for DW since I've only ever used it as a text editor, and even then only when forced, but I would be surprised if you couldn't tell it to generate absolute URLs. Something I do know is that you can set it up to automatically deploy to a separate virtual host on your development server, but based on the other thread you've already made a decision on how to solve your problem. I leave Dreamweaver issues to my wife. She maintains she can manually type in the link URLs, but that's really not a good ongoing paradigm. Now, if Dreamweaver had a config setting that said, Make all URLs absolute, I'd say that's the best resolution. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
On Tue, Feb 17, 2009 at 11:22:32AM +, Stuart wrote: 2009/2/17 Paul M Foster pa...@quillandmouse.com: snip Maintaining identical development, staging and live environments is one of the key components of reliable, repeatable and streamlined development, testing and deployment, but if you're happy with what you've got then by all means continue as before. I was just offering a best practice suggestion that would solve your current problem and likely some you'll encounter in the future. All agreed. That is the safest alternative. Will I do it that way? Not so much. Yes, I know I reap the consequences. snip Most DHCP servers can reserve an IP address for a specific MAC address such that that IP always gets given to that NIC. Actually, that's what happens in this case. But I could change that IP one day and forget to hack the hosts file. I prefer to treat it as non-fixed. snip Really, Stuart, you should try not to be so annoyed at people who don't appear to know as much as you believe you do. ;-} I'm not annoyed, I'm mildly frustrated. You did not respond to my initial suggestion in the other thread but continued to discuss the problem with others. I apologise if my tone came across as annoyed, but it's polite to respond to others when they communicate with you. All this because I didn't answer you on another thread? Wow. I typically don't reply to suggestions whose nature I'm already aware of as an alternative. Sorry about that. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How should I ....--its a date/timestamp issue
On Tue, Feb 17, 2009 at 03:55:16PM -0600, Terion Miller wrote: What are your suggestions folks on how to go about setting a date on a form so that a user can not set a start date prior to the current days date? I've been looking around php.net but is it a javascript thing in the validation I should be dealing with, basically as it is I have a form and a user can select a start date, but they should not be able to select a date that is past, currently the start date form is a drop down (a very long drop down) I would like to use one of those nifty calendar popups but am not sure (aka..wasn't able to figure out) how to send the date to the db fields as they are... guidance on this would be great ..how would you do it? thanks guys and gals Terion Broadly, you're either going to have to limit their choices going in to the form (limit the choices in the drop-down box), or validate it afterwards and generate an error message if it's wrong. I've never seen one of those calendar gizmos that wasn't Javascript, except maybe for Ashley's (mentioned in another thread). And even at that, a PHP one won't be selectable the way you want unless you put radio buttons next to all the dates. And after all that, you'd still have to do some pre-processing of it to limit selections to current date and later. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Full versus relative URLs
Here's a question related to my last post. When specifying a link in a HTML file (like to the css or an image file), there are two ways of doing it. One is to simply include the relative path to the file (relative to the doc root), like: /graphics/my_portrait.gif Or you can include the full URL, like: http://example.com/graphics/my_portrait.gif My casual observation seems to indicate that the former will load faster than the latter. But has anyone done any benchmarking on it? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
On Mon, Feb 16, 2009 at 07:30:57PM +0200, Thodoris wrote: I'm submitting a url like this: http://mysite.com/index.php/alfa/bravo/charlie/delta The index.php calls has code to decode the url segments (alfa/bravo/charlie/delta). It determines that the controller is alfa, the method is bravo, and converts charlie and delta to $_GET['charlie'] = 'delta'. It verifies that the controller and method exist, and calls the controller and method. This works fine. The right controller gets called and the right method, and the GET parameter looks like it should. The method sets some variables and then calls a render() function to render the page, which is in the doc root of the site. The page does get rendered, but without the stylesheet, and none of the graphics show up. Why? Because, according to the logs, Apache appears to be looking for the images and everything else in the directory index.php/alfa/bravo/charlie/delta, which of course doesn't exist. No, I don't have an .htaccess file with RewriteEngine on. Apache figures out that index.php is the file to look for in the original URL, but can't figure out that everything else is relative to that file, not the entire URL. This method is in use in at least one other MVC framework. What am I doing wrong? Paul I assume that in order for this to work you will have to use mod_rewrite for apache to work properly. Check the framework's installation instructions to see if you configured mod_rewrite correctly for this to work properly. mod_rewrite isn't involved. Apache has a lookback feature that looks back through the URL until it finds an actual file it can execute, which in this case is index.php. Unfortunately, it appears that Apache believes the directory in which linked files are found is the *whole* URL. mod_rewrite might resolve this, but it isn't allowed on all servers. So it's not a reliable solution. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
On Mon, Feb 16, 2009 at 07:39:29PM +0200, Thodoris wrote: Here's a question related to my last post. When specifying a link in a HTML file (like to the css or an image file), there are two ways of doing it. One is to simply include the relative path to the file (relative to the doc root), like: /graphics/my_portrait.gif Or you can include the full URL, like: http://example.com/graphics/my_portrait.gif My casual observation seems to indicate that the former will load faster than the latter. But has anyone done any benchmarking on it? Paul I am not aware if absolute URLs are faster or not (in case they are there will be such a small difference you cannot probably notice) but IMHO it is a bad practice to use full URLs. Basically because renaming directories or scripts will cause great pain in the ass. Of course resources that are coming outside your own site are needed to use absolute URLs and nobody is assuming that are useless. Agreed. But here's the real reason, in my case. We develop the pages on an internal server, which has the URL http://pokey/mysite.com. When we move the pages to the live server at mysite.com, all the URLs would have to be rewritten. Ugh. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
On Mon, Feb 16, 2009 at 08:09:51PM +0200, Dotan Cohen wrote: Agreed. But here's the real reason, in my case. We develop the pages on an internal server, which has the URL http://pokey/mysite.com. When we move the pages to the live server at mysite.com, all the URLs would have to be rewritten. Ugh. Paul So put it all in one place: ?php include path.inc; printa href=\$path/dir/file.php\; ? Full URLs don't break when users save the pages to disk. That would be fine if the pages weren't being crafted in Dreamweaver, where inserting links like that is a pain. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
On Mon, Feb 16, 2009 at 08:53:24PM +, Ashley Sheridan wrote: snip I've read through this thread and not noticed anyone mention the base tag. This allows you to specify a URL to which relative ones are mapped to, which could be just what you're looking for, as I believe all the browsers support it (the tag has been around for donkeys years, so I'd be surprised if any browsers didn't support it) You da man! I've never heard of this tag, but it shows up on my Visibone cheatbook, and my HTML 4 reference. Moreover, it works. When the URL in the base tag is specified as: base href=http://mysite.com/; and, for example, a graphic link is done this way: img src=graphics/myportrait.gif It appears to override other considerations with regard to pathing. I've already chosen an alternative solution, but I'll definitely keep this in mind for future reference. Thanks, much. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
On Mon, Feb 16, 2009 at 08:34:22PM +, Stuart wrote: snip This is your problem, you're not understanding where the paths are being resolved. Apache has absolutely no involvement in resolving relative paths in your HTML files to absolute URLs. The browser does this. All you need to do is use absolute URLs and everything will work fine. By absolute, in case you don't know, I mean starting with a / and being from the document root in the web server. FWIW, I've been doing computers since before the CP/M days (pre-pre-DOS), so I do know the difference between absolute and relative paths. I'm a little doubtful about the browser specifying things like the URLs for links within a HTML page. However, this would explain why there are separate entries for image fetches in the Apache logs, occurring after the main page has been requested. Do you have some reference for this? I'd like to read more about the server-client interaction in depth. For example, if you have a tag like a href=arse.phparse/a and arse.php is in the same directory as index.php you need to change it to a href=/arse.phparse/a. Another example... if you have a href=somedir/crack.phpcrack/a where crack.php is in the subdirectory somedir beneath where index.php is you need to change the tag to a href=/somedir/crack.phpcrack/a. You need to apply this to all URLs in your code, including stylesheets, images and javascript references. This should not be a difficult concept to grasp, so maybe I'm not explaining it right. If so please explain what you understand by what I'm saying and I can alter it to be more helpful. Here's the issue I have with this: normally I build pages on the fly with PHP. However, on this particular project, my wife is building the pages in Dreamweaver. And, as I mentioned before, while in development, the pages reside on an internal server, like this: http://pokey/example.com That is, pokey is an internal Debian machine where all our client sites reside as backups in the /var/www directory. So as far as pokey is concerned, the pages are at: /var/www/example.com but we see it as: http://pokey/example.com Dreamweaver has a very brain dead way of handling templates, resultant pages, and the internal page links. And while my wife is very savvy, her Windows-weenie-Dreamweaver way of handling links is to click on a button which opens a dialog box, in which she finds the image, and clicks Okay. This is all fine while the pages are on the development server. (Well, not really, since Dreamweaver regularly hacks up image links in non-intuitive ways.) But when they get uploaded to the production server on the internet, all those absolute links have to change from: http://pokey/example.com/graphics/myportrait.gif or /example.com/graphics/myportrait.gif to http://example.com/graphics/myportrait.gif or /graphics/myportrait.gif Moreover, I'm not even sure she can specify the links absolutely when doing her Click and Search routine. She'd probably have to manually type them in, unless there's some setting in Dreamweaver I don't know about. In any case, changing absolute links in development pages to absolute links in production pages would involve a heap of (dangerous) global search-and-replace magic. So specifying absolute links might be a bit much. I'm not happy with the way DW handles this stuff, but I have to strike a balance between my vim-handcoding-command-line method and my wife's click-and-drag-gotta-be-GUI method. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
On Mon, Feb 16, 2009 at 08:49:06PM +, Stuart wrote: 2009/2/16 Paul M Foster pa...@quillandmouse.com: snip Agreed. But here's the real reason, in my case. We develop the pages on an internal server, which has the URL http://pokey/mysite.com. When we move the pages to the live server at mysite.com, all the URLs would have to be rewritten. Ugh. My advice would be to stop coding and sort this out as soon as possible. You think? ;-} If your development server has a different layout to your live server you're simply asking for trouble, especially since you're using a front controller pattern (as evidenced in another thread). Not so much. We've structured our backups and live servers this way for a number of years without incident. Paqes for clients are normally statically built in Dreamweaver, with possibly a modicum of PHP to handle forms. Internal company pages are built by me and reside only on internal servers. This is the first client project where we're using a front controller, etc. It's simple to fix this. Add a hosts entry for mysite.local pointing at pokey's IP. Change the server software so it has a virtual host for mysite.local pointed at the mysite.com directory in the existing web rooot. Which works up until the point where you go live with the site, and forget to revert the hosts file, so you can't get to the live site. And after you do revert the hosts file, you again have the same problem with the base URL for the production site being different from the development/backup site. Virtual hosting is beyond my Apache expertise, and again, would mask live sites we host. In addition, pokey's IP is not exactly fixed. It's served up by DHCP from an internal DHCP server. It's generally the same, but I wouldn't want to rely on that in a hosts file. This is not difficult and will allow you to solve both of the problems you are currently asking this list about. Actually, Ashley's base tag solution resolves the problem. However, I've moved on and dropped the front controller concept for this project. Instead, I'm opting for a snippet of PHP at the beginning of every static page built in DW which calls in the values necessary to populate the sidebars of the pages. Really, Stuart, you should try not to be so annoyed at people who don't appear to know as much as you believe you do. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Apache odd behavior
I'm submitting a url like this: http://mysite.com/index.php/alfa/bravo/charlie/delta The index.php calls has code to decode the url segments (alfa/bravo/charlie/delta). It determines that the controller is alfa, the method is bravo, and converts charlie and delta to $_GET['charlie'] = 'delta'. It verifies that the controller and method exist, and calls the controller and method. This works fine. The right controller gets called and the right method, and the GET parameter looks like it should. The method sets some variables and then calls a render() function to render the page, which is in the doc root of the site. The page does get rendered, but without the stylesheet, and none of the graphics show up. Why? Because, according to the logs, Apache appears to be looking for the images and everything else in the directory index.php/alfa/bravo/charlie/delta, which of course doesn't exist. No, I don't have an .htaccess file with RewriteEngine on. Apache figures out that index.php is the file to look for in the original URL, but can't figure out that everything else is relative to that file, not the entire URL. This method is in use in at least one other MVC framework. What am I doing wrong? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execute EXE with variables
On Fri, Feb 13, 2009 at 02:30:38PM -0500, Dan Shirah wrote: Hello all, Can someone point me in the right direction? I'm trying to call an EXE from PHP and pass it two variables. I looked at the exec() command and I see that this can call the executable, but I don't see that it can pass the variables to it. Use the system() command, and enclose both your command and its parameters in a pair of single quotes, as: system('mycmd -a alfa -b bravo'); Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? I don't know Java, but I suspect it's a more purely OO language than C++. I *have* coded in C++, and the OO aspects of C++ are like a bolt-on on the C language. There are some odd aspects of C++ because of its history as originally a preprocessor hack on top of C. PHP is *not* a good example for OO. There are a lot of OO principles it doesn't follow. I would have suggested Smalltalk, the original OO language, except that no one uses it any more, and other languages don't necessarily fully implement OO as done in Smalltalk. You're right about using a language which implements OO in a realistic way for today's programmers. I also agree you need a language in which to teach OO. Otherwise, this is all just theory, and won't stick with the students. Imagine learning algebra but never solving equations in the class. You'd forget the whole thing ten minutes after the class was over. In fact, it seems a little backward to teach OO programming as a lone subject. I would instead opt for teaching a language first, and OO as a secondary part of that course. Learning C++ will go a long way in assisting the student to learn Java, or vice versa. My experience programming C has been invaluable in coding under PHP. As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
On Sun, Feb 08, 2009 at 03:20:48PM -0500, tedd wrote: At 3:54 PM + 2/8/09, Stuart wrote: 2009/2/8 tedd tedd.sperl...@gmail.com: I wasn't able to find a lot of information, but here's a useful link: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Tedd, that's a list of programming languages, not web development languages. The list shows php, javascript, ruby, and perl -- are those NOT web development languages?!? - I have no doubt that C# + VB accounts for more development in the world than PHP. Both are used extensively in non-web development whereas PHP is not. If you find any information of the numbers of php users out there, please let me know. When you consider how such a thing would be measured it won't take long to realise why the number is not available. You have to bear in mind non-public use which will not be insignificant, servers where PHP is not advertised and a multitude of other reasons why any number you could come up with *will* be wrong, and therefore pretty useless. Why anyone would see value in such a number is beyond me. IMHO the community that exists around it and the number of jobs out there requiring PHP should be enough to convince anyone that it's not an insignificant player. -Stuart I guess I'm not all that bright. To me a programming language is a programming language regardless of platform or purpose -- that was so when I was programming FORTRAN on Phoenix I, or Applesoft on Apple ]['s, or postscript on HI's; or ANSI C on Alphas, or FutureBasic and C/C++ on Macs, or PHP on Apache, or Javascript on IE -- they are all the same to me. I'm just trying to get a handle on the number of people who program in php -- what's wrong with wanting to know that figure? Look, I teach at the local college and am trying to get PHP/MySQL courses to be taught there. I have superiors who are asking How does PHP stack up against ASP? which the college teaches AS THE web development language. I really can't go back to them and say Well, everyone just *knows* PHP is a significant player -- that's not proof. Perhaps a better question then might be how many IIS servers are there out there compared to Apache. Apache servers uniformly support PHP, but I think only IIS servers support ASP (I could be wrong). There's also the FOSS argument. I'm continually surprised the pinheads in academia don't see the value of FOSS compared to being beholden to huge corporate behemoths like Microsoft. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class constant inconsistency
On Sun, Feb 08, 2009 at 08:04:19PM -0800, leledumbo wrote: I've read the docs about class constants and found some inconsistency (at least according to my knowledge), namely in the following statement: The value must be a constant expression, not (for example) a variable, a class member, result of a mathematical operation or a function call. Questions: Can't result of a mathematical operation be a constant expression? What is the answer of 1 + (2 - 3) * 4 / 5? Does it depend on a value that can't be determined immediately (i.e. variable)? In the name of maintainability, we do need mathematical operation as constant expression (based on true story). For example, see the following code: // constants used to add log entry // authentication related const action_login = 1; const action_logout = action_login + 1; // sco related const action_create_sco = action_logout + 1; const action_search_sco = action_create_sco + 1; const action_list_sco = action_create_sco + 2; const action_edit_sco = action_create_sco + 3; const action_delete_sco = action_create_sco + 4; // eLesson related const action_create_lesson = action_delete_sco+ 1; const action_search_lesson = action_create_lesson + 1; const action_list_lesson= action_create_lesson + 2; const action_edit_lesson= action_create_lesson + 3; const action_delete_lesson = action_create_lesson + 4; const action_export_lesson = action_create_lesson + 5; const action_import_lesson = action_create_lesson + 6; // eCourse related const action_create_course = action_import_lesson + 1; const action_search_course = action_create_course + 2; const action_list_course= action_create_course + 3; const action_edit_course= action_create_course + 4; const action_delete_course = action_create_course + 5; const action_export_course = action_create_course + 6; const action_import_course = action_create_course + 7; const action_play_course= action_create_course + 8; // profile related const action_edit_profile = action_play_course + 1; const action_edit_password = action_edit_profile + 1; Does any of them results in a non-constant expression? Well, I can easily subtitute each value by hand. But what if I forget to add one (enough to get you frustrated) that should be inserted as the second entry? I need to adjust the other 23 (there are 24 of them) by hand! Using above code, I only need to adjust action_logout to action_login + 2 and everyone's happy. In case anybody has a solution without altering the implementation, please tell me. I'm not a PHP master so I might be coding it in the wrong way. Please don't suggest define() since it has global scope (i.e. no encapsulation). P.S.: I think this should work also for other constant expression (e.g. string), like: Hello . World Since the behavior of PHP is dictated to be this way by the designers (and may not change in the near future or ever), you could solve this another way. Make these constants into class variables. You could even make them static if you like. No, it's not as clean as having them be constants, and you'd have to type $this- before using them, but it's an alternative, in case you hadn't thought of it. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] long echo statement performance question
On Fri, Feb 06, 2009 at 01:09:13PM -0500, Eric Butera wrote: On Fri, Feb 6, 2009 at 12:15 PM, Bruno Fajardo bsfaja...@gmail.com wrote: In my opinion, you would achieve better results using a template engine, like Smarty (http://www.smarty.net/). In addition, your code would be entirely separated from presentation in a elegant way. snip In a thread about performance you suggest Smarty? Really? :D You know, I was gonna say something about that, but I figure I've complained enough on list. I agree, though. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variables
I'm not too clear on HTTP headers, cookies, and such. So here are questions related to that. Let's say I generate a random number that I want the user to enter in a form. When I generate the number, I store it in a session variable ($_SESSION). When the user submits the form, I check the number they enter with what I've stored in the session variable. Since this session variable survives across page loads (assuming session_start() is appropriately called), how is it stored and recalled? Is it automatically stored as a cookie on the user's system? Or is it stored on the server? And how does a server get a cookie? Is it a separate request made by the server to the client? If the value I've asked the user for is *not* stored as a cookie, then is it passed as part of the HTTP submission or what? Thanks for any enlightenment on this. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Blank page of hell..what to look for
On Thu, Feb 05, 2009 at 11:11:03AM -0600, Terion Miller wrote: Speaking of IDE, which do people on here prefer, I have been using Dreamweaver CS3 just because as originally a designer I was/am used to it... I did finally find the problem but moving an echo(damnit); from line to line commenting out everything below it...Oi ...is this ever going to get easier for me I often wonder... Use Vim. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Garbage Collection
On Thu, Feb 05, 2009 at 02:48:14PM -0500, tedd wrote: At 7:03 PM + 2/5/09, Nathan Rixham wrote: IMHO forget the active flag, replace it with a field deleted which is a timestamp, then you've got an audit trail of when the it was removed :) infact often seen three fields on every table, inserted, updated and deleted all timestamps and self explanatory. Nathan: As usual, you (and others on this list) have clarity on this. I think I'll go your route except I'll have a date created and date inactive field but not a date updated field. In this situation there would never be a reason for an update. After all, the tutor_course record is created when an assignment is made -- when the assignment is broken, then the record becomes inactive. So, there's no reason to update. Do, or don't do, there is no try. -- Yoda Actually, if I needed a history, I wouldn't do it with timestamp fields in the table. I'd build a new file that contained the history. Maybe when timestamp operation char(1) what char(1) which id Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Connect local app to a web app
On Thu, Feb 05, 2009 at 05:24:45PM -0200, Jônatas Zechim wrote: Hi there, i'm here again, but now with another doubt. What's the best way to connect a local app write in php or php-gtk to a web app writen in php. The database is MySql, and i need to do this connection every 3s to check data, get the data back and save into localhost database. If you have control of the server, you can just set this up in a bash script, using mysql commands, which connect to the remote and then then local databases. I'm talking about cron running the script periodically. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DB Comparisons
On Thu, Feb 05, 2009 at 12:36:02PM -0800, revDAVE wrote: Hi Folks, I¹m curious if there are any previous discussions / Articles / URL¹s that compare the power and scalability of MySQL (with php) with other technologies like MS sequel server oracle - coldfusion etc I imagine that most middleware like php / asp / coldfusion is relatively good fast - (let me know if one is better ).Mostly I¹m concerned with the speed and power of the backend database as to how it functions on an enterprise scale such as how many hits it can handle per hour how many users before it starts to slow down etc. I don't know what backing DMBS Coldfusion uses, but Coldfusion requires server support of a proprietary nature. Likewise, MSSQL is a proprietary product, and I doubt it has the performance characteristics you need. In case it wasn't clear, I would always opt for an Open Source solution before any proprietary one. The arguments are well known. MySQL is not an enterprise database. And its most useful database types are owned by a large corporation which isn't entirely friendly towards the Open Source movement. It's only recently that MySQL has acquired some of the characteristics of enterprise DBMSes. For the longest time, MySQL relied on the programmer to handle his/her own foreign keys and such. It is very fast, and very suitable for web databases. And it has widespread API support in other languages. PostgreSQL *is* an enterprise database. It was designed from the beginning by DBAs, not programmers as MySQL was. It is comparable in performance to Oracle and MySQL, though this depends on the types of queries you're doing. But it has full transactional support, foreign keys, insert appropriate DBMS marketroid terms here. And of course, it it not owned by a company and is fully Open Source. Feel free to flame me about this. I did a survey years ago before selecting PostgreSQL as our internal company DBMS. I've tracked the comparisons over the years, when PostgreSQL lagged in speed behind MySQL and seen PostgreSQL speed up. And I've seen MySQL add full-fledged DBMS features. So their capabilities have come closer and closer together. But I believe PostgreSQL is still the superior choice for an *enterprise* DBMS. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preserving History
On Thu, Feb 05, 2009 at 04:38:25PM -0500, tedd wrote: Hi gang: To further the Garbage Collection thread on to another level (i.e., preserving history) please consider this: Okay, let's say we have a table containing all the instances of tutors teaching courses. A record might look like this: Course-to-Tutor table course_id = 123 tutor_id = 7 date_active = 2/4/9 date_inactive = null The above record was assembled from the following recrods: Tutor table: id = 7 name = joe Course table: id = 123 title = Introduction to Moonshine Okay, so let's now delete the course Introduction to Moonshine! At the first opportunity to search the Course-to-Tutor table we find that the course 123 is now absent from our database and as such we set the date_inactive field -- it won't be considered again. Okay, so what does that tell us about the history? It only provides that at one time joe taught an undefined course. Furthermore, if joe quits, then we only have a record that says someone with an id of 7 taught a course with an id of 123 -- that doesn't make much sense, does it? No. If you're concerned about history, leave the course and tutor records in place. Simply change record in the Course-to-Tutor table. Set the date_inactive field to today's date or whatever. If you're concerned about history, you never delete the records that contribute to a link table. You can delete the record that binds them together in the link table, but not if you want to preserve history. Now, if we reconsider the Course-to-Tutor table and instead of putting in the tutor_id and course_id, we put in the actual name of the tutor and title of the class, then at least we have a history that makes sense. Don't do this. Your searches and indexes will take longer and it will complicate things. Maintain your primary keys as integers. If you want to know the name of the guy who taught course ID 123 from this date to that date, just issue a query which joins the tables. As long as your data is somewhere in these tables (in *one* place, please), you can join tables in a query and get any info you want. However by doing that, we violate the primary principle of a relational database by creating redundant data. While this is true in the ideal world of Codd, in the real world, there is often some minor duplication of data. But in your case, it isn't needed. I guess that one can say that if we never actually delete the tutor nor the course, but instead just make them inactive as well, then we have solved the problem -- is that the answer? In any event, what problems do you foresee if I used the actual names and titles for the Course-to-Tutor table instead of their id's? After all, the instance records would retain a simple history of what happened regardless of deletions AND a search for Introduction to Moonshine should be essentially as fast as a search for 123 if both fields are indexed, am I right or wrong? Not necessarily. In fact, if you add on to this schema, you'll ultimately find that IDs are vastly easier to manage. They make the queries more complex, but the tables are easier to manage. Trust me on this. I've had to go back and redesign tables where I used a long string like a name for the index, and it's generally a bad idea. I expect most DBAs and programmers will agree. Oh, here's another *excellent* reason not to use names: fat fingers. If someone misspells a name or a course title, you can change it to your heart's content if it's just a field in a table. But if it's a key that binds tables together, you can't change it without cascading problems. That key is now in *at least* two places and must be changed *everywhere*, and the DBMS normally won't let you do that. You could add cascade update provisions into your tables, but why? Just use an integer key, and you're away. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require() causing strange characters ?
On Fri, Feb 06, 2009 at 06:34:41AM +0100, cr.vege...@gmail.com wrote: Hi all, I have a script called test.php: ?php echo C; require(echo.php); echo D; ? and a script called echo.php: ?php echo test; ? With IE and Firefox it shows: CtestD but when I view the source, it seems to be: C??testD When debugging it, it seems that: C???testD has length 9 in stead of 6 pos1 has char=C ord=67 pos2 has char=??? ord=239 pos3 has char=??? ord=187 pos4 has char=??? ord=191 rest okay ... Any idea what's causing this and how to solve it ? I don't know about the odd characters. You might try include() instead of require() and see if the behavior changes. I've noticed that Apache tends to insert an unpredictable number of spaces in code when PHP is embedded in the HTML. My best guess is that Apache substitutes blanks for all the non-printing PHP code in the file. But that's just a guess. How exactly are you managing to obtain the page in such a way that you can test character codes and such? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Hidden costs of PHP arrays?
On Fri, Jan 30, 2009 at 11:10:16AM +1100, Clancy wrote: snip As a former assembly language programmer I have some idea of the vast amount of thumb twiddling which is going on behind-the-scenes when I make some apparently simple request like the one to get my phone number. Undoubtedly most of this occurs in the murky depths of the operating system, but if there were any simple way to avoid adding to it unnecessarily it would be nice to know about it. Ahhh, finally someone who understands this principle. There's simply no reason to waste cycles if you don't have to. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote: I am just learning PHP from the O'Reilly Learning PHP 5 book and I have a question regarding the formatting of text. Actually it is a couple of questions. First, when I use the \n and run the script from the command line it works great. When I run the same code in a browser it does not put the newline in and the text runs together. I know that I can use br/ to do the same thing, but why is it this way? Browser don't break lines on the \n character. They only break on br or p tags. That's just the way it is. You can use the PHP function nl2br() to insert br tags where the \n characters are. The second question is closely related to the first. When formatting text using printf the padding works great when running from the command line but not at all when in a browser. Browsers don't respect multiple spaces, etc., except in between certain tags, like pre/pre. Instead, they combine multiple spaces into a single space and break lines where they like, based on layout. You can use the HTML nbsp; character if you don't want lines or phrases to break at the whim of the browser. If you want exact layout (columns lined up, etc.), the simplest solution is to use HTML tables. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 02:40:55PM -0500, Stephen wrote: Paul M Foster wrote: If you want exact layout (columns lined up, etc.), the simplest solution is to use HTML tables. The horror. Do not use tables for layout. Use CSS. Especially now that Microsoft, just this week, is sending out IE 8 which seems to be fully CCS standards compliant. I'm happy to be a Luddite in this area. We've been doing websites for about ten years, and have yet to find it either simple or easy to get exact, gracefully-degrading layouts with CSS. (We use CSS for all kinds of nifty things, but not to line things up properly.) Hey, I've got an idea. If someone knows of one of these uber-web-design authorities who writes books touting the superiority of CSS over tables, have them write a book showing us all how it's done [easily]. I'll be first in line to buy it, because I agree that page layout is not the original proper use of tables. Paul PS: I have to snicker as well anytime Microsoft says they're compliant with *any* standard. Their history speaks for itself; why should we believe them now? -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 03:06:36PM -0500, Bastien Koert wrote: On Wed, Jan 28, 2009 at 2:58 PM, Don Collier dcoll...@collierclan.comwrote: On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote: I am just learning PHP from the O'Reilly Learning PHP 5 book and I have a question regarding the formatting of text. Actually it is a couple of questions. First, when I use the \n and run the script from the command line it works great. When I run the same code in a browser it does not put the newline in and the text runs together. I know that I can use br/ to do the same thing, but why is it this way? snip Thanks to everyone that responded. From what I am seeing in the responses if I plan on using php for command line scripts things get written one way. If, on the other hand, the php is written for a web page it gets written a slightly different way inserting html where necessary for formatting. snip Not quite true in a properly layered application. Separating the data from the display (whatever that is) is prime idea behind the MVC (Model View Controller) design pattern. This way your code that runs via the CLI (command line) can produce the same data as the code that gets the data for the HTML. The only difference is what you plan to do with that data. You could feed it to a controller and let the controller feed it to a View to render in a browser, or send it to a FileOutput class to create a file of the data for comsumption by another resource. See? This is what I'm talking about. *I* understand what you're saying, Don, and I agree. But this guy is just learning PHP from what is arguably not one of the best books on PHP (IMO). And you're throwing MVC at him. Let him master the subtleties of the language first, then we'll give him the MVC speech. Yes, I know, they should learn proper programming practices from the beginning, blah blah blah. But think back to the first programming language you ever learned, when you were first learning it. If someone had thrown stuff like this at you, would you have had a clue? I had enough trouble just learning the proper syntax and library routines for Dartmouth BASIC and Pascal, without having to deal with a lot of metaprogramming stuff. This is the problem when you get newbies asking questions on a list whose membership includes hardcore gurus. The gurus look at things in such a lofty way that answering simple questions at the level of a beginner sounds like a dissertation on the subtleties of Spanish art in the 1500s. Just my opinion. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 01:45:07PM -0700, Don Collier wrote: On that note, what would be a better book to learn from? I have always been a fan of the O'Reilly books, but I am open to differing flavors of kool-aid. One can never have too many resources. The book that sits on my desk and is incredibly dog-eared is _Programming PHP_, also from O'Reilly. The whole back section is a reference on all the PHP functions and some extensions. The front part of the book explains nearly everything about the language. There are some errata in the book, which I've pointed out to O'Reilly, and when in doubt I check the function documentation on the php.net site. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 03:33:19PM -0500, Ernie Kemp wrote: Is there any advantage to using CSS over table and would it be idea to go to past website and change them. If it works, don't fix it. If you want to take the time to figure out how to get those same layouts in CSS, have a blast. But as you can see here from other replies, tables are the simplest choice for a lot of people who work with web pages all the time. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 09:26:10PM +, Ashley Sheridan wrote: snip I use CSS as much as possible, and it's second nature to me now to design with CSS rather than tables, but the only area I find it quicker to use tables is when I design forms. I know I'm going to browser hell, but meh, I can deal with it! :p That's my problem. Almost all the stuff I do is actual tabular data, or forms. Of course, the header and side bars are built with CSS. But the interior data are usually in tables. I've got forms with 50-odd fields in them, and I completely dispair of trying to make it look as good in CSS as it does in tables. Even with tables, I had more experimenting and colspans than you can imagine. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
On Wed, Jan 28, 2009 at 11:41:31PM +, Nathan Rixham wrote: Paul M Foster wrote: On Wed, Jan 28, 2009 at 09:26:10PM +, Ashley Sheridan wrote: snip I use CSS as much as possible, and it's second nature to me now to design with CSS rather than tables, but the only area I find it quicker to use tables is when I design forms. I know I'm going to browser hell, but meh, I can deal with it! :p That's my problem. Almost all the stuff I do is actual tabular data, or forms. Of course, the header and side bars are built with CSS. But the interior data are usually in tables. I've got forms with 50-odd fields in them, and I completely dispair of trying to make it look as good in CSS as it does in tables. Even with tables, I had more experimenting and colspans than you can imagine. Paul see this is why i chant flex flex flex flex flex flex flex flex flex flex flex flex flex drumroll flx Oh, a proprietary protocol and set of tools meant to run on a proprietary platform, built by a company as rapacious as Microsoft, and whose applications can't be mined by search engines? Oh yeah, I'm there. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Programming general question
On Tue, Jan 27, 2009 at 05:18:35PM -0600, Terion Miller wrote: I googled this and didn't find an answer my question is how do you know when to use an object or array would an object just be 1 instance, and array is several things together ( I know infantile coder language I use..but I'm a baby still in this) Can someone explain objects and arrays in plain speak for me? An array is like in math, except that an array in PHP stores anything you like. It's just a bunch of them together. An object can also store a bunch of different things, but it also has methods, which are really just functions. An array won't actually *do* anything; you have to do things *to* it. An object can actually do stuff at your direction. Like: $kitchen-make_coffee('cream', 'sugar'); The object here is $kitchen, and you've told it to use its make_coffee() method, which does something or another. You can also make those methods private so that code outside the object can't see them. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote: Paul M Foster wrote: snip In case this has yet to be answered to your satisfaction... Your page will *have* to reload when the user presses the button, but the majority of content can look the same, except for the content you want to change. /snip This is absolutely not true. You can make the button call a PHP script with AJAX and just update the textbox. Check out: http://xajaxproject.org Please show me how *without Javascript* and *only with PHP* you can change the content on a page interactively as the user described *without* reloading the whole page. Xajax contains Javascript, which is how it manages this feat. For Pete's sake people, this is a *new* PHP user who wanted a *simple* solution to a relatively simple webpage problem. He's not looking for a Javascript solution, or a framework solution, or an OOP solution. He's not necessarily looking for a bulletproof, high security solution. He's a *new* PHP user. He just wants to figure out how to do this simple thing. Give him a *simple* answer. If you have to give him provisos about security, OOP, or Javascript afterward, fine. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
On Mon, Jan 26, 2009 at 12:53:55PM -0600, Micah Gersten wrote: Paul M Foster wrote: snip Please show me how *without Javascript* and *only with PHP* you can change the content on a page interactively as the user described *without* reloading the whole page. Xajax contains Javascript, which is how it manages this feat. For Pete's sake people, this is a *new* PHP user who wanted a *simple* solution to a relatively simple webpage problem. He's not looking for a Javascript solution, or a framework solution, or an OOP solution. He's not necessarily looking for a bulletproof, high security solution. He's a *new* PHP user. He just wants to figure out how to do this simple thing. Give him a *simple* answer. If you have to give him provisos about security, OOP, or Javascript afterward, fine. Paul I'm not saying that he should use it. I'm saying that *YOUR *claim was false. You should watch what you say. You said you *HAVE* to reload which is not true. I said nothing about without JavaScript. I agree that he shouldn't necessarily use that. That's why I snipped his stuff out and just quoted you. Since he asked the question on a *PHP* list, I assumed he wanted a *PHP* solution, not a Javascript one. I also assumed that the OP was not a Javascript programmer, since as a Javascript programmer, the solution should have been obvious in Javascript. Ergo, my statements were in the context of a *PHP* solution to his question. Moreover, his question indicated that he didn't understand some basic fundamentals of the PHP execution model. Throwing a framework or Javascript solution at him would have been like putting a 14 year old behind the wheel of a Ferrari. But fair warning to all list members and future newbies who post here: If you ask for a solution on *this* list, and you give indications that you're not familiar with how PHP works with HTTP and HTML, then I will give you a PHP-based solution, and avoid Javascript, Java, C, Perl, Python, Ruby, Ruby on Rails, .NET, C++, C#, ECMAScript, Algol, PL/1, assembler, APL, Fortran, COBOL, frameworks and other assorted odds and ends which *might* do what you want, but aren't what you asked for. (Of course, I might give you a LISP/Scheme solution, though. ;-) Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: New PHP User with a simple question
On Mon, Jan 19, 2009 at 04:45:08PM -0500, Christopher W wrote: Dear responders, I was not sure which post was the best to respond to all of you so I chose the original. I wanted to thank you all for taking the time to try and help answer my question. I truly appreciate it. For the record, I have a PHP book and I understand (I think) all the variables, functions, conditionals, loops, constants, etc. of PHP. My problem, with no computer programming to speak of, was putting those variables, functions, conditionals, loops, constants, etc. together to make it do things I was hoping to accomplish. I am hoping that with reading more tutorials, looking at other people's php files and lots of practicing I may one day get it. I am truly grateful for all the time all of you spent in trying to help. Glad you found a solution (from Kevin). Don't worry about the sniping on the list. A lot of programmer types can get prickly with each other about details. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
On Sun, Jan 25, 2009 at 02:40:08AM -0500, Christopher W wrote: Mr. Kubler, Thank you for the help. I have to admit, I am still in over my head, I think. Perhaps I should just stick to static pages... Anyway what I was attempting to do, in the full picture, was be able to just switch the text in the text area without actually changing pages. For example, if the user clicks About Us (from the home page)the page doesn't change, just the text (in the area I designated for text). Since I have never used php before (but have read some online and in books) what I was trying was: if ($page == home) {echo $home_text;} elseif ($page == about) {echo $about_text;} ... else {echo $error_text;} My problem is that I can't figure out how to get the link-click to assign the value to the variable. I didn't try any php for that end because I really didn't know where to begin. Perhaps I am just going about this the wrong way but from the extremely little I have learned about php, I thought that I could do it this way easily. Thanks for the replies and the help. I truly appreciate it. In case this has yet to be answered to your satisfaction... Your page will *have* to reload when the user presses the button, but the majority of content can look the same, except for the content you want to change. Let's say you've named the button section and its value is home as in: input type=text name=section value=home/ When the user presses the button, the form now shows the value of section as home. PHP knows this has occurred. So you can make any action occur by simply (in PHP): if ($_POST['section'] == 'home') { do_something(); } In your case, you want a section of your HTML page to display something else. So, wherever you want that content to be displayed in your HTML page, do this: ?php if ($_POST['section'] == 'home') { echo a bunch of text for home stuff; } ? The ?php thingie tells Apache to interpret the next part as PHP, and the ? part tells Apache that the PHP part is over. If you're using GET instead of POST for the form then change $_POST above to $_GET. Every item in a form yields a POST or GET variable which PHP can read, just as it did above. There are alternate ways to do this, but the above is probably the simplest for you. I recommend Programming PHP an O'Reilly book as a reference for the language. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
On Sun, Jan 25, 2009 at 02:29:50AM -0500, Christopher W wrote: Sorry, I am also new to the etiquette of these mail lists. Anyway what I was attempting to do, in the full picture, was be able to just switch the text in the text area without actually changing pages. For example, if the user clicks About Us (from the home page) the page doesn't change, just the text (in the area I designated for text). Since I have never used php before (but have read some online and in books) what I was trying was: if ($page == home) {echo $home_text;} elseif ($page == about) {echo $about_text;} ... else {echo $error_text;} My problem is that I can't figure out how to get the link-click to assign the value to the variable. I didn't try any php for that end because I really didn't know where to begin. Thanks for the replies and the help. I truly appreciate it. The reply I gave you earlier assumes you're doing this with a button, not a link. If you're doing it with a link, it's slightly different. But here's what you have to understand first: When you click on a link, you load a different (or the same) page. Period. Web pages run on the HTTP protocol, and one of the things about that protocol is that the server knows virtually nothing about the context in which it's loading a page. In other words, if you were on Page A and you go to Page B, the HTTP protocol ensures that the server has *almost* no idea of what you did on that page. There are some exceptions, two of which are GET and POST variables. If you did something on a form in the page you came from, then GET/POST variable will be visible to the server (and PHP) when you get to the next page. If the method on your form is post, as in: form action=index.php method=post then it will see POST variable. If you used the GET method instead, it will see GET variables. So if you want to communicate something to the next page you go to, you will need to do it using a GET variable. GET variables are visible in the navigation bar above your browser, and POST variables aren't. So let's assume you want content.php to show home stuff if the user was in index.php and pressed the home button. Then for the link the push, you can do this: a href=content.php?section=homeHome/a Note the ?section=home part on the end of the URL? That's a GET variable named section and it contains the contents home. When you construct the content.php page. Put in a variant section as I explained in the last email, except make sure it tests for the GET variable section, like: if ($_GET['section'] == 'home') ... If you've programmed in other languages, PHP is a little difficult to grasp, just because it has to deal with the HTTP protocol, and you're embedding PHP in HTML pages. Otherwise its syntax is almost completely C-like. HTH, Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL class. Thoughts?
On Wed, Jan 21, 2009 at 11:37:07AM -0600, Jay Moore wrote: This is a MySQL class I use and I wanted to get everyone's thoughts on how/if I can improve it. This is for MySQL only. I don't need to make it compatible with other databases. I'm curious what you all think. Thanks, Jay Class: -- ?php // Standard MySQL class class do_mysql { // Constructor function __construct() { $this-do_mysql(); } // Destructor function __destruct() { //$this-close(); } function do_mysql() { $this-login = ''; $this-pass = ''; $this-link = @mysql_connect('localhost', $this-login, $this-pass) or die('Could not connect to the database.'); } // End do_mysql // Functions function close() { if ($this-link) { mysql_close($this-link); unset($this-link); } } // End close function fetch_array() { return mysql_fetch_array($this-result); } // End fetch_array function last_id() { return mysql_insert_id($this-link); } // End last_id function num_rows() { return mysql_num_rows($this-result); } // End num_rows function process($database = '') { if (is_null($this-query)) { die('Error: Query string empty. Cannot proceed.'); } $this-db = @mysql_select_db($database, $this-link) or die(Database Error:Couldn't select $database br / . mysql_error()); $this-result = @mysql_query($this-query, $this-link) or die('Database Error: Couldn\'t query. br /' . mysql_error() . br /br / $this-query); } // End process function sanitize($ref) { $ref = mysql_real_escape_string($ref); } // End sanitize } // End do_mysql ? Sample usage: $value = 'value'; $sql = new do_mysql(); $sql-sanitize($value); $sql-query = SELECT * FROM `wherever` WHERE `field` = '$value'; $sql-process('dbname'); $sql-close(); if ($sql-num_rows()) { while ($row = $sql-fetch_array()) { do stuff; } } A couple of thoughts. First precede all your mysql_* calls with the at sign (@) to shut up the routines if they generate text. I had this problem, and that was the answer. Second, store your connection resource as a class variable, so you can pass it around to the various routines. Actually, you're already doing this, but I prefer to do so explicitly, as: var $link; at the top of the class. I have a similar class for PostgreSQL. I also have routines like update, which allow you to pass a table name and an associative array of field values. Same thing for an insert routine. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] About printing functions
On Wed, Jan 21, 2009 at 08:49:46PM +0200, Thodoris wrote: snip Well Jason my point is theoretical. Lets just say that this function doesn't just print blah blah blah but like tones of html that you may like to reuse... Well you could always change it to this: function print_str() { $str = blah blah blah; return $str; } and use the output you got from the function whenever you like (print it, make it a toast, cook it with bees etc). But the question still remains: Is there a way to do this? The only way to save this text off is to put it in a $_SESSION variable or cookie, at least if you want to save it beyond the present page. Oh, you could also store it in a database. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL class. Thoughts?
On Wed, Jan 21, 2009 at 09:10:54PM +0100, Jochem Maas wrote: Paul M Foster schreef: On Wed, Jan 21, 2009 at 11:37:07AM -0600, Jay Moore wrote: This is a MySQL class I use and I wanted to get everyone's thoughts on how/if I can improve it. This is for MySQL only. I don't need to make it compatible with other databases. I'm curious what you all think. I'd try to move to using the mysqli functions or class, which you can still wrap in a custom object (I do this because I like to minimize the interface to the bare, bare minimum ... professional laziness you might say). does you class need to be php4 compatible? I'd hope not but you may still have to support php4 ... even then I'd doubt you'd be using php4 for new project so it might be worth making a new php5 only class. I always write with PHP4 in mind. You never know. Besides, I can always change the internal implementation, if it's a class. snip A couple of thoughts. First precede all your mysql_* calls with the at sign (@) to shut up the routines if they generate text. I had this problem, and that was the answer. yes that's very bad advice. using error suppression is bad for performance and debugging, don't do it unless you really really have to (e.g. you have some function that spits warnings even with display_errors set to Off) display_errors should be set to Off in production, and errors/warnings shouldn't be suppressed, they should be logged. handle errors gracefully ('or die()' is not graceful) I don't know about performance. But every call to the query() method of my class tests to see the results of the query. If it failed, I call the proper function from PostgreSQL to fetch the error, and store it in the class. The query function returns false, if there's an error. So the user can test the return and then call a function to echo the stored error. Second, store your connection resource as a class variable, so you can pass it around to the various routines. Actually, you're already doing this, but I prefer to do so explicitly, as: var $link; that's very php4. Yep. at the top of the class. I have a similar class for PostgreSQL. I also have routines like update, which allow you to pass a table name and an associative array of field values. Same thing for an insert routine. if the postgres extension is anything like the firebird extension then there may actually be a few calls which do require error suppression :-) Probably. When I first started coding PHP/PostgreSQL, I was getting stuff printed out from the pg_* routines on the webpages and screwing things up. I was on the PostgreSQL list at the time, and sent an email to the list about chatter from the pg_* routines. The solution was to prefix them with @. Works great, but I *do* check for and capture error text and such. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL class. Thoughts?
On Wed, Jan 21, 2009 at 02:30:00PM -0600, Jay Moore wrote: Good ideas guys. The input is much appreciated. Jochem (and anyone else, I guess), as I am not 100% versed with Exceptions, the php5 version you suggested, are those Exceptions able to be handled outside the class? Do I need my try block to be within the class block, or can I have the try block be in my normal code where I actually instantiate the class? This: class blah { try { stuff } catch (exception) { more stuff } } $i = new blah() or can I do this: class blah { do some stuff (no try/catch blocks here) throw an exception } try { $i = new blah(); more stuff } catch (exception) { even more stuff } I know it's very OO-y to use exceptions, but I hate them. They're like setjmp/longjmp calls in C, and they're a really headache to deal with. If you don't use default or predone handlers, you have to put all kinds of try/catch blocks around everything. They make for non-linear execution, and I prefer my code to execute in a linear fashion. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL class. Thoughts?
On Wed, Jan 21, 2009 at 10:00:53PM +0100, Jochem Maas wrote: Jay Moore schreef: I know it's very OO-y to use exceptions, but I hate them. They're like setjmp/longjmp calls in C, and they're a really headache to deal with. If you don't use default or predone handlers, you have to put all kinds of try/catch blocks around everything. They make for non-linear execution, and I prefer my code to execute in a linear fashion. Paul My thoughts exactly. What do I gain by using a try/catch that I lose by using if/else or similar? you use them not for control flow, but for deferring exceptional application states, which you can then handle in a small number of places as opposed to scattering the error handling of unlikely events in all sorts of disparate places. there is an art to using them, they compliment 'traditional' error handling, and I agree they can hinder if used badly. I understand, but then it comes down to how you define an exceptional application state. If I build a date class that throws exceptions, it's very OO-y, but a waste of my programmer time. I could just as easily build an error checker into the class and use that to check for errors. Generally speaking, my next step is going to be to display the page again and tell the user to retype the date properly anyway. There are reasons to use setjmp and longjmp in C as well, but I only ever used them once, and later ripped out that code. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
On Wed, Jan 21, 2009 at 05:27:35PM -0800, Jack Bates wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? // cannot use === null: ket% php -r '$null = null; var_dump(null === $null);' bool(true) ket% php -r 'var_dump(null === $unset);' bool(true) ket% // - cannot use isset() either: ket% php -r '$null = null; var_dump(isset($null));' bool(false) ket% php -r 'var_dump(isset($unset));' bool(false) ket% Oh I *love* this problem. I still haven't found the perfect solution for it. But since a lot of things in PHP float around as strings, I often use strlen(trim($var)) == 0 to determine the emptiness of a variable. But it all depends on what type of variable you expect to receive. I don't have this problem so much with methods and functions, since I specifically engineer them to give me exact results. But I get it when testing POST and GET variables from web pages. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Client/Server Printing
I'd like a side check on what I'm doing to print on our internal network. We have an internal server/site which uses PHP code I've written to run the business-- invoicing, A/P, inventory, etc. Some things, like invoices and reports, need to be printed. Now remember, the code is on the server, and we access it from our client machines on our desks. When we print, we do so to our local printers, attached to the client machines. So the best way I could think of to making printing work was to generate PDFs of whatever needs to be printed, dump the PDF on the server, and provide a link to the PDF on the web page. The user clicks on the generated PDF, and his/her browser opens up Acrobat or xpdf, and prints from that application to their local machine. Is that a reasonable way to implement this? Any better ideas? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need List Advice
On Mon, Jan 19, 2009 at 12:42:31PM -0500, Robert Cummings wrote: On Mon, 2009-01-19 at 12:25 -0500, Daniel Brown wrote: On Mon, Jan 19, 2009 at 11:33, c...@wizzyweb.com wrote: I have been looking but can't find which PHP list is best to post info regarding a new PHP tool. I have seen new product/service announcements on this list, but thought there might be a better list. Any suggestions? As long as it's an announcement and not a commercial advertisement, you'll be fine. One thing that we generally consider bad etiquette as well would be only posting to this list to announce your product or project. Being a helpful contributor to the list in general will buy you some Brownie Points[tm]. We get brownie points for helping? Crap, who's keeping track of mine? I had no idea!! Can they be cashed in for treats? :B Well... they would be, except that yours are negative. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] developers life
On Mon, Jan 19, 2009 at 10:23:49PM -, c...@l-i-e.com wrote: ESTJ Me too. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] maybe we could all?
On Mon, Jan 19, 2009 at 11:57:25PM +, Nathan Rixham wrote: Project: PHP Common Objects and Datatypes method: for everybody who wishes to contribute, and for everybody to review, discuss and work on the same classes. what are they: classes we can all use, that have been discussed, reviewed and agreed between many great developers around the world. the classes: all the common ones we can re-use from User to Address Email Article and beyond, also perhaps wrappers for primatives / scalars. expanding: extra abstract classes we can also use, common interfaces for the above; eventually maybe utility classes as well. the idea wouldn't be a framework or another php classes, more of a repo full of common classes to save us all some time, and as a nice project anybody can contribute to and which we can all discuss and debate the finer grained details. additional: these would maybe be best to stick to common usage, so if we have say a User class in our own project with specific needs, we can simply extend the base user class and add our own functionality. thinking of putting this distraction and debate time to good use that we can all benefit from. would also propose sticking to php 5.X [we could decide a version] and obviously OO; but then if the procedural guys wanted they could as well. maybe it's just me, no commitment, no solid work, just bits of contrib and discussion / feedback. follow? thoughts? comments? interest? [everybody, even tony, would need max input and discussion to get the best solutions for us all, and class at a time should mean we get a steady stream of classes to the repo.. think about 6 months down the line] You really don't have enough to do, do you? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] maybe we could all?
On Tue, Jan 20, 2009 at 03:29:29AM +, Nathan Rixham wrote: Paul M Foster wrote: On Mon, Jan 19, 2009 at 11:57:25PM +, Nathan Rixham wrote: snip You really don't have enough to do, do you? Paul actually, way too much - but I like to learn, contribute, think about what I'm doing, skill share and contribute to the development community. and you? too much to do? :p Always. I've got projects on the back burner, side burner, next to the stove, in the sink, and on top of the fridge. On top of which, I have to run my company. And run a Linux User Group. AND I'm married! Whew! Incidentally, I'm relatively new to the list, but I see a lot of CCs along with posts to the list. The CCs are only useful if non-subscribers can post to the list. Is that the case? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] maybe we could all?
On Tue, Jan 20, 2009 at 03:57:34AM +, Nathan Rixham wrote: snip welcome; good to see a new face - even if it is preformatted courier as per :p That preformatted courier sounds like your email client. I use mutt an vim for mail. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] maybe we could all?
On Mon, Jan 19, 2009 at 10:49:34PM -0500, Daniel Brown wrote: On Mon, Jan 19, 2009 at 22:46, Paul M Foster pa...@quillandmouse.com wrote: Incidentally, I'm relatively new to the list, but I see a lot of CCs along with posts to the list. The CCs are only useful if non-subscribers can post to the list. Is that the case? Yes, sir. It's also part of the rules and guidelines for the php.net mailing lists, to hit Reply-All vs. Reply. Well, I hope nobody minds if I don't do CCs to them. When I hit Ctrl-L (list-reply) in mutt, it just replies to the list, not everyone else. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mirroring/caching PHP webpages.
On Sun, Jan 18, 2009 at 01:03:44PM +1100, Clancy wrote: On Fri, 16 Jan 2009 00:51:58 -0500, pa...@quillandmouse.com (Paul M Foster) wrote: On Fri, Jan 16, 2009 at 11:57:24AM +1100, Clancy wrote: . The only explanation I can see is that someone has somehow managed to cache or mirror the version 1 logic, and is still dutifully stuffing pornography into it. As it is my understanding that the PHP code which handles the processing is inaccessible to the user, I cannot understand how this could have been done. Does anyone have any suggestions? If Google can spider and read your site, why can't someone else? I've had similar things happen. Any program that uses the HTTP protocol to fetch your site will only get the page as rendered by the server-- sans PHP. But I can imagine someone else programming something to snag the page a different way-- *with* PHP. But actually, they don't even have to be that sophisticated. All they have to do is submit a message to your form the first time, note the variables and their characteristics, and then resubmit that same type of content later using the same variable names and characteristics. Here's something you might do: 1) Rename the page in question. That way their submission won't piggyback on your existing PHP code. 2) Change all the variable names in the file. Chances are, they're just submitting an HTTP request with the proper POST/GET variables so your page processes it as though it were being accessed live. But if they try to submit this same content to a form that goes nowhere, Apache will just give them a 404 error. Alternatively, if you change your variable names and they submit to your existing form, your PHP can simply ignore it. Also, you might try CAPTCHA (look it up). It tries to weed out human from non-human surfers. You've probably got a 'bot submitting to you, so this might help. The page has text boxes for the name and e-mail address, a text area for the message, and a submit button. When the user hits the submit button the original code evaluates all the inputs, and either re-issued the page if it didn't like them, or transmits the message, with the title Feedback from XXX website. If the message is transmitted successfully the user is then shown a Thank you for your feedback page. In version 1 of the modification if the message passed the initial test I then submitted it to a second test. If it failed this, I replaced the message with [Censored], and sent it to an alternative address, with the title Rubbish from XXX website but showed the same Thank you page. I did this just so that if I accidentally rejected something from someone I knew, I could email them and ask them to send the message again. After a few days I decided I didn't need to know anything about these bogus messages, so I developed version 2 of the modification. This is the same as version 1, except that it uses a different title and replacement message (even though they are no longer used), and simply discards the message, but again shows the normal Thank you page. With either modification there is nothing to tell the sender that their message has been rejected, and, as I never reply to such messages, no way for them to find out whether or not I actually received their message. Whenever I try to send myself a bad message nothing happens, so that version 2 appears to have been implemented. I do not get any uncensored messages of this type now, so the rejection algorithm is satisfactory, but I'm still getting one or two messages handled by version 1 each day. I cannot see how this could happen unless someone has somehow managed to trap the version 1 PHP code (or, just conceivably, my provider switches to a backup containing an old code at some stage in a maintenance cycle). I'm not an expert at the HTTP protocol, but here's what I expect is happening: Clearly, someone captured at least the form responses from a release 1 version of your website. So now they're sending an HTTP header with the various proper fields, along with POST content which conforms to your original form. They don't need any forms or actual code to do this. They have a bot which just sends the proper responses. It would be like if someone showed up on your website and filled out the form and pressed the submit button. In that case, the client sends a response to the server based on the user submission. The server, in accepting this response knows (virually) nothing about where it came from or what to do with it. It's just a client response. It decodes the header info and the POST fields, and decides from there how to handle it. Normally, this would be to present a new page acknowledging the input. The point is that all your server is getting is a header and some POST variables from some IP somewhere. You could check your server logs for the offending IP(s) if you could
[PHP] ANN: Chisimba-2.1.0 release!
The next release of the Chisimba PHP5 framework is now available (Chisimba-2.1.0). Major enhancements included in this release are: - Numerous enhancements to the database abstraction layer for increased performance - Numerous core bugfixes and enhancements - Patch descriptions added in module catalogue - Layout and skin enhancements - Increased security and RC4 encryption of session data - Complete authentication system overhaul - Remember me functionality added - URL rewriting - Remote popularity contest module - Additional filters for rich content - Some installer fixes and, of course, new modules to add onto your installation! Please take a look, download it and give it a test drive! Chisimba, for those that don't know it already, is a PHP5 framework made in Africa, for Africa. It is a collaboration between around 16 African Universities, as well as around 35 active developers from around the continent. It can be downloaded from AVOIR at: http://avoir.uwc.ac.za/ and the documentation can be found at: http://avoir.uwc.ac.za/index.php?module=newsaction=viewcategoryid=gen14Srv6Nme27_7167_1219410313 There are server setup instructions, as well as installation walkthroughs available linking from the main AVOIR site: http://avoir.uwc.ac.za/index.php?module=newsaction=viewcategoryid=gen14Srv6Nme27_2077_1219410069 For those interested in developing a module, or just getting some additional info please take a look at: http://avoir.uwc.ac.za/index.php?module=newsaction=viewcategoryid=gen14Srv6Nme27_6705_1226737050 -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend (or other) Framework...where to start?
On Thu, Jan 15, 2009 at 09:57:42AM +0300, Usamah M. Ali wrote: On Thu, Jan 15, 2009 at 1:59 AM, Paul M Foster pa...@quillandmouse.com wrote: If you're going to go with a prebuilt framework, I'd recommend CodeIgniter for your first time out. If the docs look good to you (and they are pretty good), you'll probably do fine with it. It's about the lightest weight platform out there. It doesn't get in your way too much, but gives you the benefits of using a framework. I downloaded CI because of recommendations from this list as well, but was totally shocked when I discovered that its codebase is written in PHP4! I looked up for an alpha version that is written in PHP5 to no avail. I just can't understand why would they still be in PHP4 while Symfony, a framework born after CI, requires PHP5 since version one and takes full advantage of PHP5's advanced OO features! It's designed to work with a broad range of PHP installations. If you're running PHP5, it takes advantage of features in PHP5. Look at the code tree, and you'll see two files which alternatively switch in, depending on whether you're working in PHP4 or PHP5. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Framework...where to start? -- don't.
On Thu, Jan 15, 2009 at 04:20:16AM -0500, Robert Cummings wrote: On Wed, 2009-01-14 at 21:17 -0500, Paul M Foster wrote: Incidentally, I would differ from the reviewer in the link above only in this respect: He maintains that every line of code adds time. While this is true, I believe it's the number of files which have to be opened which drags down framework numbers the most. When I wrote C code, the CPU would blaze through the actual code, but file opens and reads consumed far more time than in-memory code execution. Moot point if you're using an accelerator like eAccelerator or APC since these cache the data in memory. Similarly, most operating systems cache file reads also, so it's probably not as expensive without an accelerator as you think either. Perhaps, but since much of the C code I've written is on Linux servers like those used by most of the hosting companies, and since I can't control whether they do or don't cache pages, my personal experience (and simple logic) guides me to believe file manipulation is far more time consuming than simple manipulation of strings, number and arrays. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Framework...where to start? -- don't.
On Thu, Jan 15, 2009 at 04:17:51AM -0500, Robert Cummings wrote: On Wed, 2009-01-14 at 21:17 -0500, Paul M Foster wrote: On Wed, Jan 14, 2009 at 01:39:02PM -0800, Daevid Vincent wrote: snip The pages are significantly slower than straight PHP by orders of magnitude: [1]http://paul-m-jones.com/?p=315 What a great link! I've never seen this kind of comparison before. HTML is 70% faster than straight PHP, and the frameworks (even codeigniter) deliver less than 20% of the performance of straight PHP. It's not a fair comparison. It's like saying here's a bucket of water. I want you to take it across the road using one of the following methods: I wouldn't consider it a truly scientific comparison. The testing method seems a little odd to me. Nonetheless, the point is makes is clear: PHP is 70% (more or less) efficient in rendering pages than straight HTML, and the best frameworks are only about 20% as efficient as straight PHP. We can argue about the exact numbers, but the results make clear that for speed HTML PHP frameworks. (And really, can you logically argue that point?) From this, you don't draw the conclusion to not use frameworks or PHP. From this, you now know one of the trade-offs in using PHP and frameworks. And you get some idea of the magnitude of its impact. (These guys didn't even bother to test HTML with a bunch of Javascript or complex CSS in it. Might PHP have been faster?) Is *coding* faster and more efficient with frameworks? Sure. Does the code execute as fast? No. If execution speed is your priority, then you either scrap the framework, resort to a caching solution (which some of the frameworks already have in place, but which the testers didn't test), or figure something else out (like C?). If execution speed isn't your priority, then you might look instead at a framework. Anyway, the survey is just a tool which lets you know about one of the trade-offs in web design. I doubt any other method of testing would skew the results all that much. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mirroring/caching PHP webpages.
On Fri, Jan 16, 2009 at 11:57:24AM +1100, Clancy wrote: For some time I have had feedback pages on several of my websites based on the example given by David Powers in chapter 6 of PHP for Dreamweaver 8. These worked fine for some years, but some months ago someone started stuffing pornographic advertisements into them. A few weeks ago I got fed up with these messages, and devised a very simple filter to reject them (I won't explain how this works, because if I did the perpetrators could immediately change their technique to defeat it). If the content was acceptable I handled the message in the normal way, but otherwise I deleted the contents, and forwarded the message to a different address with the title rubbish from XXX website. This worked well, but then I decided I didn't need to know anything about this stuff at all, so I modified the logic so that if the message is unacceptable it is simply dumped, but the sender is still shown the normal Thank you for your feedback message. This way the sender cannot tell whether or not his message has actually been sent, and so he cannot experiment to try to break the filter. Now if I try to send myself bad messages they simply disappear without trace, as expected, but I am still getting one or two messages a day sent with the version 1 (censored) logic. I have changed the messages in my new version, and verified that the old messages do not appear anywhere on my hard disk, and that there is only the new version of the feedback procedure on my server. The only explanation I can see is that someone has somehow managed to cache or mirror the version 1 logic, and is still dutifully stuffing pornography into it. As it is my understanding that the PHP code which handles the processing is inaccessible to the user, I cannot understand how this could have been done. Does anyone have any suggestions? If Google can spider and read your site, why can't someone else? I've had similar things happen. Any program that uses the HTTP protocol to fetch your site will only get the page as rendered by the server-- sans PHP. But I can imagine someone else programming something to snag the page a different way-- *with* PHP. But actually, they don't even have to be that sophisticated. All they have to do is submit a message to your form the first time, note the variables and their characteristics, and then resubmit that same type of content later using the same variable names and characteristics. Here's something you might do: 1) Rename the page in question. That way their submission won't piggyback on your existing PHP code. 2) Change all the variable names in the file. Chances are, they're just submitting an HTTP request with the proper POST/GET variables so your page processes it as though it were being accessed live. But if they try to submit this same content to a form that goes nowhere, Apache will just give them a 404 error. Alternatively, if you change your variable names and they submit to your existing form, your PHP can simply ignore it. Also, you might try CAPTCHA (look it up). It tries to weed out human from non-human surfers. You've probably got a 'bot submitting to you, so this might help. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print a to z
On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote: i have this cute little problem. i want to print a to z for site navigation my first attempt work fine for($i = '65'; $i '91'; ++$i) echo chr($i); but someone point me a more interesting solutions for($i = 'a'; $i 'z'; ++$i) echo $i the only problem with the 2nd solutions is it only print up to Y without z. so how to print up to z with the 2nd solutions? because it turn out that you cant to something like for($i = 'a'; $i = 'z'; ++$i).. for ($i = 'a'; $i = 'z'; $i++) echo $i; Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend (or other) Framework...where to start?
On Wed, Jan 14, 2009 at 04:30:59PM -0500, John Corry wrote: Well, bummer. I *seriously* need to divine a way to increase my efficiency both immediately and for the long term as I maintain tomorrow the applications I build today. For the new-to-frameworks, is there a better/easier framework to use that will streamline the development process from the beginning? I've looked at Codeigniter and LOVE the user guide/documentation...the underlying philosophy of that product looks very attractive too. Any others? If you're going to go with a prebuilt framework, I'd recommend CodeIgniter for your first time out. If the docs look good to you (and they are pretty good), you'll probably do fine with it. It's about the lightest weight platform out there. It doesn't get in your way too much, but gives you the benefits of using a framework. My beef with frameworks like this is that they have too much cruft. I checked one time and codeigniter (again, one of the *lightest* frameworks) open about 15 files before a byte gets written to the screen. There is a lot of stuff in there you don't need (benchmarking code, etc.). I'd hack that stuff out if I were using it for real. One of the things you'll have to get used to is the MVC way of doing things. When you first start writing PHP, you probably don't do things this way, but when you start using frameworks, you've got to starting thinking in terms of what the view will do, versus what the controller, versus what the model will do. It's just a change of viewpoint you have to get used to. In any case, I've used CodeIgniter and liked it. I just didn't like all the cruft in it. And their license is not a straight GPL-like license-- it requires attribution even on derivative projects and requires clear notice of any changes you make to their code. But for a framework, it's pretty good. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend Framework...where to start? -- don't.
On Wed, Jan 14, 2009 at 01:39:02PM -0800, Daevid Vincent wrote: Not to start a Holy War (as these to framework or not to framework debates often turn into), but I personally had a horrible experience with using frameworks. I was forced to use Symfony at my last job and it was so cumbersome and slow to do even the simplest things. The whole MVC thing can be overkill. Plus the learning curve can be quite steep. Then if you want to hire other developers to work with you, you have to train them and let them ramp up on not only the framework but also your core project too! More wasted time. The pages are significantly slower than straight PHP by orders of magnitude: [1]http://paul-m-jones.com/?p=315 What a great link! I've never seen this kind of comparison before. HTML is 70% faster than straight PHP, and the frameworks (even codeigniter) deliver less than 20% of the performance of straight PHP. The basic problem with frameworks is they try to be one thing for all people. This carries a lot of baggage with it. There's a lot of crap you end up pulling in that you don't want/need. Plus if you want to deviate at all, you either have to roll your own, or sometimes you simply just can't. They seem attractive with all their plugins and stuff, but honestly, rarely do the plugins do EXACTLY what you want, the way you want. It might be as simple as trying to change the look/feel of a button or something and you'll find out that you can't -- so now you have this website that has this section that doesn't look like the rest of your site. And if you find a bug, you have to try to either fix it yourself and then keep those changes migrated into new updates, or submit it to the developer and hope they implement them (and trust me, you can submit to them and have them rejected for all sorts of lame reasons -- even though the work has been done and you're using it!) I advise against it. Just follow good practices and use thin wrappers and functions. Don't get all OO googlie eyed and try to over-engineer and over-OO the code. OO is great for some things (like a User class) but don't start making some OO page renderer or form builder. Don't fall into the DB Abstraction trap either -- just use a wrapper around your DB calls (see attached), so you can swap out that wrapper if (and you almost never do) you change the DB. Don't be suckered by something like QuickForms -- you WILL run into limitations that you can't get around and are at their mercy. Don't buy the hype that DIV's are the magic bullet and TABLEs are poor design -- Tables are still the best and most ubiquitous way to align things in a browser agnostic way (including mobile phones, etc.) and to layout forms. I agree and disagree. I agree there's waaay too much herd mentality in the programming field. (Fortunately, Linus Torvalds didn't listen to the academics who insisted that microkernels where THE WAY, or we wouldn't have Linux today.) OO is nifty for some things, but it's certainly not the fountain of reusability it was originally promoted to be. And I also agree about tables versus CSS. I can render a page very precisely with tables that would take me hours to get right with CSS. And I really don't give a crap about what experts say about anything. I find experts to be wrong much of the time. OTOH, I just finished writing about 80K lines of PHP/HTML, all by hand, no OO, no classes, no nothing. Each page in one file, except for a few helper functions in a couple of common files. I wouldn't want to go through that again. I've opted for a framework on rewriting this code, just to cut down on the number of lines of code I have to manually write. But I built my own framework, which doesn't call in 20 files for each page load. Very compact. Probably not suitable for every kind of project, but it works for this. Incidentally, I would differ from the reviewer in the link above only in this respect: He maintains that every line of code adds time. While this is true, I believe it's the number of files which have to be opened which drags down framework numbers the most. When I wrote C code, the CPU would blaze through the actual code, but file opens and reads consumed far more time than in-memory code execution. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Zend (or other) Framework...where to start?
On Wed, Jan 14, 2009 at 03:50:25PM -0800, Daevid Vincent wrote: snip OMG, and don't get me started on ORM. What a bloat that is. The amount of query overhead is rediculous. All these stupid objects for even the simplest of 'glue tables'. Straight SQL, optimized for your query and the data you need is significantly faster. But if you try to use that in a framework, you have other drama to deal with. Here is the base.class.php I wrote that gives the best of all worlds IMHO... Um, your base.class.php belongs to your company and says at the top not to copy or distribute. Oops. I didn't mention ORM, but I agree completely. I come from a database background, so writing SQL and designing databases is simple to me. And I'd suggest that if you're going to work with databases, you learn their design and language (SQL). Data objects have a certain symmetry and aesthetic, but they mostly add overhead. And they isolate you from a full understanding of how the database works. Most of the system code in the world is written in C, which hasn't anything like objects. And yet all that system code works pretty well. And most of the guys who code it would smack you silly if you suggested objects to them. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Sun, Jan 11, 2009 at 11:28:49PM -0800, Lars Torben Wilson wrote: 2009/1/11 Paul M Foster pa...@quillandmouse.com: snip But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? I'm in such a position now, and it's great. Mind you, as I said in another post in this thread, I have separated code and presentation for years and so I'm probably biased. ;) I can just think about code and let someone else handle the presentation. That doesn't mean that the weenies* don't have input into the code, or that I don't have input into the presentation, just that we don't have to focus on jobs that aren't ours. * - For the record, while I might have thought of the people doing the presentation as HTML weenies a few years ago, since then I've had to run a solo shop for a few years, have done layout for some CD releases, and so on--and I have gained respect for people with a truly good eye and the ability to translate that onto the screen. While I enjoy layout and presentation, it's not where my training is and I recognize superior talent when I see it. They have their strengths and I have mine and we do what we do best. As for HTML weenies, my experience has been the opposite. My company does websites, among other things. Most of my work involves our internal website, which runs the company. I do PHP and the HTML for the internal website. My wife does the design/HTML for customer websites. If a customer website needs PHP, I do it. I don't know how many times we've had to deal with outside web design types, and found their work to be atrocious. I also have a fair amount of contempt for people who refuse to learn anything outside their narrow field, which is what I see in a lot of HTML folks. I would have more respect for them if they took the time to understand at least something about PHP, and thus better understand what I have to deal with in their HTML. My wife doesn't know as much about HTML as I do, since she uses Dreamweaver to code HTML. But I code HTML by hand, and I don't have the patience to do fancy HTML the way she does. Consequently, the internal website is visually pleasing but not fancy. Customer websites are prettier than our internal one, but have almost no PHP in them. However, I've had many situations where my wife has designed a pretty page I have to now add PHP to. It's tricky. But as a consequence, I tend to code HTML without resorting to rendering classes. Even though it would be much easier to do it with classes. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Php and CSS where to put it
On Mon, Jan 12, 2009 at 09:56:00PM +, Ashley Sheridan wrote: snip Here's something for fixing IE with hacks: http://www.ashleysheridan.co.uk/coding_html_comments.php basically it lets you add in extra IE-only stylesheets using comment code only recognised by IE, and you can use !important to stress your IE styles. Best thing though is it validates through the W3C because it is just an HTML comment. Don't move that page; I've bookmarked it. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote: One of the best things that ever happened to me (with regards to writing PHP) was deciding not to embed it in HTML anymore. I either: a) generate the HTML from classes I've built (HTML, Forms, Tables, Images, etc) or use an equivalent PEAR class - or - b) Use Smarty templates...in which I still generate the HTML that will go to the template (where required) with the HTML generation classes. The advantages are abundant. I can't imagine having to maintain some of the code I saw in the examples above. My favorite WTF was with this snippet: $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . ' class=' . $imgclass . ' /'; Holy crap...REALLY!? All that string concatenation and there's not even width/height attributes in there! That would look like: $i = new Image('path/to/image/file'); $i-__set(array('class'=$imgClass, 'alt' = $altText)); $i-toHtml(); Being able to change every image tag in a site by editing the class/method that created is just too big an advantage not to use. Not to mention the auto-generated width/height attributes, the ability to auto-produce thumbnails and fullsize images from a single file... After struggling through the beginnings, I wrote classes to generate basic HTML elements, then tables, then forms, then images. It saved me a bunch of time and taught me to see the website as an application...not as a web-page with pieces of data in it. Somehow, coming to that bit of knowledge was very helpful to my life as a programmer. I've written a lot of code like the original example above, and still do, but I see your point, since I've written code like yours too. I write all my PHP code (and I write a *lot* of it) solo, with no help and no collaborators. But as I understand it from a lot of framework types, the ideal is to set up the HTML so that a HTML coder can understand what's going on, without having a lot of PHP weirdness in it. Meaning, if you're going to infuse your HTML with PHP, you should do it in a minimalistic way. It'd be a helluva lot easier on me to do it all through PHP classes, though. I also come from a C background, and I recognize significant differences between the paradigm for C programs and HTTP-based coding. Considering that every PHP program paints generally a single page, I'm not a fan of loading up 14 support files every time I load a page of HTML. That's why I don't use one of the MVC frameworks available in the FOSS world. CodeIgniter, which is one of the lightest weight frameworks, opens something like 17 files before it paints a single byte in the browser. The upshot is that I don't like to use a lot of libraries scattered in a variety of files to render HTML/PHP pages. But here's a question for those of you who work in a collaborative environment-- are you really ever in a situation where some HTML weenie is coding HTML pages and you're somewhere else doing the PHP work? Or is that some academic's view of the way things *should* be done? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: hello
On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote: On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote: On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote: -12C in Toronto Meh! 30C - 35C in Cape Town, South Africa almost every day for the last month. It has been a scorcher this year! Grumble, grumble... did I mention freshwater falls from the sky and forms vertical piles outside my home? High of 72 degrees in central Florida. Now, where did I put my swimsuit? ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: hello
On Sat, Jan 10, 2009 at 03:16:34AM -0500, Robert Cummings wrote: On Sat, 2009-01-10 at 03:10 -0500, Paul M Foster wrote: On Sat, Jan 10, 2009 at 01:57:09AM -0500, Robert Cummings wrote: On Sat, 2009-01-10 at 05:20 +0200, Paul Scott wrote: On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote: -12C in Toronto Meh! 30C - 35C in Cape Town, South Africa almost every day for the last month. It has been a scorcher this year! Grumble, grumble... did I mention freshwater falls from the sky and forms vertical piles outside my home? High of 72 degrees in central Florida. Now, where did I put my swimsuit? ;-} *throws snowball at you* *ducks behind sand castle* ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
On Sat, Jan 10, 2009 at 09:46:14AM -0500, tedd wrote: At 8:48 AM -0500 1/10/09, Gary wrote: Looks like a great link, thank you. But am I to understand that all I need to do is change the extention on a file to php from html for all to be right with the world? Yup. By changing the suffix (extension), you are telling the server that this file is to be treated differently than a html file. As such, the php interpreter will process the file before it is sent to the browser. A statement like: ?php echo('Hello'); ? Will print Hello to the browser. In fact, the browser will never see your php code unless you make a mistake. The file will be processed and delivered to the browser as html. Please note that my use of echo above does not require the (), that's a habit I practice for no good reason whatsoever other than I like it. I think it's because I'm dyslectic and it makes sense to me. In any event, I would consider the followingbad practice: ?php echo('h1Hello/h1'); ? Whereas, the following I would consider good practice. h1?php echo('Hello'); ?/h1 As best as you can, try to keep php and html separate. I know that some have different ideas on good/bad practices, but you'll develop your own views/habits as you grow and learn. And let me present an alternative perspective. Never do something like: ?php echo 'Hellow world'; ? Let Apache (or whatever) interpret HTML as HTML, and don't make it interpret PHP code as HTML. Instead, do: h1Hello world/h1 If you're going to use PHP in the middle of a bunch of HTML, then only use it where it's needed: h1Hello ?php echo $name; ?/h1 The contents of the PHP $name variable can't be seen by the HTML, which is why you need to enclose it in a little PHP island. Naturally, if you're going to put PHP code in the middle of a HTML page, make the extension PHP. Otherwise, Apache will not interpret the PHP code as PHP (unless you do some messing with .htaccess or whatever). It's just simplest to call a file something.php if it has PHP in it. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Referencing variable in calling class?
On Sun, Jan 11, 2009 at 10:33:30AM +1000, Murray wrote: Hi All, I'd like to reference the value of a variable in a class that called the current piece of code via a require_once. In essence, I have a 'front controller' class that builds the page to be displayed depending on several criteria. One issue I'm having is that when a user logs out of my application, I destroy the cookie that indicated the user was logged in during my preRender process, and then go onto display the 'logged out' page. Unfortunately, I have a page element that indicates whether the user is logged in or not, and I assume because the cookie destruction is being sent down in that page request, when that page renders it still appears as if the user is logged in, because the cookie still exists until after that page is rendered. So, I thought perhaps as part of my logout routine, I could set a variable that my 'are you logged in or out' code could check and use to override whether or not it displays the 'login' url or the 'logout' url. I thought that in that code I should be able to check the value of a public variable that is in my front controller class, but it appears I can't? So, pseudo chain of processing would be something like this: - call index.php - instantiate front loader class - perform pre-render processing, if logging out, set public variable in class to true - call actual page to be rendered via require_once - in page being rendered, call function from separate file that displays 'login / logout' url - in that function test public variable in front controller class to see if true - if true, regardless of whether or not the cookie still 'appears' to exist, display 'login' url because user has logged out However, am I right in thinking that the function that displays the login / logout url is actually unaware of the existence of the front controller class at the point at which it is being called? M is for Murray I'm not quite sure why you don't force the login/logout page to use the front controller. Here's how I do it: I set various variables, and check the login status (I use $_SESSION variables to hold user ID and encrypted password). If the user is not logged in, I force the controller to be the login controller, regardless of whatever page the user *wants* to display. Then I go ahead with instantiating the controller, in this case, the login controller. So essentially, if the user is logged in, I go ahead and instantiate whatever controller they specify. But if they're not logged in, I force the login controller to be the one which is instantiated. (In my case, the front controller isn't really a class as other controllers are. It's just a bunch of routines and function calls in index.php.) Does that make sense? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First steps towards unix and php
On Fri, 2009-01-09 at 07:50 -0500, Daniel Brown wrote: I'd take SMART or urpmi over yum as well, for the record. First choice is ./configure make make install, second choice is apt -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First steps towards unix and php
On Fri, 2009-01-09 at 14:53 +0200, Paul Scott wrote: First choice is ./configure make make install, second choice is apt Even better, of course, is the: Yo sysadmin intern! Install package for me please and don't screw it up -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] on Mapserver and php5_MapScript
On Fri, 2009-01-09 at 14:15 -0500, Eduardo Arévalo wrote: As I write this line is highlighted in black php5_MapScript You should probably ask this on the UMN Mapserver lists at mapserver-us...@lists.osgeo.org but... ; $jStyle-outlinecolor-setRGB(200, 200, 200); You are setting an outline colour, but the style you are using does not allow it to be displayed. Basically all you are getting is the outline and not the fill. I suggest you read the excellent mapfile docs or ask on another list. -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: hello
On Fri, 2009-01-09 at 18:15 -0500, Phpster wrote: -12C in Toronto Meh! 30C - 35C in Cape Town, South Africa almost every day for the last month. It has been a scorcher this year! -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: can a session be used in a query?
On Wed, Jan 07, 2009 at 08:29:42PM -0500, Frank Stanovcak wrote: because you so nicely didn't make fun of me...that much :) I keep it in it's own file and just use it as in include to probe where I need to. --code follows-- ?php function breakarray($passed){ echo 'table border=1trthkey/ththvalue/th/tr'; foreach($passed as $tkey=$tvalue){ echo 'trtd[' , $tkey , ']/tdtd'; if(is_array($tvalue)){ breakarray($tvalue); }else{ echo '' , $tvalue , '/td/tr'; }; }; echo '/table'; }; echo 'table border=1tr thvariable/th thvalue/th /tr'; foreach(get_defined_vars() as $key = $value){ echo 'trtd$',$key ,'/tdtd'; if(is_array($value) and $key != 'GLOBALS'){ if(sizeof($value) 0){ breakarray($value); echo '/td/tr'; }else{ echo 'EMPTY /td/tr'; }; }else{ echo '' , $value , '/td/tr'; }; }; echo '/table'; ? Nicely done. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing and then printing ANSI escape sequences in (and then from) variables
On Wed, Jan 07, 2009 at 11:11:53PM +, Luke Slater wrote: Hi, I'm storing ANSI escape sequences in an array, stored like this: $connections[$channel][2] = $info['colour']; $info['$colour'] would contain something like \033[33m Now, my problem is when I try and print it: $pstring = $connections[$channel][2] . $connections[$channel][1] . . $buffer . chr(7); It will print as a literal string, actually printing \033[33m to the screen, so how do I make it work? I'm sure I'm missing something fatally simple here. Thanks for your help, Luke Slater What you're storing is human shorthand for bytes sent to the display. (I'm assuming you're working with the terminal here, not a browser window.) The \033 indicates an octal byte with that value. But when you send it, you're sending each character individually to the screeen. That is '\' is one byte, '0' is the next, '3' the next, etc. That '\033' (and subsequent codes) need to be coded as single bytes and sent bytewise to the terminal. And if your terminal isn't configured to accept ANSI excape codes, it won't work anyway. Your chr(7) is the clue. Your codes, if numeric, need to be converted to integers and given to the chr() function, and output using that function. Try converting some known codes into integers, outputting them via the chr() function, and seeing if the result is what you expected. You may need to use the inverse function, ord(), to get your codes into numeric form. For example, ord('m') will return decimal 109. That's only an example, since you should be able to send single characters to the terminal as is. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Holocoste against palestinians
On Wed, 2009-01-07 at 22:51 -0800, It flance wrote: The message is to webhosting companies, This is not a web hosting company. Israel is killing palestinian children. Some sites are are showing the fotos of israel's holocoste against palestinians. Now here is a link that shows to israelis how to fight that too: http://www.jpost.com/servlet/Satellite?cid=1231167272840pagename=JPost%2FJPArticle%2FShowFull Please be aware of that. What exactly does this inane crap have to do with PHP? I see that there is an asshole like you on almost every list that I subscribe to (many) and I am tired of politics creeping into FREE software. I think that part of MY FREEDOM that you are infringing on is my FREEDOM from politics. If I was interested in this crap, I would subscribe to an APPROPRIATE list. Thank YOU and good luck. -- Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
On Wed, Jan 07, 2009 at 08:38:03AM +1100, Chris wrote: Nathan Rixham wrote: chris smith wrote: It may be worth mentioning that, IIRC, CHAR is faster due to the fixed length. If you can make your table use a fixed length row size (ie no variable length columns), it'll be faster. I'd be interested in seeing tests about this.. I doubt there's any difference. quote: http://dev.mysql.com/doc/refman/5.1/en/data-size.html For MyISAM tables, if you do not have any variable-length columns (VARCHAR, TEXT, or BLOB columns), a fixed-size row format is used. *This is faster but unfortunately may waste some space.* See Section 13.4.3, ?MyISAM Table Storage Formats?. You can hint that you want to have fixed length rows even if you have VARCHAR columns with the CREATE TABLE option ROW_FORMAT=FIXED. It'd still be interesting to see if it made any noticeable difference (I'm guessing not until you get into rather large db's). FWIW, this is *not* the case with PostgreSQL, according to this note from the PostgreSQL website: Tip: There are no performance differences between these three types, apart from the increased storage size when using the blank-padded type. While character(n) has performance advantages in some other database systems, it has no such advantages in PostgreSQL. In most situations text or character varying should be used instead. http://www.postgresql.org/docs/8.0/interactive/datatype-character.html Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] permission failure with fopen
On Fri, 2008-11-07 at 14:27 +0200, Thodoris wrote: I'm testing on Windows XP SP2 with PHP 5.2.0 As far as I remember, you need to pass the b parameter to Windows as well on fopen(), so you would do an fopen(/path/to/file,wb); --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] web shot script
On Thu, 2008-10-23 at 22:20 -0400, Joey wrote: Really I want to do this, not pay someone to do it via those services you linked to. So nobody has seen open source code for this? I run a free (freedom and beer) webservice to do this via the Chisimba framework (http://avoir.uwc.ac.za) The docs and files are all in svn so if you would like em, get em! The screenshot code is in python though. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dev Facts
On Fri, 2008-10-17 at 00:14 +0100, Nathan Rixham wrote: Evening All, I'd be /really/ interested to know who uses what! *Procedural or OOP?* OOP *Dev OS* Ubuntu 8.04 *Dev PHP Version* PHP-5.2.3 *Live Server OS* Debian *Live Server PHP Version* PHP-5.2.3 *Which HTTP Server Software (+version)?* Apache 2 *IDE / Dev Environment* Zend Studio / Vim / nano *Preferred Framework(s)?* Chisimba *Do you Unit Test?* Yes - PHPUnit3 *Most Used Internal PHP Class* SPL classes *Preferred OS CMS* Chisimba CMS --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ANN: Chisimba-2.0.3 Released!
The next release of the Chisimba PHP5 framework is now available. Major enhancements included in this release are: - PDO and MDB2 support - Improved database performance - Bug fixes - Better code documentation - API integration for many more modules - Remote downloads of modules (apt like module installations) and, of course, new modules to add onto your installation! Please take a look, download it and give it a test drive! Chisimba, for those that don't know it already, is a PHP5 framework made in Africa, for Africa. It is a collaboration between around 16 African Universities, as well as around 35 active developers from around the continent. It can be downloaded from AVOIR at: http://trac.uwc.ac.za/trac/chisimba/downloader/download/release/5 and the docs can be found at: http://avoir.uwc.ac.za/ There are server setup instructions, as well as installation walkthroughs available linking from the main AVOIR site: For those interested in developing a module, or just getting some additional info please join our mailing list and ask some questions: http://mailman.uwc.ac.za/mailman/listinfo/nextgen-online --Paul -- . | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :: All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web2.0 style tags - where to start?
On Tue, July 29, 2008 9:22 am, Jason Norwood-Young wrote: On Mon, 2008-07-28 at 23:57 +0100, Paul Jinks wrote: Jason Norwood-Young wrote: On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote: I think my first post was ambiguous. What we're thinking of is to build a site on which people can view videos with the option to add metadata to a video after viewing it. We think that the content we have will be of wide interest to a lot of people and the best way to index it is for users to 'tag' it themselves, since it's hard for us to anticipate the uses that people may have for the content. How do you plan to have users enter the info? Through the Flash player, through some kinda Ajax form, through a form in a frame or just a static form? Also, would the tags be predefined by you (eg. genres like the ID3 tag genres) or would people be able to add their own tags? The way I'd do it would be to let the users enter the info through an Ajax form below the video, with suggestions popping up as they type. Then save it in a separate table (I assume all your vids are in their own table) with a link table between the vids table and the tags table (M2M relationship). This means that if the tag is already in there and linked to one vid, you don't replicate it for a second vid. It's also very easy to do lookups of similar items. I'd also add a weighting to the tags in the links table, maybe with the more people that add a specific tag, the more weight that tag gets. Also check out http://www.music-map.com/ as an example of showing similar music - you might even be able to plug into this data. Hi Jason Hmm, food for thought. music-map is brilliant, though not what I'm looking for graphically at the moment (was surprised to find Cesaria Evora in close proximity to The Cardigans but I digress). What you describe is pretty much what I'm chasing, thanks and helps me down the road, particularly with thinking about the database set up. They 'only' problem is, my php/mysql skills are some way behind my javascript/actionscript knowhow (I'm pretty much a noob here); what I could use now is a how-to tutorial to give me some code to work off, either online or in a book. If it ain't there, I can build from scratch but it's going to mean a lot of calls for help! =) Many thanks Paul In that case, I suggest the following solution: 1. Download the unternet into your puter 2. Open the file called mysql.com 3. Read and learn 4. Open the file called php.net 5. Read and learn 6. Rinse and repeat LOL In all seriousness, this is a nice, simple project to learn on. You want to look at different types of relationships in Sql (one-to-one, one-to-many and many-to-many) and learn a bit about basic DB architecture; make some tables and play with getting data in and out (get PHPMyAdmin to help you out); maybe use a nice simple framework like CodeIgniter to get you kick-started on the PHP. Right, from scratch it is then (installs xampp, starts up PSPad, and cancels all meetings)... =) Cheers Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Double results??
In mail.php.general, Dan Shirah [EMAIL PROTECTED] wrote: $name_result = ifx_query ($name_query, $connect_id); while ($name = ifx_fetch_row($name_result)) { $party_name = TRIM($name['caa44240004']); print_r($name); } print_r($name) will return: John John Mary Mary Cindy Cindy I don't know anything about the Informix functions, but in other database types fetch_row can return doubly indexed entries. e.g. array( 0 = 'John', 'name' = 'John', ) I would suggest you use var_dump() or var_export() to get a better idea of what is in $name - you might find if this is the case that your code is not necessarily wrong because you are getting the right number of rows. Note it is hard to tell from your code - because your code would run print_r() for every loop - but that isn't what your suggested output is. Regards, PG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Web2.0 style tags - where to start?
Hi I'm working on a project where we're building a collection of videos in Flash and the idea has been mooted that it would improve usability if we were to allow users to tag videos they've seen a la last.fm, flickr youtube etc. It's still very early days and I'm quite interested in putting something together quickly to see if it's really the way we want to go (also because it might be useful for other projects). Does anyone know of any good resources on building a tagging system? The video for now will be held on a normal LAMP machine as will everything else. TIA Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web2.0 style tags - where to start?
On Mon, July 28, 2008 2:04 pm, Richard Heyes wrote: I'm working on a project where we're building a collection of videos in Flash and the idea has been mooted that it would improve usability if we were to allow users to tag videos they've seen a la last.fm, flickr youtube etc. If you're thinking of trying re-invent a UI - my advice would be don't. Your visitors are more likely to know and understand their own PCs UI as opposed to one that you invent. Any UI you come up with is not going to be as easily used no matter how good it is. -- Richard Heyes http://www.phpguru.org Hi Richard I think my first post was ambiguous. What we're thinking of is to build a site on which people can view videos with the option to add metadata to a video after viewing it. We think that the content we have will be of wide interest to a lot of people and the best way to index it is for users to 'tag' it themselves, since it's hard for us to anticipate the uses that people may have for the content. Last.fm allows users to tag bands and songs for example; here's the tag page for Joy Division: http://www.last.fm/music/Joy+Division/+tags The idea being that if you're interested in post-punk, for example, you can click on that tag and be taken to the pages of similarly genred bands. So it encourages use of the content and serendipitous connections (maybe). I'm not convinced that this is the way to go, but I'd like to pilot the idea and am looking for signposts for where to start. Paul Ps. I was wrong about youtube, by the way, it doesn't look like they do tagging. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web2.0 style tags - where to start?
Jason Norwood-Young wrote: On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote: I think my first post was ambiguous. What we're thinking of is to build a site on which people can view videos with the option to add metadata to a video after viewing it. We think that the content we have will be of wide interest to a lot of people and the best way to index it is for users to 'tag' it themselves, since it's hard for us to anticipate the uses that people may have for the content. How do you plan to have users enter the info? Through the Flash player, through some kinda Ajax form, through a form in a frame or just a static form? Also, would the tags be predefined by you (eg. genres like the ID3 tag genres) or would people be able to add their own tags? The way I'd do it would be to let the users enter the info through an Ajax form below the video, with suggestions popping up as they type. Then save it in a separate table (I assume all your vids are in their own table) with a link table between the vids table and the tags table (M2M relationship). This means that if the tag is already in there and linked to one vid, you don't replicate it for a second vid. It's also very easy to do lookups of similar items. I'd also add a weighting to the tags in the links table, maybe with the more people that add a specific tag, the more weight that tag gets. Also check out http://www.music-map.com/ as an example of showing similar music - you might even be able to plug into this data. Hi Jason Hmm, food for thought. music-map is brilliant, though not what I'm looking for graphically at the moment (was surprised to find Cesaria Evora in close proximity to The Cardigans but I digress). What you describe is pretty much what I'm chasing, thanks and helps me down the road, particularly with thinking about the database set up. They 'only' problem is, my php/mysql skills are some way behind my javascript/actionscript knowhow (I'm pretty much a noob here); what I could use now is a how-to tutorial to give me some code to work off, either online or in a book. If it ain't there, I can build from scratch but it's going to mean a lot of calls for help! =) Many thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: very very small CMS
On Sat, 2008-07-19 at 10:18 -0400, tedd wrote: At 12:48 PM +0200 7/19/08, Frank Arensmeier wrote: 19 jul 2008 kl. 05.05 skrev Robert Cummings: Here's a CMS I've been working on. http://www.webbytedd.com/a/easy-page-db The idea is to allow the user edit pages in situ. Tedd, Looks pretty good, but why not use in place editing with a little bit of AJAX rather than making the user click twice? I would rather turn editing on, then click to edit in place. --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Capitalization of variable
At 6/18/2008 09:38 PM, Nathan Nobbe wrote: $streetAddr = 817 17th ST, DENVER COLORADO; echo ucwords(strtolower($streetAddr)); // 817 17th St, Denver Colorado I'd like to mention that, in practical usage, capitalizing the first letter of every word does not correctly capitalize addresses in most languages expressed in Roman script. In North America we see numerous common exceptions such as PO, APO, NE/NW/SE..., MacDonald, Macdonald, deCamp, D'Angelo, de la Rosa, Apt. 3E, et cetera, et cetera. If you're serious about correcting a mailing list for upper- lowercase, I suggest you build or use a replacement dictionary that's smart about postal addresses and smart about the languages you're liable to encounter. If you're in North America, a simple correcting algorithm is pretty much impossible because of the damage done by Ellis Island that has rendered the spelling of names arbitrary, even random, and often incorrect relative to their origins. Good luck! But don't give up -- as Xeno will attest, your earnest attempt to reach the tree with your arrow will gain praise even if it's doomed never to actually arrive. Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] losing mysql connection during cron job
At 6/18/2008 02:47 PM, Paul Novitski wrote: I've got a simple script running as a cron job that's getting intermittent Lost connection to MySQL server during query errors. At 6/18/2008 10:43 PM, Chris wrote: You need to do a mysql_close(); mysql_connect(...) before mysql_query works again - otherwise mysql_connect will just return the same resource id (or I guess just use the 'new_connection' flag for mysql_connect and skip the mysql_close()). Thanks! Adding the new_link parameter to mysql_connect() did the trick. What had me stumped before was that each mysql_connect() succeeded but the mysql_select_db() immediately afterward failed. But as the documentation says: new_link If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters. http://ca3.php.net/mysql_connect Reminder to self: RTFM doesn't always work if you think you know the page and don't re-read it with new eyes. Cheers, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Associative Arrays
At 6/19/2008 05:55 PM, VamVan wrote: How to create an associative array of this kind in PHP? return array( 12345 = array( 'mail' = '[EMAIL PROTECTED]', 'companyName' = 'Asdf Inc.', ), 54321 = array( 'mail' = '[EMAIL PROTECTED]', 'companyName' = 'Asdfu Corp.', ), ); This is the right PHP syntax, except that you've got an extraneous comma before the closing parenthesis of each array that's going to throw a parse error. Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Associative Arrays
At 6/19/2008 07:36 PM, Robert Cummings wrote: 54321 = array( 'mail' = '[EMAIL PROTECTED]', 'companyName' = 'Asdfu Corp.', ), ); This is the right PHP syntax, except that you've got an extraneous comma before the closing parenthesis of each array that's going to throw a parse error. Actually that's allowed (and by design too) :) Yep, it's there to primarily simplify generated PHP code. Additionally, it sure makes commenting out chunks simple since you don't need to comment out the preceding comma if commenting out the last entry. Thanks. I could have sworn I'd gotten parse errors on that. Damned cross-language memory leakage... I've gotten into the habit of writing comma-delimited lists like so: (item ,item ,item ,item ); which works for functions with long parameter lists and SQL field lists as well as arrays. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] losing mysql connection during cron job
I've got a simple script running as a cron job that's getting intermittent Lost connection to MySQL server during query errors. The script sends out listserve messages, 50 BCCs each minute, sleep()ing for 60 seconds between sends and updating a data table after each send. The whole BCC list varies from one message to the next, but messages typically take 10 or more sends in batches of 50 recipients. Inconsistently, the script aborts with the lost connection error after a varying number of sends. Rarely it bombs not at all and performs all 10 or 12 updates without error. The script cycle is, symbolically: foreach (recipients as batch) { mail() using batch of recipients; mysql_query() update table; sleep(60); } final mysql_query() update table as complete; In an attempt to cure the problem I'm re-establishing the $conn before each query and doing a mysql_close() after each query, but the error still occurs. The hosting is Media Temple's gridserver. I've never encountered this error in any of the many PHP/mysql scripts I run on Media Temple accounts, but this is different as it's a cron job. Can you suggest aspects of the process that might lead to this error that I should look at more carefully? I can understand that sleep() might lose the connection between PHP the MySQL server, but why would the script be unable to reconnect after sleeping? Would that be a server-dependent issue or is there something I can do in PHP to nail down the connectivity? I'm hoping to get assistance on this issue without having to clean up the script enough to invite in guests, but I'll do so if required. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] losing mysql connection during cron job
At 6/18/2008 04:49 PM, Shiplu wrote: why don't you edit your code? foreach (recipients as batch) { mail() using batch of recipients; mysql_query() update table; if(mysql_errno()==ERROR_CODE_YOU_GET){ mysql_connect(); mysql_select_db(); } sleep(60); } Thanks for the suggestion. I am currently successfully working around this error by another method, although your suggestion is probably better. The reason I posted this problem, though, is that I want to understand *why* I'm getting the Lost connection to MySQL server during query error. If anyone has had a similar experience using cron jobs or sleep() I'd love to hear from you. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SPAM SPAM Re: [PHP] Capture homepage screenshot
On Fri, 2008-06-13 at 14:45 -0400, Daniel Brown wrote: There are several commercial options available, but I may put together a script this afternoon capable of generating thumbnails from websites. If I do, I'll keep you informed. In my project, we do this through a small Python application. The cool thing for you, is that the functionality is exposed through an XML-RPC service as well... You are free to use it, as long as you don't abuse it of course (we have limited bandwidth in Africa). The other option is to read the docs as to how its done and copy it (it's all GPL anyway). To see it in action, take a look at: http://avoir.uwc.ac.za/index.php?module=cmsaction=showfulltextsectionid=init_1id=gen14Srv2Nme49_8062_1213073978 In my framework, we simply call it through a filter, so to get a screnshot of the PHP site, I would simply add in: [SCREENSHOT]http://www.php.net/[/SCREENSHOT] in any place that I can add content (blog, wiki, cms etc). Lastly, but not least at all, you could also just use our framework... Download from http://avoir.uwc.ac.za/ --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SPAM SPAM [PHP] Build and Deployment Process
On Tue, 2008-06-10 at 14:56 -0700, VamVan wrote: What is the best method to build and deploy php scripts along the different environments? You can talk about rpm's and stuff In my project(s) I use Phing. http://phing.info It is even written in PHP, so keeping this thread on topic. --Paul -- . | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :: All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP/SOAP WDSL Restrictions
Hi All, I'm struggling with the WDSL restrictions in PHP/SOAP for a while know. I would like to create some simple restrictions in my WDSL file. The script are running both on the same server with PHP Version 5.2.6 with the official soap extension. On both my client and server there is some error configuration: error_reporting(E_ALL); ini_set(soap.wsdl_cache_enabled, 0); use_soap_error_handler(true); In my WDSL file there are some restrictions like: A rule to accept only numbers, PHP/SOAP is translating not numbers to 0. (but I want an error message!) xsd:element name=streetNumber minOccurs=1 maxOccurs=1 type=xsd:int Almost the same for this more advanced restriction, you can provide every string. There is no error message and the whole string is accepted by my server. xsd:simpleType name=Email xsd:restriction base=xsd:string xsd:pattern value=^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*$ /xsd:pattern /xsd:restriction /xsd:simpleType I hope there are some people that have some more experience with PHP/SOAP and the use of restrictions who can help me with this! Best regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP/SOAP WDSL Restrictions
I'm struggling with the WDSL restrictions in PHP/SOAP for a while Sorry, I mean WSDL instead of WDSL. But of course the problem stays the same :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the Y2K38 BUG
On Wed, 2008-05-07 at 00:54 -0600, Nathan Nobbe wrote: looks like mine only goes to dec. 31, =/ *Gasp!* best you get cracking on finding an alternative solution! --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] AI file and mapping with PHP
On Wed, 2008-05-07 at 12:17 +0200, Angelo Zanetti wrote: We have a project where by we have a map in ai format (vector format). What we want to do is to programmatically come up with a solution that say on the map there is a restaurant at a certain location, that we can zoom into the map on that specific area. Angelo, You will need a specialised solution for this, like UMN Mapserver with PHP/Mapscript. If you need some real, local, help, mail me off list, and I will see about you guys paying me to do this for you (at SA prices) ;) Seriously though, you won't get what you want with GD... --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange behavior, when converting float to int
On Tue, 2008-05-06 at 09:34 -0500, Philip Thompson wrote: I got the same results. I'm not exactly sure what's happening, but I'd be curious to see if there's anyone else who can shed some light. PHP Version 5.2.4. Is this not coming from the underlying C libs that directly use the FP on the CPU? I would say that the compile flags, CPU settings etc would probably have an impact on accuracy. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the Y2K38 BUG
On Wed, 2008-05-07 at 10:03 +0530, Chetan Rane wrote: Have guys heard of the the Y2K38 Bug more details are on this link Nope, but I can guess what its about. Can there be a possible solution. As the system which I am developing for my client uses Unix timestamp. There are probably multiple solutions. AFAIK time is a 32 bit signed int, making it unsigned would add like 100 years onto your app. This might effect my application in the future If your app survives that long! Why not just maintain it and when times change, your app changes? :) Seriously, this is really not a big deal! Thank you, in Advance. It's a pleasure my paranoid son... --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php