Re: [PHP] A Strange Problem
On Jun 20, 2013 7:20 PM, Tedd Sperling t...@sperling.com wrote: On Jun 20, 2013, at 7:12 PM, Stuart Dallas stu...@3ft9.com wrote: Whatever the reason for this, I'd recommend you always specify a path relative to the current script. In PHP 5.3+: $fcontents = file(__DIR__.'/docs/admin-email.txt'); Prior to 5.3: $fcontents = file(dirname(__FILE__).'/docs/admin-email.txt'); -Stuart -Stuart: Thats' an excellent idea -- I will do that. I just don't know why after so many years this problem came up -- I never experienced it before -- AND when I am really up against it. Maybe someone smarter than me (open to many) will explain why it happened. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This was aeons ago, but i recall reading somewhere that could not necessarily trust what directory one's script was executing in so always spec abs paths. I've been more lax on that lately, but such things appear from time-to-time.
Re: [PHP] Re: limit access to php page
On May 30, 2013 8:10 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 5/29/2013 9:38 PM, tamouse mailing lists wrote: Okay, first off, your application *has* to have some entry point that *is* accessible to a browser; otherwise nothing will find it. Once again - I was wrong in my suggestion as Ashley has pointed out so correctly. Had to test it out this morning only to discover that I had never done quite that kind of Header redirect before. So - the include method still works, as would the single script 'controller' method. Within a php script any file is accessible (within your domain at least) and may therefore be included and execute. I want to throw in a caveat here, and that is the open_basedir directive, wbicb limits where you can include files from. On the other hand, if you must have the target script in your web-accessible tree, simply establish some kind of security handler and add logic to your page(s) to check permissions before displaying anything. This handler could be based upon session vars, cookies, db entries (my pref). Once established it can be a universal addition to any and all of your appls. My personal method is to create a db table containing an appl name, page name, and a non-unique security level (I use an integer). Then have an admin screen for creating userids for an appl with multiple recs each containing a security level for that user for that appl. Then have a signon method that validates credentials and builds a session array containing all the user's security levels. In every page that I want secured, I call a function with that script's internal pagename and appl name and confirm that the page's sec level is contained in the user's session array. I also have a master level (99) that if present gives global access for myself as administrator. There's a bit more to it, but that's my security method. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for a good working PDO and/or mysqli database class to get started with OOP
On Thu, May 30, 2013 at 8:45 PM, Stephen stephe...@rogers.com wrote: On 13-05-30 09:36 PM, dealTek wrote: Hi all, Thanks for your help... I'm looking for a very good, pre made, working PDO and/or mysqli database class (in a wrapper) - to get started with, that has all the basic needs like UPDATE - INSERT - DELETE - QUERY etc. That would be very helpful. I'm also trying to learn OOP, and creating my own class to start out is over my head, so one that is recommended here would be a good start. Hmmm. PDO **IS** an OOP implementation. Why would you want to encapsulate it? Accessing a database requires SQL with arguments dependant on YOUR database schema. You have to do that work; there is no way around it. Sounds like the OP is asking for a pre-built CRUD interface that adapts to his tables and their relationships. It's a fair question, just one I don't have an answer to. There must be some kind of ORM for PHP? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limit access to php page
On Wed, May 29, 2013 at 6:11 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I've created an authentication page (index.php) that logs into an LDAP server, then points you to a second page that some folks are intended to use to request apache redirects from the sysadmin group (redirect.php). Everything works great so far, except if you pop the full URL of redirect.php into your browser you can hit the page regardless of the login process on index.php. How can I limit redirect.php so that it can only be reached once you login via the index page? Thank you! Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B Read through this page, and the other parts of the Session manual. Hopefully that will help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limit access to php page
On Wed, May 29, 2013 at 8:14 PM, Jim Giner jim.gi...@albanyhandball.com wrote: On 5/29/2013 7:11 PM, Tim Dunphy wrote: Hello list, I've created an authentication page (index.php) that logs into an LDAP server, then points you to a second page that some folks are intended to use to request apache redirects from the sysadmin group (redirect.php). Everything works great so far, except if you pop the full URL of redirect.php into your browser you can hit the page regardless of the login process on index.php. How can I limit redirect.php so that it can only be reached once you login via the index page? Thank you! Tim I would simply place my redirect.php script outside of the web-accessible tree. The user can never type that uri into his browser and have it work. Depends on whether the redirect is by header or not, if it is via the Location header, then the browser has to be able to hit it. There is, though, a form of application architecture where everything is run through the index page, and it pulls things in via include/require as directed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limit access to php page
On Wed, May 29, 2013 at 8:20 PM, Glob Design Info i...@globdesign.com wrote: On 5/29/13 6:14 PM, Jim Giner wrote: On 5/29/2013 7:11 PM, Tim Dunphy wrote: Hello list, I've created an authentication page (index.php) that logs into an LDAP server, then points you to a second page that some folks are intended to use to request apache redirects from the sysadmin group (redirect.php). Everything works great so far, except if you pop the full URL of redirect.php into your browser you can hit the page regardless of the login process on index.php. How can I limit redirect.php so that it can only be reached once you login via the index page? Thank you! Tim I would simply place my redirect.php script outside of the web-accessible tree. The user can never type that uri into his browser and have it work. I always see this answer a lot but never any sample code of how to include that file using require_once() or include_once(). It would be nice to know the exact syntax of inclusion of such files. Say, for example if I put the login/redirect .php file 3-4 levels up from my webroot. Okay, first off, your application *has* to have some entry point that *is* accessible to a browser; otherwise nothing will find it. THe include/require(_once) directives take as an argument a file path including file name, there is no requirement they be in the same directory or lower as the calling file. So let's take this as a example: Application/webroot/index.php Application/includes/redirect.php Application/includes/login.php index.php: ?php session_start(); if (valid_user($_SESSION['current_user'])) { include_once(../includes/redirect.php); } else { include_once(../includes/login.php); } ? This the so-called single script entry style for designing your app. A consequence of this is that it makes bookmarking a bit different. One example of this is the PmWiki application. Everything runs through the main script (in this case it's called pmwiki.php instead of index.php, but that's immaterial here). Pages in the wiki are given on the path, such as: http://www.pmwiki.org/wiki/PmWiki/PmWiki, which makes it bookmarkable and work in the browser history. Others may not; it all depends on what you want. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: $d = '{result_ok:true,result_message:null,client_name:Radek Krej\u010da}'; echo Initial: $d\n; echo Decoded:\n; var_dump(json_decode($d)); echo \n\nPHP Version: .phpversion().\n; Output == Initial: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} Decoded: object(stdClass)#1 (3) { [result_ok]= bool(true) [result_message]= NULL [client_name]= string(13) Radek Krejča } PHP Version: 5.3.10-1ubuntu3.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Sat, May 25, 2013 at 3:14 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: Which I now see was what the second part was about. Perhaps there is actually something in $decrypted_data that is not legal JSON data that doesn't appear when you echo it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Sat, May 25, 2013 at 3:21 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Sat, May 25, 2013 at 3:14 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: Which I now see was what the second part was about. Perhaps there is actually something in $decrypted_data that is not legal JSON data that doesn't appear when you echo it? try checking json_last_error() after you attempt to decode $decrypted_data. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random
On Thu, May 23, 2013 at 3:51 PM, Last Hacker Always onpoint lasthack...@gmail.com wrote: Hey I need code for random number 1-30 for my site. function rand_from_1_to_30() { return 4; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
Back to the OP's request, Ken Pugh's Interface Oriented Design goes quite a long way in describing OO* and directly to the heart of why interfaces make so much sense as a way of designing your code. It does not show PHP examples, it tries to remain agnostic to language.
Re: [PHP] Re: Sync CSV files with MySQL Database.
On Sat, May 11, 2013 at 9:41 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 5/11/2013 12:57 AM, Carlos Sura wrote: Hello mates, Perhaps this seems to be a silly question, but it is not to me, here is the scenario: I know how to import CSV files with PHP to a MySQL database, the thing is, that CSV file is automatically feed by a third-party application, I want to do something to add just the new records, not all the records again. Any idea or example, will be really appreciated. Thanks! So - just how are you doing your import now? If you are breaking down the csv record into fields before adding it to the db, then it would be simple to take the 'key' fields and check your database before adding each record, no? While not strictly a PHP operation, you can compare two files and just get the new lines in the second file using the comm(1) command in shell: $ comm -1 -3 file1 file2 will simply emit the lines in file2 that are not in file1 If you keep around the last file loaded, and compare it using the above command with the newest file, you'll just have the new records to import. Then keep the newest file to compare with the next newest one. If you want to keep things all pure PHP, you could easily come up with a similar operation in PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undef func
On Fri, May 10, 2013 at 12:23 PM, Daniel Brown danbr...@php.net wrote: On Fri, May 10, 2013 at 6:15 AM, georg georg.chamb...@telia.com wrote: Hello ! im increasingly frustrated on my effort to get PHP/ODBC going with Apache on Linux (did it on MS XP, that was trixy but this is worse, nothing seem to be correct; utilities missing, erroneous file-directory references, crapy stringency in description...) well: undefined function odbc_connect() is what I currently find in my Apache Error_log So evidently I have sucessfully gotten at least PHP to get working, but to connect to ODBC (this then would indicate that dynamical loading of libararies is not successful, but what...) man tnx for clues georg Did you uncomment the line in php.ini to load the ODBC DLLs? Aren't DLLs a Windows thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize question
On Tue, May 7, 2013 at 10:16 PM, Curtis Maurand cur...@maurand.com wrote: find -name *.js -exec removestring.php '{}' \; That's how I get the I put file name. I think that I need the if statement to look at the filesize and make sure that I can open them and they are at least the size of the string that I'm looking to cleanse. That's how you pass the name into the php script; how does $inputfile get set (via $argv somehow) once you're inside php? This line: $inputline = fread($inputfile, filesize($argv[1])); Somehow, you opened $inputfile (assuming via fopen) by passing it a file name, presumably off the command line. Show me(us) where that happens. Would that joomla.modules would use the ftp layer if it were turned on. Then I wouldn't have to be scanning files dor malicious iframes or if clamav coyld remove offending code without removing the entire file... I don't know anything about joomla. tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand cur...@maurand.com wrote: Hello, I'm feeding a filename to a php script on the command line (command line program). I run the following against it: $inputline = fread($inputfile, filesize($argv[1])); I'm getting an error complaining that the second parameter can't be '0' The thing to look for, is how did you get $inputfile out of the command line, and why you'd expect the file name to be in $argv[1] at that point? Marco's suggestion isn't really going to work as $inputfile will be a file handle, and filesize() needs the name of the file. Maybe want to give us a wider look at what your code is doing? Generically, you can wrap this up as: function binread_file($filename) { $handle = fopen($filename,'rb'); if (FALSE === $handle) die(Unable to open $filename); $contents = fread($handle, filesize($filename)); if (FALSE === $contents) die(Unable to read $filename); return $contents; } -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize question
On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand cur...@maurand.com wrote: Hello, I'm feeding a filename to a php script on the command line (command line program). I run the following against it: $inputline = fread($inputfile, filesize($argv[1])); I'm getting an error complaining that the second parameter can't be '0' The thing to look for, is how did you get $inputfile out of the command line, and why you'd expect the file name to be in $argv[1] at that point? Marco's suggestion isn't really going to work as $inputfile will be a file handle, and filesize() needs the name of the file. Maybe want to give us a wider look at what your code is doing? Generically, you can wrap this up as: function binread_file($filename) { $handle = fopen($filename,'rb'); if (FALSE === $handle) die(Unable to open $filename); $contents = fread($handle, filesize($filename)); if (FALSE === $contents) die(Unable to read $filename); return $contents; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
On Tue, May 7, 2013 at 4:28 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip]Globals being used in a function. [/snip] *smacks forehead* It bites me all the time, too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
On Tue, May 7, 2013 at 9:42 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, May 7, 2013 at 4:28 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip]Globals being used in a function. [/snip] *smacks forehead* It bites me all the time, too. (Might be worth a refactor to eliminate globals from this, in fact? I honestly do not see the benefit to embedding that into a function like that.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generate onfly PDF
On Sat, May 4, 2013 at 3:31 PM, Rafnews raf.n...@gmail.com wrote: On 04.05.2013 23:05, Tedd Sperling wrote: On May 4, 2013, at 5:00 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Rafnews raf.n...@gmail.com wrote: Is there a solution to generate onfly PDF from HTML page, and from data user typed in form (let's say like a template) without using PECL ? i read that is hosting does not allow such extension, we can not generate PDF, so i would rather get a solution without such library. Moreover i'm searching a solution free and that i can supply with my web components. I created a component that should be able to generate PDF files quite often as service for user. Have a look at fpdf, its a class that doesn't need any special server-side support. Its basic, but is pretty good. Thanks, Ash Ash is right, here's an example I provide my students: http://rebel.lcc.edu/sperlt/citw185/examples/pdf/ Everything is there. Cheers, tedd AFAIK fpdf needs zlib and gd extensions. gd extension is almost everywhere enabled as extension, however i'm not sur zlib is enabled on most of servers... What do you think about that ? I would think zlib is even more ubiquitous than gd; it's used all over the place. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Load testing an app
On Tue, Apr 23, 2013 at 8:04 AM, Andrew Ballard aball...@gmail.com wrote: On Tue, Apr 23, 2013 at 2:29 AM, Adam Richardson simples...@gmail.com wrote: On Mon, Apr 22, 2013 at 10:41 PM, Andrew Ballard aball...@gmail.com wrote: The other developer in our office spent some time profiling the site with xdebug and found that an exec() call to netsh used on a couple pages seems to take 2-4 seconds to complete. Unfortunately, those exec() calls are the one function that we cannot test in our development environment. I'm wondering if it would be possible to carve out the part doing the netsh calls so they're not part of your web application's stack, and make them an asynchronous part? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Sat, Apr 20, 2013 at 9:37 PM, Glob Design Info i...@globdesign.com wrote: Night now this is just a test server. On the real thing I'll do it right. On 4/20/13 10:58 AM, Tedd Sperling wrote: On Apr 20, 2013, at 11:44 AM, Stuart Dallas stu...@3ft9.com wrote: On 20 Apr 2013, at 16:25, Jim Giner jim.gi...@albanyhandball.com wrote: Why are you allowing anyone to connect to your database from a form? A little OT, but... What do you mean by this question? How do you check someone's credentials if not by connecting to a db to verify the login? Cause I'm doing the same kind of thing all over the place. With good practices on validation and such before doing my query of course. I'm pretty sure that's not what tedd meant. The code is logging in to the database server using the username and password from the form. There are very few legitimate reasons to be doing this, so the question is well worth asking. -Stuart Stuart is exactly right. If you are checking someone's credentials to access your site, such as a user, then giving them the keys to the kingdom is a bit of an overkill. My advice, set up user_id and password fields in a user table for users you want to access some portion of your site, here's the code to do that: http://sperling.com/php/authorization/log-on.php Where I have said // define your user id here is the place to actually open your database and access your user table to gather the correct user_id and password. I also suggest that when you open the database you only use literals from a config.php file ($dbhost,$dbuser,$dbpass) for accessing the actual database and then check the user_id and password before giving them authorization to private areas. Keep the private stuff private! Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com That is a great point -- I was thinking this was a private app, but you should never ever ever ever ever ever (x infinity) allow wild wild web access to your database like this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for complete entered URL
On Sat, Apr 20, 2013 at 1:51 PM, Angela Barone ang...@italian-getaways.com wrote: I've written a script that logs all visits to a web site, complete with referrer and IP address. It also logs all 4xx errors. What I'd like to add to this is, if someone adds extra code after the page_name.php, to be able to capture any extra code and log that. I've tried: $_SERVER['QUERY_STRING'] $_SERVER['REDIRECT_QUERY_STRING'] $_SERVER['REDIRECT_URL'] So, since I wasn't exactly sure what got put into $_SERVER, and since I'm lazy, I tapped out the following script: ?php header(Content-type: text/plain); echo '$_SERVER:'.PHP_EOL; var_dump($_SERVER); ? When I called it with the following URL: http://localhost/~tamara/teststuffout/logger.php/one/two?a=true#fragment It showed all the stuff in $_SERVER as a result of that, including: [REQUEST_URI]= string(47) /~tamara/teststuffout/logger.php/one/two?a=true [PATH_INFO]= string(8) /one/two [QUERY_STRING]= string(6) a=true Interestingly, it appears nothing reports #fragment... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql_connect noob question
On Sun, Apr 21, 2013 at 5:20 AM, Glob Design Info i...@globdesign.com wrote: I am aware of the security implications. I will deal with that later. Right now I am just trying to get the WS architecture working. I'm wondering, if you can get it to work with the creds in the script, why do you have to have them come from a web form at all? What value is that providing at all? While it is certainly an interesting question as to why it doesn't work, if you have other things in your app to work on, just leave it and come back to it when you've time, if it's still that interesting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Sun, Apr 21, 2013 at 9:12 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Apr 21, 2013, at 9:32 AM, Stuart Dallas stu...@3ft9.com wrote: However, a more important question for me is why you are doing this. You say you are aware of the security implications, and that you'll deal with that later, but I question how you're going to deal with it. What exactly are you developing that requires DB credentials to come from a form on a web page? -Stuart You and I are asking the same question, but I am afraid the poster is not listening. Instead, he is pursuing a course of action that simply repeats his problem. His focus is on a specific tree instead of the forest. He doesn't want to widen his view. Until the poster answers our question, I'm afraid our recommendations will fall on deaf ears. Some days you can help and some days you can't. Cheers, tedd There's the Zen saying When the student is ready, the teacher appears. -- which to me says more about those attempting to teach than those attempting to learn. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Sun, Apr 21, 2013 at 9:49 AM, Stuart Dallas stu...@3ft9.com wrote: On 21 Apr 2013, at 15:46, tamouse mailing lists tamouse.li...@gmail.com wrote: On Sun, Apr 21, 2013 at 9:12 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Apr 21, 2013, at 9:32 AM, Stuart Dallas stu...@3ft9.com wrote: However, a more important question for me is why you are doing this. You say you are aware of the security implications, and that you'll deal with that later, but I question how you're going to deal with it. What exactly are you developing that requires DB credentials to come from a form on a web page? -Stuart You and I are asking the same question, but I am afraid the poster is not listening. Instead, he is pursuing a course of action that simply repeats his problem. His focus is on a specific tree instead of the forest. He doesn't want to widen his view. Until the poster answers our question, I'm afraid our recommendations will fall on deaf ears. Some days you can help and some days you can't. Cheers, tedd There's the Zen saying When the student is ready, the teacher appears. -- which to me says more about those attempting to teach than those attempting to learn. :) To me that means that you won't recognise the teacher until you're ready to learn. Teachers are always all around all of us, we just need to be willing to learn. Yes, that is the intended meaning. My alternate means that teachers should not try to teach students who aren't ready. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info i...@globdesign.com wrote: I know this has probably been answered already. When I pass a user name and password from a form to my PHP script and then pass those to mysql_connect it doesn't connect. When I paste those exact same values into mysql_connect as string literals it works. Can anyone tell me why this happens? I know the strings are identical to the literals I try in a test but they don't work when submitted via form. $form_user = $_POST[ 'user' ]; $form_pass = $_POST[ 'password' ]; # Connect to remote DB $LINK = mysql_connect( $host, $form_user, $form_pass ); And yes, my $host param is correct. Thanks, So, um, look at this gist: https://gist.github.com/tamouse/5430012 I know this never helps, but 'Works for me!' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
After all this, the OP remains unenlightened. This is just a waste of time. You are doing this wrong. There are existing tools that do what your client wants. A command line tool is not the same as the php library. are all met with I don't want to learn, just tell me what isn't working. Too bad.
Re: [PHP] mysql_connect noob question
No, that's for writing safe html output. If the user or password contains special chars, sending them through htmlspecialchars would turn them into html entities. i doubt you want that. I'm at a loss here. The only thing Ican think of is to try something like this at the top of the script: ?php error_reporting(-1); ini_set('display_errors',1); ini_set('display_startup_errors',1); header(Content-type: text/plain); var_dump($_POST); exit; ? and see precisely what is being passed in from your form. On Apr 19, 2013 10:50 PM, Glob Design Info i...@globdesign.com wrote: No, no spaces. I am wondering if I need to use htmlspecialchars() On Apr 19, 2013, at 7:17 PM, Jim Giner jim.gi...@albanyhandball.com wrote: On 4/19/2013 9:33 PM, Glob Design Info wrote: They aren't on the same server. The DB is on xeround.com, the web server is localhost. The host value is set and working. If I hard-code the user and password values in the mysql_connect() call and leave the host value as is, it connects fine. Only passing the user and password from the form cause it to fail. On 4/19/13 5:47 PM, David Robley wrote: Glob Design Info wrote: Sorry. The error displayed is: *Warning*: mysql_connect() [function.mysql-connect http://localhost/wservices/function.mysql-connect]: Access denied for user 'user'@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in */Library/WebServer/Documents/wservices/connect.php* on line *29* (But with the real user name, not just 'user') Thanks, On 4/19/13 3:28 PM, tamouse mailing lists wrote: On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info i...@globdesign.com wrote: I know this has probably been answered already. When I pass a user name and password from a form to my PHP script and then pass those to mysql_connect it doesn't connect. When I paste those exact same values into mysql_connect as string literals it works. Can anyone tell me why this happens? I know the strings are identical to the literals I try in a test but they don't work when submitted via form. $form_user = $_POST[ 'user' ]; $form_pass = $_POST[ 'password' ]; # Connect to remote DB $LINK = mysql_connect( $host, $form_user, $form_pass ); Please show the error you are getting from the mysql_connect And yes, my $host param is correct. Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php First guess is that you don't have privileges for 'user'@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges for 'user'. And, what are you using for the $host value? If the script and mysql are on the same server, it shouldn't need to be anything other than 'localhost'. Do your user or password contain spaces, thereby requiring quotes in your call? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question - Parse XML with PHP...
This will be brief as I'm on a tablet... On Apr 19, 2013 5:53 PM, dealTek deal...@gmail.com wrote: On Apr 19, 2013, at 3:32 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: page1.php is sending out to credit card company - getting processed - then coming back to the *same page1.php* with the XML data listed below... Please expand what you mean by sending out and coming back - is this a REST or SOAP API call? In that case, the response body is likely to be the XML. - so I'm not going to some other page to get it - it is coming to me to the same page I am on.. so - after the XML result comes in - I need to assign the php to the XML somehow... How do you recognize the XML result com(ing) in ? Hi tamouse, with my untrained eye - it appears that this is what is 'sending out' $data = sendXMLviaCurl($xmlRequest,$gatewayURL); This is the sending and receiving -- the function uses curl to send your xml request and returns the response from that. and this might be what is 'responding back' on the same page $gwResponse = @new SimpleXMLElement((string)$data); $data contains the response, this is how you are processing it. Skipping the long and monolithic code, what I will suggest is that you break things up into modules, functions and procrdures, and write unit tests that will check each piece seperately. After you've verified that each step is working, then you can start to integrate the pieces, following the stricture of keeping code (logic), data, and presentation seperate. It is much easier to deal with debugging when your code is simple and does only one thing. Break out the part you are asking here about, the API call. Build up a viable test request that will get you a known response and make sure you are getting what you expect. My suspicion is that the response here isnot what you expect.
Re: [PHP] mysql_connect noob question
On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info i...@globdesign.com wrote: I know this has probably been answered already. When I pass a user name and password from a form to my PHP script and then pass those to mysql_connect it doesn't connect. When I paste those exact same values into mysql_connect as string literals it works. Can anyone tell me why this happens? I know the strings are identical to the literals I try in a test but they don't work when submitted via form. $form_user = $_POST[ 'user' ]; $form_pass = $_POST[ 'password' ]; # Connect to remote DB $LINK = mysql_connect( $host, $form_user, $form_pass ); Please show the error you are getting from the mysql_connect And yes, my $host param is correct. Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question - Parse XML with PHP...
On Fri, Apr 19, 2013 at 4:04 PM, dealTek deal...@gmail.com wrote: On Apr 19, 2013, at 1:33 PM, Sebastian Krebs krebs@gmail.com wrote: A webpage is a file, that (usually) a browser downloads and parses. You'll do exactly the same :-) I don't know exactly, but you can try to pass the URL directly to simplexml_load_file(). If this doesn't work, download the content (for example with file_get_contents()) and pass it to simplexml_load_string(). There are obviously many other approaches, but you should now have an idea :-) Thanks Sebastian for the help Actually what is happening in my case is: page1.php is sending out to credit card company - getting processed - then coming back to the *same page1.php* with the XML data listed below... Please expand what you mean by sending out and coming back - is this a REST or SOAP API call? In that case, the response body is likely to be the XML. - so I'm not going to some other page to get it - it is coming to me to the same page I am on.. so - after the XML result comes in - I need to assign the php to the XML somehow... How do you recognize the XML result com(ing) in ? I hope I am making myself clear Thanks in advance for the help Or you use a specialized library like Guzzle. Am 19.04.2013 22:17 schrieb dealTek deal...@gmail.com: Hi all, newbie - just starting with trying to parse XML... $mylist = simplexml_load_file('thelist.xml'); then use a foreach to echo the data... ?php $mysongs = simplexml_load_file('songs.xml'); foreach ($mysongs as $songinfo) { $title=$songinfo-title; $artist=$songinfo-artist; $date=$songinfo['dateplayed']; echo $title.' --- '; echo $artist.' --- '; echo $date.' --- '; echo ' /br '; } ? that I get ... Question: how do you use $mylist when the xml is not as a file but is returned on a web page? an example of the real xml I am trying to work with is like this demo below Goal : when this response comes back - I would like to be able to get the data as php and then update the database example ?xml version=1.0 encoding=UTF-8? response result1/result result-textSUCCESS/result-text transaction-id1865264174/transaction-id result-code100/result-code authorization-code123456/authorization-code avs-resultN/avs-result cvv-resultN/cvv-result action-typesale/action-type amount12.00/amount ip-address::1/ip-address industryecommerce/industry processor-idccprocessora/processor-id currencyUSD/currency order-descriptionSmall Order/order-description merchant-defined-field-1Red/merchant-defined-field-1 merchant-defined-field-2Medium/merchant-defined-field-2 order-id1234/order-id tax-amount2.00/tax-amount shipping-amount0.00/shipping-amount billing first-nameJohn/first-name last-nameSmith/last-name address11234 Main St./address1 cityBeverly Hills/city stateCA/state postal90210/postal countryUS/country phone555-555-/phone emailt...@example.com/email companyAcme, Inc./company cc-number40**0002/cc-number cc-exp0118/cc-exp /billing shipping first-nameMary/first-name last-nameSmith/last-name address11234 Main St./address1 cityBeverly Hills/city stateCA/state postal90210/postal countryUS/country address2Unit #2/address2 /shipping product product-codeSKU-123456/product-code descriptiontest product description/description commodity-codeabc/commodity-code unit-of-measure1/unit-of-measure unit-cost5./unit-cost quantity1./quantity total-amount7.00/total-amount tax-amount2.00/tax-amount tax-rate1.00/tax-rate discount-amount2.00/discount-amount discount-rate1.00/discount-rate tax-typesales/tax-type alternate-tax-id12345/alternate-tax-id /product product product-codeSKU-123456/product-code descriptiontest 2 product description/description commodity-codeabc/commodity-code unit-of-measure2/unit-of-measure unit-cost2.5000/unit-cost quantity2./quantity total-amount7.00/total-amount tax-amount2.00/tax-amount tax-rate1.00/tax-rate discount-amount2.00/discount-amount discount-rate1.00/discount-rate tax-typesales/tax-type alternate-tax-id12345/alternate-tax-id /product /response -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to insert html code with PHP
On Apr 11, 2013 6:35 AM, Rafnews raf.n...@gmail.com wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? I am a little confused. If you want to insert the same bit of code in a php file, use the include function. If you need to do same thing across a number of pages, you probably have found a spot to refactor your code. If your talking about inserting it in real time in the client's browser, you want jQuery/AJAX for that, not php. (php can serve up the HTML in response to an AJAX request, though) thx. A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search array
On Thu, Apr 11, 2013 at 1:37 PM, Russell Brackett rbrack...@capitolabs.com wrote: I need help with this code to echo all items in the general database and not just the fields I'm searching for. ?php // filter function function cleanInput($input) { $search = array('OEM Name, Category, OEM Name'); $output = str_replace($search, '', $input); return $output; } //define layout name $layoutName = 'SYSTEMS CONFIGURATOR'; //block for pagination if(isset($_GET['page']) !empty($_GET['page'])){ $page = $_GET['page']; } else{ $page = 1; } $max = 20; $skip = ($page - 1) * $max; // grab their search query and clean it if($_POST){ $searchQuery= $_POST['q']; $_SESSION['searchQuery'] = $searchQuery; } else{ if(!isset($_SESSION['searchQuery'])){ header('location: index.php'); } } //$searchQuery= amat; // sanitize $cleanInput = cleanInput($_SESSION['searchQuery']); // Add 1st request for serial number $findSerial = $fm-newFindRequest($layoutName); $findSerial-addFindCriterion('OEM Name', $cleanInput); // Add 2nd request for category $findDesc = $fm-newFindRequest($layoutName); $findDesc-addFindCriterion('Category', $cleanInput); // search the description field //$find-addFindCriterion('description', $cleanInput); // sort the results //do a compound find with above two search conditions $compoundFind = $fm-newCompoundFindCommand($layoutName); $compoundFind-add(1, $findSerial); $compoundFind-add(2, $findDesc); $compoundFind-addSortRule('Serial #', 1, FILEMAKER_SORT_ASCEND); // set skip and max values $compoundFind-setRange($skip, $max); // run the search $result = $compoundFind-execute(); $records = $result-getRecords(); //get found count and get total page number $foundCount = $result-getFoundSetCount(); $totalPage = ceil($foundCount / $max); // create the smarty object $smarty = new Smarty(); $smarty-force_compile = true; $smarty-debugging = false; $smarty-caching = false; //$smarty-cache_lifetime = 120; ? Russell Brackett Web Developer Capitol Area Technology 3500 Comsouth Suite 500 Austin, Texas, 78744 rbrack...@capitolabs.commailto:c.h...@capitolabs.com Office 512-610-3246 Cell 979-412-3018 Capitol Area Technology: Integrity-Courtesy-Customer Satisfaction Where do these methods come from? // Add 1st request for serial number $findSerial = $fm-newFindRequest($layoutName); $findSerial-addFindCriterion('OEM Name', $cleanInput); // Add 2nd request for category $findDesc = $fm-newFindRequest($layoutName); $findDesc-addFindCriterion('Category', $cleanInput); // search the description field //$find-addFindCriterion('description', $cleanInput); // sort the results //do a compound find with above two search conditions $compoundFind = $fm-newCompoundFindCommand($layoutName); $compoundFind-add(1, $findSerial); $compoundFind-add(2, $findDesc); $compoundFind-addSortRule('Serial #', 1, FILEMAKER_SORT_ASCEND); // set skip and max values $compoundFind-setRange($skip, $max); // run the search $result = $compoundFind-execute(); I'm not familiar with them as one of the usual PHP database extensions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to insert html code with PHP
On Thu, Apr 11, 2013 at 1:12 PM, Rafnews raf.n...@gmail.com wrote: On 11.04.2013 19:19, Jim Giner wrote: On 4/11/2013 10:48 AM, Rafnews wrote: On 11.04.2013 13:34, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. Ok i can write an include_once('myfile.php'); however if i have an array in this file, other files where is the include_once(); do not recognize the array. here is an extract of this file to include (submenu.php): ?php $submenu = array(); $submenu[] = array('id' = 1,'class'='menuitem1'); $submenu[] = array('id' = 2,'class'='menuitem2'); // function in the same file function DisplayMenu($title){ // here i do not have access to the previous array $submenu define outside the function ... } as it is included the function DisplayMenu should also have access to $submenu array, no ? basic php question. Variables within any function are local to that function (except for superglobals like $_POST, $_SESSION, etc.). In order to reference a var defined/used outside that function you must add a global statement in the function: function () { global $submenu; ... ... } I solve my problem creating a class and now it works well. Probably the best solution. As you asked the question here, it would be nice to share your solution so others with a similar problem can benefit. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] webform spam prevention
On Apr 4, 2013 3:57 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Captchas are not very accessible. Not only do you often need a near super-human ability to identify the scrawl that's displayed, but if you can't actually see very well to start with (maybe your vision isn't perfect or you can't see at all) then you have to fall back to the audio replacement offered by the captcha. I've tried listening to some, and they are awful. That is the premise behind what the folks at textcaptcha are doing, going so far as to question the need for captcha itself One type I've seen (and use myself) which is gaining traction is that of asking for a human type of response to a question, or have them perform a simple mathematical problem, where the numbers are replaced with something else. Those can be great. The sticky part seems to be i18n and common user experience to answer the question, but this seem much easier to work with then throwing something horrible at your users. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] webform spam prevention
These folks might have direction for you: http://textcaptcha.com/really (And my apologies for top posting. It seems Google has forced their new mail compose widget upon me. I can no longer use my own editor to smoothly and easily edit message, and Google forces the top post.) On Tue, Apr 2, 2013 at 2:13 PM, Jen Rasmussen j...@cetaceasound.com wrote: Can someone recommend a best practice for blocking spam on web forms (aside from captcha) ? I've been for the most part utilizing a honeypot method and then individually blocking IPs and am looking for a more efficient method that won't require daily maintenance. I've come across this module: http://spam-ip.com/phpnuke-spam-module.php Has anyone used this method or have any other better suggestions? Thanks in advance! Jen Rasmussen Web Development Manager | Cetacea Sound Corp. 763-225-8465 | www.cetaceasound.com P Before printing this message, make sure that it's necessary. The environment is in your hands -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-FPM with Apache 2.4, forward all request for all virtual host
Sorry, in all of that, I don't see what the question is? On Wed, Apr 3, 2013 at 3:27 PM, Jose Nobile jose.nob...@gmail.com wrote: Hi, In Apache 2.2 http://httpd.apache.org/docs/2.2/ forward all request that point to phisical .php file to PHP-FPM http://php-fpm.org/ is as follow: LoadModule fastcgi_module http://www.fastcgi.com/ modules/mod_fastcgi.so FastCGIExternalServer /usr/sbin/php-fpm -socket /usr/local/php/lib/php.sock -idle-timeout 900AddHandler php-fastcgi .phpAction php-fastcgi /usr/sbin/php-fpm.fcgiScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm But in Apache 2.4 http://httpd.apache.org/docs/2.4/ is different, I'm following the tutorial in Apache Wiki http://wiki.apache.org/httpd/PHP-FPM but I don't understand as enable PHP for all virtual host, not each one. I search in PHP documentation, there is not mention about install on Apache 2.4: - Install PHP on Apache 2.x on Unix systemshttp://www.php.net/manual/en/install.unix.apache2.php - PHP-FPM Install http://www.php.net/manual/en/install.fpm.install.php - PHP-FPM Documentation http://php-fpm.org/wiki/Documentation This question was initially posted on stackoverflow: http://stackoverflow.com/questions/15773901/php-fpm-with-apache-2-4-forward-all-request-for-all-virtual-host Thank you for your help. Saludos, José Nobile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] webform spam prevention
I'd love to learn how to do that WITHOUT A MOUSE On Wed, Apr 3, 2013 at 8:10 PM, jomali jomali3...@gmail.com wrote: On Wed, Apr 3, 2013 at 7:33 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: These folks might have direction for you: http://textcaptcha.com/really (And my apologies for top posting. It seems Google has forced their new mail compose widget upon me. I can no longer use my own editor to smoothly and easily edit message, and Google forces the top post.) Actually, it doesn't, as I show below. On Tue, Apr 2, 2013 at 2:13 PM, Jen Rasmussen j...@cetaceasound.com wrote: Can someone recommend a best practice for blocking spam on web forms (aside from captcha) ? I've been for the most part utilizing a honeypot method and then individually blocking IPs and am looking for a more efficient method that won't require daily maintenance. I've come across this module: http://spam-ip.com/phpnuke-spam-module.php Has anyone used this method or have any other better suggestions? Thanks in advance! Jen Rasmussen Web Development Manager | Cetacea Sound Corp. 763-225-8465 | www.cetaceasound.com P Before printing this message, make sure that it's necessary. The environment is in your hands -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Actually, it doesn't. All you have to do is scroll to the bottom and add your material. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On Fri, Mar 15, 2013 at 8:34 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! The op wasn't about casting a string to an int but detecting if a string was just a string representation of an int. Hence using a regex to determine that. Regular expressions are not just about giving feedback to the user. Seemed to me that was exactly what it was about. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 5:00 AM, georg georg.chamb...@telia.com wrote: I have a need to make a pure display in a (HTML tagged area defined by) FRAME now so far I have only succeeded in making output into a frame by landing a clicked tag to open the new doc (href or src) in a specified frame. Possibly its not solvable with framework of frames. Not 100% sure of what you want, but can't you just populate the frames directly? frameset rows=10%,* frame name=upper src=upperframe.php frame name=lower src=lowerframe.php /frameset the link in the src attribute populates it initially. You already know how to populate them with links. ( I know, FRAMEs are a dying breed, depressed by HTML society, sorry deprecated possibly my issue is fixable by style-sheets but I havnt gotten that far yet, too complex ) Frames are not only deprecated, they are unsupported entirely in HTML5 (not that browsers won't continue to display them; just that they won't validate). Leap the hurdle and start to look at Web 3.0 stuff with backbone.js, twitter's bootstrap, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 9:11 AM, georg georg.chamb...@telia.com wrote: Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Maybe you want an IFRAME (Inline Frame) instead of FRAMESET/FRAME? Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg - Original Message - From: Stuart Dallas stu...@3ft9.com To: georg georg.chamb...@telia.com Cc: PHP General Sent: Friday, March 15, 2013 2:38 PM Subject: Re: [PHP] rather a HTML Q; however 2-FRAME On 15 Mar 2013, at 13:34, georg georg.chamb...@telia.com wrote: To make things clearer. I already have the frames since earlier and want to fill then again, so it is not at the initial filling of the frames at creation. You want one action to change the content in two frames? For that you'll need to use Javascript, or reload the parent frame, neither of which involve PHP. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = abc; if($a == (int)$a) echo YES; else echo NO; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = asdf1234; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. ?php $values = array(asdf1234, 123.123, 123); foreach ( $values AS $value ) { echo $value; if ( ctype_digit($value) ) { echo ' - is all digits'; } else { echo ' - is NOT all digits'; } echo 'br /'.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int Thanks, Ash http://www.ashleysheridan.co.uk That is so about is_numeric(), but once I know it's a numeric, coercing it to just an int is easy. *Validating*, rather than just assuring, that a string is an integer is another matter; if you need to give feedback to the user, etc., in which case a Regex is better. (One small nit, + is possible on integers, too.)
Re: [PHP] PHP context editor
On Fri, Mar 15, 2013 at 4:03 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: 2013/3/15 Karim Geiger gei...@b1-systems.de Hi Georg, On Thu, 2013-03-14 at 23:10 +0100, georg wrote: hello, annyone knows of some good PHP context editor freeware ? (tired of missing out on trivials like ; ) I don't know exactly what you mean by a context editor but if you want an editor with syntax highlighting try eclipse for an complete IDE (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on Linux Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux (multiplatform too). Or gedit on Gnome/Linux, or or or ... vim is not the end of what can a linux desktop can provide :D Regards -- Karim Geiger B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is great as a full-blown IDE, or Geany is quite nice if you need something in-between those two. The great thing is that they are all available on Windows too. Thanks, Ash http://www.ashleysheridan.co.uk Since we're doing this, lemme toss in my rec for Sublime Text 2. But I'm still holding onto my dear old Emacs, cos it's my frenz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rather a HTML Q; however 2-FRAME
On Fri, Mar 15, 2013 at 10:36 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 3/15/2013 10:11 AM, georg wrote: Actually I think you are right; what I would have liked (as a natural extension of the depression:) is actually a FRAME tag that stands without the FRAMESET and which as target=framename instead of the frame defining name=framename and which just displayed the src in that frame (immediatly as it does today) Im fairly new to PHP so Im bound to bounce into some walls, tnx. BR georg And apparently new to html as well if you want to use frames still :) Why not learn just a little css and html and develop something more current that you won't be re-visiting down the road some time and changing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Although maybe there's something ascetic about going through features from the beginning and learning to hate them as much as we did. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP] Accessing Files Outside the Web Root
On Mar 13, 2013 7:06 PM, David Robley robl...@aapt.net.au wrote: Dale H. Cook wrote: At 05:04 PM 3/13/2013, Dan McCullough wrote : Web bots can ignore the robots.txt file, most scrapers would. and at 05:06 PM 3/13/2013, Marc Guay wrote: These don't sound like robots that would respect a txt file to me. Dan and Marc are correct. Although I used the terms spiders and pirates I believe that the correct term, as employed by Dan, is scrapers, and that twerm might be applied to either the robot or the site which displays its results. One blogger has called scrapers the arterial plaque of the Internet. I need to implement a solution that allows humans to access my files but prevents scrapers from accessing them. I will undoubtedly have to implement some type of challenge-and-response in the system (such as a captcha), but as long as those files are stored below the web root a scraper that has a valid URL can probably grab them. That is part of what the public in public_html implies. One of the reasons why this irks me is that the scrapers are all commercial sites, but they haven't offered me a piece of the action for the use of my files. My domain is an entirely non-commercial domain, and I provide free hosting for other non-commercial genealogical works, primarily pages that are part of the USGenWeb Project, which is perhaps the largest of all non-commercial genealogical projects. readfile() is probably where you want to start, in conjunction with a captcha or similar -- Cheers David Robley Catholic (n.) A cat with a drinking problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If the files are delivered via the web, by php or some other means, even if located outside webroot, they'd still be scrapeable.
Re: [PHP] Re: Generating CRUD code for normalized db
On Mar 13, 2013 1:52 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Wed, 2013-03-13 at 19:24 +0100, Marco Behnke wrote: Am 13.03.13 12:57, schrieb Gary: ma...@behnke.biz wrote: Do us all a favor abnd stay away from open source if you do not honor the work us wannabes put into it. As I said before I wasn't aware you would feel that the cap fitted. If you do feel that, then perhaps instead of complaining at me for pointing it out, you would be better off employing that time increasing the quality of what you produce. So you said you tried Yii. But have you wasted some of your precious time trying out the extension that extends Yii in a way, that creating models and views with Gii get proper SELECT Boxes and stuff for relations? If I understood you correct, this is what you were looking for? At this point I don't think he's looking for an actual solution, but merely wants to moan about open source. OSS has flaws, of course, but even someone so narrow minded would have a hard time arguing in earnest that it suffered from too little choice and a lack of solutions to a problem. Thanks, Ash http://www.ashleysheridan.co.uk And isn't the point of OSS exactly that if it doesn't work for your needs, you enhance it? Whingeing about it seems a sure-fire way to not get any help.
Re: [PHP] Re: Populate input from another form
On Fri, Mar 8, 2013 at 9:17 PM, Jim Giner jim.gi...@albanyhandball.com wrote: On 3/8/2013 2:45 PM, John Taylor-Johnston wrote: I have a form form action=CRTP_Query.php id=CRTP_Query method=post target=_CRTPinput value=Query form=CRTP_Query type=submit/form OnSubmit, I want to include data from another form (form=DPRform). input name=DPRsurname type=text form=DPRform size=20 value=?php echo stripslashes($_POST[DPRsurname]);? I should use a hidden identical field and use form=CRTP_Query: input name=DPRsurname type=hidden form=CRTP_Query value=?php echo stripslashes($_POST[DPRsurname]);? But I have no idea how to populate the hidden field with the data from the viewable field. PHP cannot do this onsubmit, can it? Anyone have an example to show me please? Do I need to use jquery? I thought that the new 'form' attrib did that for you? No? My understanding is that the new form attribute on input lets you put an input tag *outside* any forms, and use the form= attribute to indicate which form it should go with. I think this may be more useful for mobile web apps than desktop browser apps. It doesn't let you copy a form element from one form to another. If you have multiple forms on one page, and want to submit data that is placed in one form with another one, you will have to do that with JS/jQeury. I don't have a ready example, but the basic concept is: * capture the form submit using an onclick * which calls a function that can gather up all the information from the other forms, and * build hidden form elements on the fly for the form you want to submit, and * then programmatically perform the submit This seems interesting enough that I might do up a tutorial on it when I have some time. Maybe Tedd already has one? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web Developer Opportunity
On Tue, Mar 5, 2013 at 6:42 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Mar 6, 2013 at 1:34 AM, Tedd Sperling t...@sperling.com wrote: On Mar 5, 2013, at 7:18 PM, Matijn Woudt tijn...@gmail.com wrote: On Wed, Mar 6, 2013 at 1:16 AM, Tedd Sperling t...@sperling.com wrote: On Mar 4, 2013, at 3:10 PM, Allison Garcia agar...@smallworldlabs.com wrote: -snip- What are you offering? $2/hr. Oh, It's not Friday.. Is it more on Friday? Friday is the time for jokes on this list, right? For you, one dollar on Friday. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange Error calling method of wsdl based SOAP client
On Wed, Mar 6, 2013 at 1:36 PM, Tobiah tshep...@rcsreg.com wrote: I'm talking to the Membersuite SOAP api. They have a Get() method and a Save() method for objects. I call Get(), and get an object back representing an individual. I pass it back to Save() and I get this: Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://membersuite.com/contracts:objectToSave. The InnerException message was 'Element Value from namespace http://schemas.datacontract.org/2004/07/MemberSuite.SDK.Types cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'. Please see InnerException for more details. in /home/toby/public_html/membersuite/-:115 Stack trace: #0 /home/toby/public_html/membersuite/-(115): SoapClient-__soapCall('Save', Array, NULL, Array, Array) #1 /home/toby/public_html/membersuite/-(18): Membersuite-call('Save', Array) #2 {main} thrown in /home/toby/public_html/membersuite/- on line 115 The whole store with source code is here: http://register.rcsreg.com/r2/membersuite Thanks for any help. I've been working on this for over a month now. Tobiah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I would mock the SOAP save call in your tests and inspect it to see that it is indeed what should be being sent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.4 Help
On Wed, Mar 6, 2013 at 10:41 AM, Great Recordings, LLC mu...@great-recordings.com wrote: I need help from someone knowledgeable about PHP and I hope I am seeking it in the right place. I beg your forgiveness if this is not the right place. I purchased a software (1-2-3 Music) a few years ago and have used parts of it on my website so people can buy and download MP3 songs. I have tried to contact the company I purchased the program from but they seem to be out of business. Have also tried contacting the main developer but am not able to make contact…my emails to him are rejected by his mail box). Beginning on April 1, 2013 my Web Hosting company will no longer support PHP programs less than Version 5.4...Register_Globals will be turned off. I have tested my software with the new upcoming restrictions and find none of my song downloads will function with the PHP 5.4 version. Will someone tell me if the small module included on the bottom of this note will function properly under PHP 5.4? (Register_Globals turned off). If it does not function properly with Register_Globals turned off, is there a way to make changes to the module so it does function properly with Register-Globals turned off? Thank you very much Floyd J. Badeaux - Module: ?php define (DOCMA_HOME, /homepages/37/d48651986/htdocs/htdocs/1-2-3-music-store/docma_08306s); ini_set(display_errors, 0); require_once (DOCMA_HOME./system/prepend.inc); define (DOCUMENT_ROOT, preg_replace(/()+/, /, realpath(.))); session_start(); $processName = $_REQUEST[pname]; $process = process_get_process($processName); $process-execute(); ? --- Suggestion: change this line: ini_set(display_errors, 0); to this: error_reporting(-1); ini_set('display_errors', true); ini_set('display_startup_errors', true); as a start to see what the failures actually are. If there are syntax errors in the PHP, they will still not be shown, you should vet the source by running it through php -l (lint) to ensure no syntax errors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Open form in new window
On Tue, Mar 5, 2013 at 8:37 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 3/4/2013 11:04 PM, tamouse mailing lists wrote: I would like to just take a step back and ponder what the user experience of this will be. Click a submit button, one of *many* as the OP says, and a new browser window opens? I don't think that is how most people experience the web these days. Technicalities of how one does this notwithstanding, I am urging the OP to consider their users. The OP's use of the word 'many' is subjective. Too you it might mean 5, to him it could very well mean 3. To me, either one is possible on many of my forms, since I try to provide the user with flexibility and function on each of my screens. Sometimes there are several things that a form could lead to, depending upon what the user needs to see or do. In this case, I can see the purpose for a separate window being opened. Sometimes (as a user myself) I have wished to have a screen of data appear to support my primary screen's use. It opens, I get some new input and I close it, going back to where I was. We obviously don't know the OP's task, but I can see usefulness and appreciate it. Just my $.02 Yes, it's all subjective, yes, what you like may not be what I like, and so on. Yet, UX people do agree on many things, and this is one of them. Popping a new browser window should be the user's choice. Not doing so leads to not only confusion, but also a11y problems. Which window gets focus? How does the user get back? These are real considerations when someone has to use a screen reader, or Voiceover. Navigating various windows can also be a problem for people with restricted mobility. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cold Intermediate Programmer trying to modularize website...
On Tue, Mar 5, 2013 at 12:42 PM, Barry Smith scs.bns...@gmail.com wrote: I know less about WordPress than I do about Joomla, but I did notice a template site that I cannot find any support for (cool templates) which supports both Joomla and WordPress, as well as HTML/CSS. I know that there are lists of buttons which I was going to rely on PHP to handle. The problem with WordPress and Joomla is that the current webhost will allow PHP, but will not allow MySQL. :) I know... time to move the site to a FREE php/MySQL host. I already have one in mind, but the throughput from the host at a major ISP (Charter) is hard to leave... since the client has been paying for that webhost for over 20 years. A GoDaddy hosted site I might be able to talk her into, in a pinch... but she is a firm believer in the idea that you pay for quality. It might be very hard convincing her to consider another webhost that isn't local, and Charter is a local (non-toll-free) phone call away. Thank you for the suggestion. A WordPress site might actually be the solution... if she is willing to leave Charter. -- Barry Smith c 704-497-4217 e scs.bns...@gmail.com On Tue, Feb 26, 2013 at 11:22 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: Have you considered setting this up in wordpress? I'm not familiar with Charter as an ISP, or what they offer. I'm guessing they are on a consumer web hosting plan? Something to look at might be if there's a low-tier commercial hosting plan with Charter, that might be better than moving off to GoDaddy (which I have very personally strong averse feelings to, so take that into account). Also, not trying to talk you out of a job or anything like that, but there are also things like wordpress.com and other public blogging platforms. A completely left-field thing now is also github pages. You can't run PHP, but wow can you make a great backbone.js app there. Anyway, just tossing out ideas. They're free, so you can ignore them. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cold Intermediate Programmer trying to modularize website...
On Tue, Mar 5, 2013 at 5:55 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, Mar 5, 2013 at 12:42 PM, Barry Smith scs.bns...@gmail.com wrote: I know less about WordPress than I do about Joomla, but I did notice a template site that I cannot find any support for (cool templates) which supports both Joomla and WordPress, as well as HTML/CSS. I know that there are lists of buttons which I was going to rely on PHP to handle. The problem with WordPress and Joomla is that the current webhost will allow PHP, but will not allow MySQL. :) I know... time to move the site to a FREE php/MySQL host. I already have one in mind, but the throughput from the host at a major ISP (Charter) is hard to leave... since the client has been paying for that webhost for over 20 years. A GoDaddy hosted site I might be able to talk her into, in a pinch... but she is a firm believer in the idea that you pay for quality. It might be very hard convincing her to consider another webhost that isn't local, and Charter is a local (non-toll-free) phone call away. Thank you for the suggestion. A WordPress site might actually be the solution... if she is willing to leave Charter. -- Barry Smith c 704-497-4217 e scs.bns...@gmail.com On Tue, Feb 26, 2013 at 11:22 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: Have you considered setting this up in wordpress? I'm not familiar with Charter as an ISP, or what they offer. I'm guessing they are on a consumer web hosting plan? Something to look at might be if there's a low-tier commercial hosting plan with Charter, that might be better than moving off to GoDaddy (which I have very personally strong averse feelings to, so take that into account). Also, not trying to talk you out of a job or anything like that, but there are also things like wordpress.com and other public blogging platforms. A completely left-field thing now is also github pages. You can't run PHP, but wow can you make a great backbone.js app there. Anyway, just tossing out ideas. They're free, so you can ignore them. :) Oh, another thing. AWS RDS (MySQL in the cloud) is possible, but it's horribly expensive to run for a low-access site. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Mon, Mar 4, 2013 at 5:58 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2013-03-05 at 10:19 +1030, David Robley wrote: Angela Barone wrote: On Mar 4, 2013, at 11:33 AM, Ashley Sheridan wrote: You can manually write a cookie on your machine, or use a special script that only you visit that contains a setcookie() call (it only need be set once). From there on, you can check the $_COOKIES super global for the presence of your cookie. I don't know why, but I can't get cookies to work. Here's a script I'm calling from my browser: ?php $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain); ? !DOCTYPE html html lang=en head meta charset=utf-8 / titleTest Page/title /head body ?php echo 'Cookie is: '.$_COOKIE[$cookie].br; ? ?php echo 'Domain is: '.$domain.br; ? /body /html The domain is being displayed but the cookie is not. There's no cookie in the browser prefs, either. What am I doing wrong? Angela Misunderstanding what $cookie contains? It is a boolean, i.e. it will be true or false depending on whether the cookie was set or not. To echo the contents of a cookie, you need to use the cookie name, viz ?php echo 'Cookie is: '.$_COOKIE['test2'].br; ? -- Cheers David Robley Oxymoron: Sisterly Love. Not just that, but if you set a cookie, you won't be able to retrieve it in the same script I believe. It's only available in the $_COOKIES array once you refresh the page, as that's when the super global is populated from the cookie data that the browser sends. Thanks, Ash http://www.ashleysheridan.co.uk Same script *invocation*. The cookie gets set when the response is sent back to the client. If the client calls the same script again, that cookie then uploaded. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Open form in new window
I would like to just take a step back and ponder what the user experience of this will be. Click a submit button, one of *many* as the OP says, and a new browser window opens? I don't think that is how most people experience the web these days. Technicalities of how one does this notwithstanding, I am urging the OP to consider their users. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
On Sat, Mar 2, 2013 at 10:35 AM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip] Speak for yourself, I'm an autumn turkey! -Stuart [/snip] My body is an Autumn turkey, my head says differently - save on certain mornings when too much popping and cracking occurs. See, you can't really call yourself old until that's pooping and cramping... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Joining fixed text to a SUBJECT variable
On Sat, Mar 2, 2013 at 5:04 AM, Michael CALDER mikecal...@optusnet.com.au wrote: -- G'day , G'day, cobber! Here is the current contact2.php file - but the SUBJECT only shows as RVRA Contact Form - Others have addressed that, as well as not needing the stripslashes. If you will permit, I have a few other comments. If not, simply delete. No worries! I added line numbers to make notation easier. 1 ?php 2 3 // get posted data into local variables 4 $EmailAddress = Trim(stripslashes($_POST['EmailAddress'])); 5 $EmailTo = mikecal...@optusnet.com.au; You might want to use a configured value instead of the direct string. If you have to change the email address, or other similar things, it's easier to change a configuration file than looking through code. 6 $Subject = RVRA Contact Form - ,$MessageSubject; Similarly here, the subject of the email could be a configured item. 7 $Name = Trim(stripslashes($_POST['Name'])); 8 $EmailAddress = Trim(stripslashes($_POST['EmailAddress'])); You've duplicated this from line 4. 9 $YesNo = Trim(stripslashes($_POST['YesNo'])); 10 11 $MessageSubject = Trim(stripslashes($_POST['MessageSubject'])); 12 $Message = Trim(stripslashes($_POST['Message'])); 13 14 // send email 15 if(!isset($_REQUEST['identiPIC_selected'])){exit;} Instead of just throwing an exit here, and giving the user a blank page, maybe better to redirect to some landing page. This is done by issuing a header before any other text is sent: header(Location: your-error-landing-page.html); 16 17 $identiPIC[1] = Bird; 18 $identiPIC[2] = Logo; 19 $identiPIC[3] = Flower; 20 21 if($_REQUEST['identiPIC_selected'] !== $identiPIC){print meta 22 http-equiv=\refresh\ content=\0;URL=error-pic.html\; exit;} Here, instead of making the browser refresh, do a redirect to a landing page. See above for header. 23 24 25 26 27 // prepare email body text 28 $Body = ; 29 30 $Body .= Name: ; 31 $Body .= $Name; 32 $Body .= \n; 33 34 $Body .= EmailAddress: ; 35 $Body .= $EmailAddress; 36 $Body .= \n; 37 38 $Body .= RVRA Member; 39 $Body .= $YesNo; 40 $Body .= \n; 41 42 43 44 $Body .= Message Subject: ; 45 $Body .= $MessageSubject; 46 $Body .= \n; 47 48 $Body .= Message: ; 49 $Body .= $Message; 50 $Body .= \n; This is the ideal place for a HEREDOC (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) to make your code more readable and maintainable: $Body ENDOFMAIL Name: $Name EmailAddress: $EmailAddress RVRA Member: $YesNo Message Subject: $MessageSubject $Message ENDOFMAIL 51 52 53 // send email 54 $success = mail($EmailTo, $Subject, $Body, From: $EmailAddress); The fourth parameter is actually any additional headers, and should be constructed in the standard mail format, the header name, the proper contents and terminated by a CR-LF. In this case, the From: header needs to correspond to an RFC2922 address, or list of such addresses. If you want to use the angle brackets, you need to put in a user name before it. Otherwise, simply omit the brackets. All the additional headers specified in the fourth parameter need to end with a CR-LF as well, not just a LF, or in this case, nothing. The way this is set up, the following would be proper setup: $AdditionalParms = From: \$Name\ $EmailAddress\r\n; Then: $success = mail ($EmailTo, $Subject, $Body, $AdditionalParms); The escaped quotes around $Name allow for such things as non-alnum+space characters, i.e., something like this would be allowed: From: Samuel L. Jackson, Jr. sammyj...@example.com However, in this case, the email is NOT actually being sent from $EmailAddress, it is being sent from your server, so putting in that address is technically a spoof. While that's not illegal, some mailing systems will call that a spam message, as the From and Sender do not match, and From won't be found at the originating mail node. 55 56 // redirect to success page 57 if ($success){ 58 print meta http-equiv=\refresh\ content=\0;URL=thanks.html\; 59 } 60 else{ 61 print meta http-equiv=\refresh\ content=\0;URL=error-pic.html\; 62 } 63 Here again, give the idea of using a header redirect instead of a browser refresh a go. 64 ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Close enough to Friday...
On Thu, Feb 28, 2013 at 9:59 PM, Adam Richardson simples...@gmail.com wrote: On Thu, Feb 28, 2013 at 10:19 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: Congratulations on ditching the Dreamweaver Templates! Now, as to preprocessing: how does this benchmark out? Have you noticed a significant different in processing time, memory usage, disk usage, etc? Well, it depends... For example, if you use code similar to the inlined function example, there is a difference. In that example, the inlined code runs almost twice as fast. ?php $a = 1; $b = 2; $start = microtime(); for ($i = 0; $i 1; $i++) { $result = ($a $b $a % 2 !== 0) ? $a : (($b % 2 !== 0) ? $b : (($a % 2 !== 0) ? $a : null)); } $runtime = microtime() - $start; echo $runtime; ? ?php function maxodd($a, $b) { return ($a $b $a % 2 !== 0) ? $a : (($b % 2 !== 0) ? $b : (($a % 2 !== 0) ? $a : null)); } $a = 1; $b = 2; $start = microtime(); for ($i = 0; $i 1; $i++) { $result = maxodd($a, $b); } $runtime = microtime() - $start; echo $runtime; ? That said, there's tremendous variance across the possible range of function types (e.g., number of args, complexity of function, etc.), so there's no guarantee you'll always see a worthwhile (which is also subjective) improvement. I'm going to use inlining for functions that output html-escaped output (the function wraps htmlspecialchars to allow whitelisting), as they're frequent and simple, the very type of function that is easily inlined and provides some speed benefit. In terms of the templating, in my tests using siege comparing Dreamweaver Templates vs PHP includes, I've typically seen significant benefits when the template requires multiple includes, with the effect dropping off as the number of includes approaches 0. These results should be the same. Again, there seems to be a broad range of considerations (in terms of using APC, using absolute paths helped the include performance: http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat) There are usually bigger ways to enhance performance (data persistence, etc.), but in the same way that I try to teach my little girls to turn off the faucet in between spitting into the sink even though monitoring showers can do much more to save water, when I see simple ways I can consistently save cycles, I try to implement them :) Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Awesome. Not unsuspected, but still awesome. I know some site schemes that do a lot of nested templating; and from my work on rails, rendering a site with tons of partials (the same sort of thing) can really slow page loads down. I know Smarty caches the compiled templates automatically, and refreshes if a given template changes from the cached version, and this does speed things up somewhat, but it doesn't actually do the full up staticify (if i may be so bold!) like this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
On Fri, Mar 1, 2013 at 11:56 AM, Daniel Brown danbr...@php.net wrote: On Fri, Mar 1, 2013 at 12:54 PM, Jim Giner jim.gi...@albanyhandball.com wrote: What gives you such optimism? I recently saw a list of languages in use and PHP has dropped quite a bit over the last 5 or more years. Being a relative newbie myself, I'm happy that PHP exists and is so readily available to us hobbyists, etc. Certainly am in favor of your optimism, but curious (hey it's Friday!) about your prediction. Just knowing how the patterns go. It's always the same, and it will likely be the same again. No guarantees, but all it takes is a bit of fostering of the community to return it to a decently-vibrant forum. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Things come, things go, ebb and flow. PHP is easy for people to pick on, for some good and not so good reasons. It, to me, is still the easiest programming language for someone to learn, in *NO* small reason because of all the excellent documentation and community contributed comments. And places like this list. I've been working in Rails for the past several months, and although I much prefer Ruby as a language, the documentation on libraries, extensions, packages, and frameworks is rather lacking. The ruby doc website has the space for users to add comments, but there's hardly any. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Holding datetimes in a DB.
On Fri, Mar 1, 2013 at 11:53 AM, Matijn Woudt tijn...@gmail.com wrote: On Fri, Mar 1, 2013 at 11:49 AM, Richard Quadling rquadl...@gmail.comwrote: Hi. My heads trying to remember something I may or may not have known to start with. If I hold datetimes in a DB in UTC and can represent a date to a user based upon a user preference Timezone (not an offset, but a real timezone : Europe/Berlin, etc.) am I missing anything? Richard. I would only use this if you're planning to have servers all around the world in different timezones, then it would be easier to interchange data. Otherwise, stick with ur local timezone and it will save you a lot of unneeded timezone conversions probably. - Matijn This may be just me, but I've always preferred my servers, database, and such to run UTC, and let users select their own time zone they'd like to see. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Close enough to Friday...
On Thu, Feb 28, 2013 at 7:50 PM, Adam Richardson simples...@gmail.com wrote: Just wanted to toss this out as something I quick developed in case it could help others: https://github.com/AdamJonR/PreHP Essentially, I just wanted a quick pre-processor that would work with PHP so I could limit some of the processing done at runtime. As opposed to C macros, I wanted to design it so that files could/should be developed to be valid html/php without the preprocessor. The preprocessor merely speeds the performance. The example for templating could be redone to use includes and then replace those with the inlined content, I just prefer to work with skeleton HTML so I can validate the XHTML as I go within the static file rather than having to check the content on a test server. The preprocessor is dumb (for now, I'm not parsing the PHP to ensure the comments are not contained within strings, etc.), but this shouldn't pose an issue for most situations. Anyways, I just whipped this up so I could ditch Dreamweaver Templates (which I used so the templating happened prior to runtime, too), as I'm trying to save some money and I don't want to upgrade to the next version :) Happy Friday! Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Congratulations on ditching the Dreamweaver Templates! Now, as to preprocessing: how does this benchmark out? Have you noticed a significant different in processing time, memory usage, disk usage, etc? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stupid question
On Wed, Feb 27, 2013 at 2:42 AM, Sebastian Krebs krebs@gmail.com wrote: 2013/2/27 tamouse mailing lists tamouse.li...@gmail.com Well, *I* have a stupid question: is $lhv = expr the same as $lhv = expr ?? Yes :) Because an operator = doesn't exists, thus the lexer will split them into the tokens = , or = WHITESPACE respectively. The parser again ignores whitespaces. Thanks; thought I was seeing something new, and/or going nuts -- apologies for the thread hijack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cold Intermediate Programmer trying to modularize website...
Have you considered setting this up in wordpress? On Tue, Feb 26, 2013 at 5:14 PM, Barry Smith scs.bns...@gmail.com wrote: Yes, Jim, and tamouse, Apologies for the length of this response. I am asking for help organizing the rewrite of the site, from a LOT of HTMLs that have 90% in common, containing a couple of php links to do a php mail form and command, and an article... to a template-article-footer format. I am having a problem visualizing how I need to proceed (from the highest level), so I was asking for opinions on how to organize the index.php plus template.php plus home.article design... at the highest level. From the sounds of it ( I didn't bother to un-zip his file) it appears that he just wants to create a model template and fill in the center (the 'article'?) appropriately depending upon the user's request That is basically the project. I have used Joomla for sites like this before, but the business owner is not tech-savvy (not a power-user) in the least. Setting up Joomla for her site, teaching her how to navigate Joomla to modify articles, and giving her the access to the articles that she wants access to is WAY beyond what she is capable of and REALLY overkill for this small website. Besides, she could destroy the whole site as Joomla admin or a Joomla user very easily. She wants access to some of the articles, ONLY to change the wording of some articles (the article on the about page and the home page, and maybe a specials page yet to be designed) but I am trying not to giving her the ability to destroy the whole site because she has access to. I want to place .article files in a folder, and let her work on the articles. I can build a default article into the PHP if the document that she edits gets deleted. Yet she's a smart business owner... if i have access to the articles to change them and I mess up, I don't want the website to disappear was how she expressed it to me. The other wrinkle (at a programming level) is that she wants a header in every email that the website sends to the company, to track which link was clicked. I'm thinking that (as an example of the changes that I need to make to the files contained in the zip )-- I. index.html would require index.php. 1) index.php would define variables for that page, i.e. a var building=index or about or services or products, and then include template.php, a home.article file, and a footer.php . 2) template.php would use the building value to build each custom header and left column and right column. Within the header, it would use the variable building to send a label that identifies building and another value header to contact.php (see more about contact.php later). Programatically, template.php will highlight tab buttons at the top of the page (if they need to be highlighted) and menu buttons in left column (if they need to be highlighted) dependent on the value of building, and in column 2 choose the correct list of buttons to display in a vendor list dependent on the value of building. 3) footer.php would use the building value to build each custom footer for the page. Within the footer, it would use the variable building to send a label that identifies building and another value footer to contact.php (see more about contact.php later). II. contact.php will bring up an email form, use the label passed in to create a custom header to insert into the php mail command/function. III/IV/V/VI. Each HTML in the site will have an associated php that calls template, grabs any appropriate .article file, calls footer. Does that structure make sense? Are there gotchas, things to verify and watch out for that you have run into doing similar projects? As a past for this design procedure, I worked on a sales agent site years ago that did a similar build each page dependent on logged.in.user ... but the control for this project is not logged.in.user in this project... the control is page.being.built . Thank you for the input, and any links to online articles that I should probably read, or topics that I should make sure I understand completely in php. Peace, -- Barry Smith c 704-497-4217 e scs.bns...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stupid question
On Tue, Feb 26, 2013 at 4:41 PM, Jim Lucas li...@cmsws.com wrote: On 02/26/2013 01:27 PM, Curtis Maurand wrote: I have the following: $dsn = mysqli://$username:$password@$hostname2/$database; $options = array( 'debug' = 3, 'result_buffering' = false, ); $dbh = MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2-getMessage()); } function tallyCart($_u_id,$dbh){ while($row = $result-fetchrow(MDB2_FETCHMODE_ASSOC)) { Talking in code. The above two lines tell me... $dbh != $result isset($result) === false $_showCheckOut=1; $_pdetail=new ProductDetail($row{'product_ID'}, $row{'product_Quantity'}, $_u_id); $_getSubTotal += $_pdetail-_subTotal; $_counter++; } } I'm getting: Call to undefined method MDB2_Error::fetchrow() anyone have any ideas? Can I not pass a database handle to a function? Thanks, Curtis -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well, *I* have a stupid question: is $lhv = expr the same as $lhv = expr ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arrays
On Mon, Feb 25, 2013 at 9:51 PM, Karl DeSaulniers k...@designdrumm.com wrote: Never mind. I found a different function that reads out the children as well into the array. function xml_parse_into_assoc($data) { $p = xml_parser_create(); xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($p, $data, $vals, $index); xml_parser_free($p); $levels = array(null); foreach ($vals as $val) { if ($val['type'] == 'open' || $val['type'] == 'complete') { if (!array_key_exists($val['level'], $levels)) { $levels[$val['level']] = array(); } } $prevLevel = $levels[$val['level'] - 1]; $parent = $prevLevel[sizeof($prevLevel)-1]; if ($val['type'] == 'open') { $val['children'] = array(); array_push($levels[$val['level']], $val); continue; } else if ($val['type'] == 'complete') { $parent['children'][$val['tag']] = $val['value']; } else if ($val['type'] == 'close') { $pop = array_pop($levels[$val['level']]); $tag = $pop['tag']; if ($parent) { if (!array_key_exists($tag, $parent['children'])) { $parent['children'][$tag] = $pop['children']; } else if (is_array($parent['children'][$tag])) { if(!isset($parent['children'][$tag][0])) { $oldSingle = $parent['children'][$tag]; $parent['children'][$tag] = null; $parent['children'][$tag][] = $oldSingle; } $parent['children'][$tag][] = $pop['children']; } } else { return(array($pop['tag'] = $pop['children'])); } } $prevLevel[sizeof($prevLevel)-1] = $parent; } } $params = xml_parse_into_assoc($result);//$result = xml result from USPS api Original function by: jemptymethod at gmail dot com Duplicate names fix by: Anonymous (comment right above original function) Best, Karl On Feb 25, 2013, at 7:50 PM, Jim Lucas wrote: On 02/25/2013 05:40 PM, Karl DeSaulniers wrote: Hi Guys/Gals, If I have an multidimensional array and it has items that have the same name in it, how do I get the values of each similar item? EG: specialservices = array( specialservice = array( serviceid = 1, servicename= signature required, price = $4.95 ), secialservice = array( serviceid = 15, servicename = return receipt, price = $2.30 ) ) How do I get the prices for each? What would be the best way to do this? Can I utilize the serviceid to do this somehow? It is always going to be different per specialservice. TIA, Best, Karl DeSaulniers Design Drumm http://designdrumm.com This will never work. Your last array will always overwrite your previous array. Here is how I would suggest building it: $items = array( 1 = array( serviceid = 1, servicename= signature required, price = $4.95 ), 15 = array( serviceid = 15, servicename = return receipt, price = $2.30 ) ) This will ensure that your first level indexes never overwrite themselves. But, with that change made, then do this: foreach ( $items AS $item ) { if ( array_key_exists('price', $item) ) { echo $item['price']; } else { echo 'Item does not have a price set'; } } Resources: http://php.net/foreach http://php.net/array_key_exists -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Would this work for you? http://us.php.net/manual/en/function.xml-parse-into-struct.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe,
Re: [PHP] Big File Upload how to catch stream
On Sun, Feb 24, 2013 at 1:10 PM, Wim wim.stock...@gmail.com wrote: Hello, I have been looking how to upload big files more than 1GB , with php but it doesn't work well. I guess php POST multipart method is to memory consuming. Is there a way , like in the apache.commons to catch the stream and handle it ? I've looked at the rfc1867.c file implementation and it seems that this is where the memory goes really up. Is there a way we could change this ? Kind Regards Wim Maybe look at http://stackoverflow.com/questions/10961538/uploading-very-large-files-5gb-to-15gb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Upload MultiPart
On Sun, Feb 24, 2013 at 1:07 PM, user@domain.invalid wrote: Hello, I have been looking how to upload big files more than 1GB , with php but it doesn't work well. I guess php POST multipart method is to memory consuming. Is there a way , like in the apache.commons to catch the stream and handle it ? I've looked at the rfc1867.c file implementation and it seems that this is where the memory goes really up. Is there a way we could change this ? Kind Regards Wim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Although loathe to respond to someone listed as user@domain.local... Maybe look at http://stackoverflow.com/questions/10961538/uploading-very-large-files-5gb-to-15gb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cold Intermediate Programmer trying to modularize website...
On Fri, Feb 22, 2013 at 1:48 PM, scs.bns...@gmail.com wrote: Intro -- Sorry to post in php.general . Just found the newserver, and I'm still trying to figure out where to post this question. Thus, I posted in .general ... either to get help or find out in which newsgroup I should post my question. Thank you. Website description -- (have included files from the website as reference) The site runs all CSS through one style.css for all div declarations. I have attached a zip which includes the index.html file, the style.css and the cgi directory with multiple contact*.php for each different link as a sample of where I'm starting from. On each page, there is a header block (with a contact*.php link), navigation tabs and a navigation menu, a left column, a right column, an article, and a footer (with a contact*.php link). Each page has an article, like index.html. First part of question (php-focused)-- I'd like to change the multiple contact.php modules that I call from the ../cgi/ directory into one contact.php program that can receive a string paramenter. I'd like to pass a parameter string into the new contact.php which would contain a label which identifies the link that was clicked to call the single contact.php and be put on the header line (currently hard-coded in multiple copies of contact*.php). This is to track which link was clicked on which page... as you can see by the naming convention of my contact*.php modules. Second point of discussion (more HTML grabbed from PHP to complete the page) -- I'd like to (use index.html from the zip attachment as an example) strip any blocks that do not change between pages (ie, most of the header except the link for contact*.php, or the label sent to the new contact.php from the point above) and put them into another file that would be included into each page. I'd really like to template stuff into template part includes, and use them to simplify the different pages. The real reason behind this is that the business owner wants to be able to edit the middle column (the article) so that they can update parts of the site themselves. I have warned her that she doesn't want to do this, but she insists. If I put their articles into a ./articles/ directory, and give them the extension .article, I can set up a Windows Explorer folder shortcut to the ./articles/ directory, and install Notepad+ on her computer, and define .article to only work with Notepad+... and educate her not to change anything but the text of her article... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This is the most suspicious looking thing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Thu, Feb 21, 2013 at 8:46 AM, Jim Giner jim.gi...@albanyhandball.com wrote: I *have* heard claims that something like this is preferrable, though: if (FALSE === $variable) I believe I read a comment somewhere once that writing your IF statements that way helped to trigger an error message when the coder forgot to use the double equal sign (==) in the statement. I haven't adopted it yet, but I think that's the sole reason for it. Basically you can't make an assignment (=) to a constant or some non-variable target. That sounds like a reasonable explanation to me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Wed, Feb 20, 2013 at 1:31 PM, Stuart Dallas stu...@3ft9.com wrote: -Stuart -- Sent from my leaf blower -- Did you get the 4G model, or is this just the WiFi version? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Tue, Feb 19, 2013 at 1:02 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: tamouse mailing lists wrote: I hate arrays. :D Here's a small snippet showing how it works, I hope: foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } Question 1: when did we have to add [] to a input name to turn it into an array? input type=checkbox name=DPRlocationdetails[] value=Unknown According to phpinfo() it still comes out as $_POST['DPRlocationdetails'] without []. Are the [] necessary? [] are necessary when you want to return multiple values for a form field, or collection of form fields such as checkbox. AFAIK, this has always been the case with PHP. See https://gist.github.com/tamouse/5002728 -- Question 2: I was looking at some code in the Manual, where someone used isset and is_array. How necessary is if(isset($_POST['DPRlocationdetails'])) and then to use: if(is_array($_POST['DPRlocationdetails'])) That seems like over kill? It's more defensive, in the case where someone may be by-passing your form to send things in. -- Question 3: My code works, perfectly. Then there must be no questions. :) In this case, I decided to attack some check-boxes first. The resulting function will work for select multiple too.. Does anyone see me doing something wrong in my code below? My questions are: Is this the only way to pass Unknown, Family Home or Apartment into the function? Is this correct? if ($_POST['DPRlocationdetails'] == Unknown) Somebody once told me I had to do it this way? if (Unknown == $_POST['DPRlocationdetails']) In this scenario, these are equivalent. There is no preference of one over the other. I *have* heard claims that something like this is preferrable, though: if (FALSE === $variable) But I think that may have been due to some misunderstanding of precedences in the following sort of scenario: if (FALSE === ($result = some_function()) where if done this way: if ($result = some_function() === FALSE) was giving them bad results. John snip--- form action=foo.php id=DPRform method=postinput value=Update type=submit input type=checkbox name=DPRlocationdetails[] value=Unknown ?php filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown input type=checkbox name=DPRlocationdetails[] value=Family Home ?php filter_value($_POST['DPRlocationdetails'],Family Home); ? Family Home input type=checkbox name=DPRlocationdetails[] value=Apartment ?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment /form ?php function filter_value($tofilter,$tofind) { foreach($tofilter as $value){ if ($value == $tofind) echo checked; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Mon, Feb 18, 2013 at 6:54 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I am capable with select name=DPRpriority. (I suppose I did it correctly? :p ) But I haven't the first clue how to parse a select multiple and multiply select name=DPRtype. Would anyone give me a couple of clues please? :) Thanks, John Priority: select name=DPRpriority form=DPRform option value=1 ?php if ($_POST[DPRpriority] == 1) {echo selected;} ?1/option option value=2 ?php if ($_POST[DPRpriority] == 2) {echo selected;} ?2/option option value=3 ?php if ($_POST[DPRpriority] == 3) {echo selected;} ?3/option option value=4 ?php if (empty($_POST[DPRpriority])) {echo selected;} if ($_POST[DPRpriority] == 4) {echo selected;} ?4/option /select select multiple=multiple name=DPRtype form=DPRform option value=1. Crimes Against Persons1. Crimes Against Persons/option option value=2. Disturbances2. Disturbances/option option value=3. Assistance / Medical3. Assistance / Medical/option option value=4. Crimes Against Property4. Crimes Against Property/option option value=5. Accidents / Traffic Problems5. Accidents / Traffic Problems/option option value=6. Suspicious Circumstances6. Suspicious Circumstances/option option value=7. Morality / Drugs7. Morality / Drugs/option option value=8. Miscellaneous Service8. Miscellaneous Service/option option value=9. Alarms9. Alarms/option /select -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Do test this, but I think all that's required is you make the name an array: select name=DPRpriority[] form=DPRform -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Mon, Feb 18, 2013 at 7:28 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: select multiple=multiple name=DPRtype form=DPRform option value=1. Crimes Against Persons1. Crimes Against Persons/option option value=2. Disturbances2. Disturbances/option option value=3. Assistance / Medical3. Assistance / Medical/option option value=4. Crimes Against Property4. Crimes Against Property/option option value=5. Accidents / Traffic Problems5. Accidents / Traffic Problems/option option value=6. Suspicious Circumstances6. Suspicious Circumstances/option option value=7. Morality / Drugs7. Morality / Drugs/option option value=8. Miscellaneous Service8. Miscellaneous Service/option option value=9. Alarms9. Alarms/option /select Do test this, but I think all that's required is you make the name an array: select name=DPRpriority[] form=DPRform Something like this? if $DPRpriority[0] == 7. Morality / Drugs { echo selected; } I hate arrays. :D http://php.net/manual/en/language.types.array.php ?php $DPRpriority[] = array( 1= a, 1 = b, 1.5 = c, true = d, ); var_dump($array); ? Not exactly that -- I think I goofed up your variable names. $DPRpriority is the set of values that can be selected, and DPRType are the values returned from the form. Here's a small snippet showing how it works, I hope: ?php // Initial value for demo $DPRpriority = array(array('name' = Crimes Against Persons, 'selected' = false), array('name' = Disturbances, 'selected' = false), array('name' = Assistance / Medical, 'selected' = false), array('name' = Crimes Against Property, 'selected' = false), array('name' = Accidents / Traffic Problems, 'selected' = false), array('name' = Suspicious Circumstances, 'selected' = false), array('name' = Morality / Drugs, 'selected' = false), array('name' = Miscellaneous Service, 'selected' = false), array('name' =Alarms, 'selected' = false)); echo h1Initial value of DPRpriority:/h1ul\n; foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } echo /ul\n; if (count($_POST) 0) { // something was posted: echo h1\$_POST:/h1precode\n; var_dump($_POST); echo /code/pre\n; echo h2Items selected:/h2ul\n; foreach ($_POST['DPRType'] as $item) { $DPRpriority[$item]['selected'] = true; echo li.$item.: .$DPRpriority[$item]['name']./li\n; } echo /ul\n; echo h1Final value of DPRpriority:/h1ul\n; foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } echo /ul\n; } ? form method=post select name=DPRType[] id=DPRType[] multiple onchange= size=?php echo count($DPRpriority) ? ?php foreach ($DPRpriority as $index = $value) { ? option value=?php echo $index; ??php if ($value['selected']) {echo ' selected=selected';} ??php echo $value['name'];?/option ?php } ? /select input type=submit name=submit value=submit / /form (gist link: https://gist.github.com/tamouse/4982630 ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP to run sequential SQL queries?
On Sun, Feb 17, 2013 at 10:00 AM, AmirBehzad Eslami behzad.esl...@gmail.com wrote: We have a bunch of SQL-queries, they should be executed in a sequential order, with a defensive programming style in mind. We were thinking to implement the solution as Stored Procedures instead of a PHP solution that runs SQL queries, but an article in Coding Horro recommendeds to avoid SP for good reasons: http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html As has been said, everything has it's place, every tool has it's use, but we've all used that screwdriver to both open a can of paint and then bang on the lid with handle to get it closed again. Meaning that just because there's a tool to hand, it doesn't always mean it's the right thing. I tend to use stored procs when what I need to get accomplished resides well within the database and utilizes the database engine more effectively, and when such activities might become I/O bandwidth issues if it were all done serially within the application. In other words, very few and far between. If the dataset is large and involves some very complex queries (lots of nested selects and so on), it is often better as a stored proc. But there is a caveat there as well in that often times the skill sets for maintaining complex SQL code can be a lot harder to find and acquire than the skill set for maintaining the same logic in PHP. So, no absolutes, one way or another. Now we're going to carry on in PHP, and my experience says that we should write the solution in a procedural-style, instead of OOP. Is there any benefit to use OOP in these situations? Please share your thoughts. This is actually a very similar question: again, no absolutes. An OO approach is well fit for some aspects of implementation, and a procedural approach to others, and then there is the functional approach, which is yet another way of looking at the problem. Even with that, all three can come into play in any given application. What is to be gained by using an object approach, versus procedural, versus functional? If it's a fairly confined operation, perhaps wrapping it in an object might give some more portability, and if the rest of the application utilizes an object approach, would be a good way to go. If the rest of the application is primarily procedural, then introducing an object approach might become more of a maintenance issue. So, really, it's not a simple answer. There are far too many considerations. Other things to consider: does the entire series of queries need to be performed in a locked state, i.e., if the database records change during the series of queries, will things break? This has very huge performance considerations, and should be taken into account. One of the purported uses of stored procs is that it's easier to implement an atomic operation such as that, but that's really not entirely accurate either. It's quite possible to lock and release while still running the queries sequentially from code. The round-trip factors of I/O do weigh more heavily here. My overall suggestion: Do it the simplest way you can right now, measure, charaacterize, look at how the whole app operates, and refactor what needs to be refactored when you have some actual performance data. Recognize also that simplest is pretty subjective based upon you and your fellow devs experiences and points of view. A super DBA person might be able to snap off a stored proc in no time; while an experience PHPer might be able to do the same procedurally. It doesn't mean either one is better than the other. Only putting it into play and actually measuring it will do that. Stumbling over how best to do something is very often less optimal than just implementing and seeing for yourself. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache to serve RESTful requests using PHP
On Sat, Feb 9, 2013 at 12:21 PM, Stuart Dallas stu...@3ft9.com wrote: On 9 Feb 2013, at 16:42, AmirBehzad Eslami behzad.esl...@gmail.com wrote: We're a developing a PHP-driven web service with a RESTful API, and we have a dedicated Linux server for that with 6GB of RAM. I would personally recommend nginx + php-fpm over Apache + mod-php every time. The pre-request memory footprint is massively reduced and I've seen nothing but upsides since migrating most of my client's sites, and my own. +1 for nginx+php-fpm - the memory savings on this are incredible; while I keep using Apache as a general purpose server, nginx+php-fpm is really ideal for large scale php applications. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Integer
On Fri, Feb 1, 2013 at 10:40 PM, Ron Piggott ron.pigg...@actsministries.org wrote: In the following the “2.” means a moderator response and “25” is the account # of the moderator. ?php $author = 2.00025 ? How can I get the 25 by itself? - I want to drop the “2.” and remove all the zero’s Would it be best to turn this into a STRING? Any suggestions? Storing data as a float is a bad idea. Way bad. Also, I think that's too many significant digits for php to handle in a float. You should store data in an accessible way. For instance, assuming there are actually only two pieces of interesting data there, you could store them as a hash: php $author = Array('account' = 25, 'response' = 2); php var_dump($author); array(2) { [account]= int(25) [response]= int(2) } If that data is coming from somewhere beyond your control and is presented as that, then parsing as a string will be the way to go. Again, assuming there is no other useful information, a simple regexp to parse it would be: php if (preg_match('/(\d+)\.0+(\d+)/','2.00025',$matches)) { php { $author = Array('account' = $matches[2], 'response' = $matches[1]); php { } php // else handle error if need be php var_dump($author); array(2) { [account]= string(2) 25 [response]= string(1) 2 } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Integer
On Fri, Feb 1, 2013 at 11:27 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Feb 1, 2013 at 10:40 PM, Ron Piggott ron.pigg...@actsministries.org wrote: In the following the “2.” means a moderator response and “25” is the account # of the moderator. ?php $author = 2.00025 ? How can I get the 25 by itself? - I want to drop the “2.” and remove all the zero’s Would it be best to turn this into a STRING? Sorry for complicating things. I didn't read your request carefully enough. YES, treat it as a string, and if you just need the last 2 digits, just grab the substring: php $author = substr('2.00025',-2); php echo $author; 25 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web User Management
On Wed, Jan 30, 2013 at 10:21 AM, Jonathan Sundquist jsundqu...@gmail.com wrote: For Zend Framework 2, take a look at https://github.com/ZF-Commons/ZfcUser On Wed, Jan 30, 2013 at 10:19 AM, Adolfo Olivera olivera.ado...@gmail.comwrote: You can take a look at the classes from the Zend Framework (they can be used stand alone as well) Thanks Marco, which classes specifically are you talking about. Where can I download them from and get documentation on them? I looked into zend's web site and it is a bit overwhelming, so may be you can point me in the right direction. On Wed, Jan 30, 2013 at 11:53 AM, ma...@behnke.biz ma...@behnke.biz wrote: Adolfo Olivera olivera.ado...@gmail.com hat am 30. Januar 2013 um 15:18 geschrieben: My questions are 1 Is there some kind of library, framework I could utilize to save me some work? You can take a look at the classes from the Zend Framework (they can be used stand alone as well) 2 Any thoughts, lessons learned from more senior programmers, I'm fairly new with PHP. Think about security issues like encrypted transfer of passwords, sessions hijacking, sql injection, sessions without cookies and stuff like that. I'd recommend Symfony, or, well Drupal, even, depending on what you've got to do. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What needs to configure to run php exec for socket connection?
On Sun, Jan 27, 2013 at 3:10 AM, jupiter jupiter@gmail.com wrote: Hi, I have a client.php which calls an external python socket client program exec(Client.py), the Client.py calls sockobj.connect((localhost, 6)) to connect socket. If I run the client.php from Linux command line $ ./client.php, it works find, no problem at all. But when I run it from web page http://localhost/client.php, it could not connect to socket at following exception in python sockobj.connect((localhost, 6)): sockobj.connect Errno 13 Permission denied Why it can run from command line, but cannot make socket connection from web? Does it need some kind of configuration in php or apache? Appreciate any tips and clues. Thank you. Kind regards. I am puzzled by First question: why use a separate program and language to call a socket? PHP has two ways of doing it, using the Socket extension and using the Stream extension. The Stream extension is a little nicer as you just use standard PHP file functions on it. To look here, though, you might want to look at the permissions on client.py to make sure it as well as the requisite paths to get to the script are readable and executable by the user running your webserver, or alternatively, your php scripts if running something like fcgi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] new FTP function
On Fri, Jan 18, 2013 at 9:43 AM, Daniel Brown danbr...@php.net wrote: On Fri, Jan 18, 2013 at 10:33 AM, KISE wowk...@gmail.com wrote: Paul Dragoonis, Actually it wont work i did tried it before, if the dir end with / it will list the directories inside the path you gave it and if it doesn't have any directories it will return false since there is no directories to return. you have to take out the last / and then remove the directory in question and list the files in the parent directory and check if the dir exists otherwise it will return false, i spent 3hrs yesterday thinking why its returning false even though the directory exists. The discussion is now getting more into the general coding realm than internals, so let's move it over there in case anyone wants to mention something like: function ftp_dir_exists($conn, $currentDir) { $currentDir = (substr($currentDir,-1,1) == '/') ? substr($currentDir,0,-1) : $currentDir; $list = ftp_nlist($conn, '-dF '. $currentDir); return in_array($currentDir, $list); } Haven't played with ftp functions at all, but wondering what if you gave it dirname($currentDir) instead of $currentDir? (Still have to do the trailing '/'-ectomy) $list = ftp_nlist($conn, dirname($currentDir)); untested, just a thought. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] new FTP function
On Fri, Jan 18, 2013 at 9:26 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Jan 18, 2013 at 9:43 AM, Daniel Brown danbr...@php.net wrote: On Fri, Jan 18, 2013 at 10:33 AM, KISE wowk...@gmail.com wrote: Paul Dragoonis, Actually it wont work i did tried it before, if the dir end with / it will list the directories inside the path you gave it and if it doesn't have any directories it will return false since there is no directories to return. you have to take out the last / and then remove the directory in question and list the files in the parent directory and check if the dir exists otherwise it will return false, i spent 3hrs yesterday thinking why its returning false even though the directory exists. The discussion is now getting more into the general coding realm than internals, so let's move it over there in case anyone wants to mention something like: function ftp_dir_exists($conn, $currentDir) { $currentDir = (substr($currentDir,-1,1) == '/') ? substr($currentDir,0,-1) : $currentDir; $list = ftp_nlist($conn, '-dF '. $currentDir); return in_array($currentDir, $list); } Haven't played with ftp functions at all, but wondering what if you gave it dirname($currentDir) instead of $currentDir? (Still have to do the trailing '/'-ectomy) $list = ftp_nlist($conn, dirname($currentDir)); untested, just a thought. Although on further thought, if $currentDir actually points to a non-directory, that will still pass, won't it. Might have to go with ftp_rawlist and parse it out to ensure it is a directory... Check the first character of each line to see if it's 'd', then the file name will be the last field in the line. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP programming a members only access site
On Sun, Jan 13, 2013 at 11:05 AM, Stephen stephe...@rogers.com wrote: I know there are existing solutions for this, but the ones I have found are complex, turnkey and don't really facilitate learning. When learning is the goal, writing your own is probably the best course. When deploying a live site, go with something that is time tested and has had many eyes upon it. And, of course, having sample code for functions like creating a new account, sending the confirmation email, handling the response. Dealing with forgotten passwords. I don't want to re-invent the wheel, but I don't want to have to dissect the code for, say, phpBB to see how it is done there, either. I'd be rather hesitant to look into phpBB as well; it's rather old, a lot of security has been bolted on, stuck in, and so on. Plus it has many known exploits. Drupal is somewhat better as it has had major rewrites and releases, but it's not the most accessible of code. Symfony is well written, but it seems to borrow quite a lot from Ruby's DSL concepts in PHP-land. (Incidently, Drupal will be using Symfony for Version 8.) Do spend time perusing the questions and answers at stackoverflow as well: http://stackoverflow.com/questions/tagged/security and this: http://www.owasp.org/index.php/Main_Page +1 for Essential PHP Security. Dated, but still very valid and useful in a learning context. Also, while not really tutorials or documentation, start following the hacker news to see what sorts of exploits are out there in the world. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't connect to MySQL via PHP
On Sat, Jan 12, 2013 at 4:49 PM, admin ad...@buskirkgraphics.com wrote: As much as the php list would like to force people from using mysql, I guess you should not have invented it, if you don't want people to still use it. It's not this php list. It's the php developers. mysql* functions are set to be removed in a release coming soon. Time marches on. mysql* functions were written first, then the mysqli* functions were written. mysql* is old, out of date, and not begin supported. Should not have written it? Maybe? But maybe no libraries should have been written, nothing should move forward, better ways should not have been found. Maybe you want to do your computing using pebbles, too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear Page2
On Sat, Jan 5, 2013 at 8:52 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote On Sat, 2013-01-05 at 15:23 +0100, Silvio Siefke wrote: On Sat, 05 Jan 2013 07:53:04 + Ashley Sheridan a...@ashleysheridan.co.uk wrote: I'm not sure quite what you'd expect such a module to do? Is this for templating? page2 creates complete websites. Would be useful because I'm sitting at the website internationalization. Template engines seem complicated. I've just had a quick look at page2, and I can't say I see the point. You'd end up having to write a lot more code that was harder to manage by adding each element through a class like that if your site got even moderately complicated. There are many templating engines, and some are more complicated than others, don't write them off just yet. Technically speaking, page2 is a template engine of a kind, so you're already using one. To build on Ash's remarks, I'd say don't over-engineer and complicate your application. HTML5 is dead easy to write directly -- unless you think your application is going to need to generate different flavours of (X)HTML, it may not be worth going the full-programmatic route like Page2 does. Internationalization is a pretty complex thing in and of itself (language preference detection, message catalog management, localized formatting, etc) that to also make the other parts of the presentation that complex are probably not where you want to spend your time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
On Fri, Jan 4, 2013 at 1:56 AM, Sebastian Krebs krebs@gmail.com wrote: 2013/1/4 tamouse mailing lists tamouse.li...@gmail.com Bit operators are not comparing values, they're COMBINING values. Technically spoken they're comparing bits, whereas boolean operators does the same, but treaten every value as a single bit. And that's just going to confuse things. Technically speaking, bit operations and NOT logical operations. If you do this: if ($a $b) when you meant this: if ($a $b) it's because you got lucky, not because it's correct. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
On Fri, Jan 4, 2013 at 4:25 PM, Sebastian Krebs krebs@gmail.com wrote: 2013/1/4 tamouse mailing lists tamouse.li...@gmail.com On Fri, Jan 4, 2013 at 1:56 AM, Sebastian Krebs krebs@gmail.com wrote: 2013/1/4 tamouse mailing lists tamouse.li...@gmail.com Bit operators are not comparing values, they're COMBINING values. Technically spoken they're comparing bits, whereas boolean operators does the same, but treaten every value as a single bit. And that's just going to confuse things. Technically speaking, bit operations and NOT logical operations. If you do this: if ($a $b) when you meant this: if ($a $b) it's because you got lucky, not because it's correct. Sorry, but ... well, I don't understand you :X When I want and type it's simply a bug, but sometimes I want , for example like in $a FLAG_ALLOWED, so I don't know, what you are talking about right now I'm talking about the first case, when it's a bug. Missing important words; *and it works*, it's because you got lucky, not because it's correct -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear Page2
On Fri, Jan 4, 2013 at 8:18 PM, Silvio Siefke siefke_lis...@web.de wrote: Is there something similar to Pear/Page2 module, that can working with HTML5? Would phptal be of use? http://phptal.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable placeholders in a text file
On Mon, Dec 31, 2012 at 2:37 PM, Nelson Green nelsongree...@hotmail.com wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for the expansion. Also consider using HEREDOC instead of the double quotes. You may want to put your message in a text file and using the include function. Hi Stephen, My message is in a text file, but I'm using fopen and fread in a self-defined function, so message is actually defined as (GREETER_FILE is a defined constant): function print_greeting($user_name) { $handle = fopen(GREETER_FILE, r); $message = fread($file_handle, filesize(GREETER_FILE)); $msg_text = str_replace(USER, $user_name, $message); print($msg_txt); } And my text file is simply: $cat greet.txt Hello USER. How are you today? If I change USER to $user_name in the text file and change the print function parameter to $message, $user_name gets printed verbatim. In other words the greeting on my page becomes: Hello $user_name. How are you today? I want to pass the name Nelson to the function, and have it output: Hello Nelson. How are you today? after the function reads in text file input that contains a variable placeholder for the user name. I actually had a HEREDOC in the function, and that worked. But by reading a file instead, I can make things more flexible. I'd rather be changing a text file instead of a code file. I use the include(template) method for this alla time, it works great. Most especially for HTML emails coming from a web site to a group of users, just slick as anything. include does basically just what your print_greeting function does less the actual printout, but using php variables instead of a str_replace. Also, this way the templates can be stored elsewhere, outside the actual code base if need be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable placeholders in a text file
On Mon, Dec 31, 2012 at 5:47 PM, Stephen stephe...@rogers.com wrote: The common stuff for every page is defined in the file include.php. I define the variable $markup in that file. Here is the definition for $markup $markup=HEREDOC [[snippy]] HEREDOC; By using require_once instead of fopen and fread, I have simpler code and PHP evaluates the embedded variables in $markup without any need to use string functions. While using the *_once works in many cases, if you're doing a mass mailing kind of thing, you want to use the standard include/require so you can re-include it as your variables change: foreach ($customers as $customer) { $fullname = $customer['fullname']; $address = $customer['address']; // and so on include(mailing.php); process($mailing,$customer); } where mailing.php defines the $mailing variable as the content that got included and substituted. (Back before I came up with this, I was starting off in the same place as the OP -- and then I just realized wait --- PHP *IS* a templating system! a voila) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to build multilingual e-commerce website
On Fri, Dec 28, 2012 at 5:19 AM, Sachin Raut imsachinr...@gmail.com wrote: Dear Friends, I have to develop multilingual e-commerce (clothing) website. Could anyone who has developed these kind of sites before guide me on how to start the development or recommend any tutorial / book for developing these kind of sites? Would really appreciate any inut regarding this. regards Sachin Raut There's this at O'Reilly: Building eCommerce Applications http://shop.oreilly.com/product/0636920023098.do And this at Amazon: Effortless E-Commerce with PHP and MySQL by Larry Ullman http://amzn.com/0321656229 Also, not really knowing how much you need to do yourself, you could probably get a leg up using existing frameworks and such. The multilingual aspects will certainly be tricky. Gettext is sort of the standard for doing multilingual things, but in and of itself doesn't really provide much help in understanding *how* to do multilingual right, and can be problematic. Some frameworks do support multilingual sites; I know drupal does, for example, and includes quite a lot of other things that can help you build an e-commerce site rather quickly, but drupal itself has a rather steep learning curve. Passages of just plain text aren't that difficult; it's when you start constructing displayed text dynamically that it will be trickier, for certain. Just thinking off the top of my head; you will likely need something other than just gettext with it's separate language files for things like product descriptions. I think it gets rather difficult, and probably bad form, to have your separate strings in files in your code base linked to data base entries; simpler just to store the various multilingual data base bits in the data base itself. But you can see how complex it gets. At any rate, I hope you have a fair bit of experience in building dynamic internet sites already, this is not going to be easy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Fri, Dec 21, 2012 at 7:06 PM, Jim Giner jim.gi...@albanyhandball.com wrote: That actually makes sense tho. Afterall, a string is truly only one memory allocation whereas array elements are basically multiple vars having the same name. So - how can you unset one char in a string? That actually depends on what you mean by unset. If you mean to remove it, str_replace should do, or if you only know it's position, using substr twice to grab the front and back should work. Setting a charcter to null ('') in the middle of the string could be interesting for some applications... Following up with the example I just showed: // now let's 'unset' a character in the middle $s3 = $s; $s3[10] = ''; showstring($s3); yields: String of length 34 is Now we aregone down to the river! s[0] : 'N' 78 s[1] : 'o' 111 s[2] : 'w' 119 s[3] : ' ' 32 s[4] : 'w' 119 s[5] : 'e' 101 s[6] : ' ' 32 s[7] : 'a' 97 s[8] : 'r' 114 s[9] : 'e' 101 s[10] : '' 0 s[11] : 'g' 103 s[12] : 'o' 111 s[13] : 'n' 110 s[14] : 'e' 101 s[15] : ' ' 32 s[16] : 'd' 100 s[17] : 'o' 111 s[18] : 'w' 119 s[19] : 'n' 110 s[20] : ' ' 32 s[21] : 't' 116 s[22] : 'o' 111 s[23] : ' ' 32 s[24] : 't' 116 s[25] : 'h' 104 s[26] : 'e' 101 s[27] : ' ' 32 s[28] : 'r' 114 s[29] : 'i' 105 s[30] : 'v' 118 s[31] : 'e' 101 s[32] : 'r' 114 s[33] : '!' 33 Still 34 byte string length, but looking at s[10] you see the null byte. It didn't really affect printing, but it might affect other things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Noobie starting to learn OOP for databases needs help
On Sun, Dec 16, 2012 at 9:38 AM, dealTek deal...@gmail.com wrote: Noobie starting to learn oop for databases from here: Cool. :) mysql_insert_id (depricated?) or mysqli_insert_id() (I am using mySql 5.3) The mysqli version would be preferred, since you're using mysqli in that class. 2 - how does one do aggrigate select queries like SELECT SUM(price) FROM mytable ... what I tried seemed to fail... Problem there is that the query method forces everything through prepare, and you don't have a preparable statement. I'd write another method for such single values where you won't sent it through prepare/execute/bind, and just suck in the value and return it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing searching docs
On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for all the posts. After reading and googling all afternoon, I think the best approach for me is: Create two macros in Word (done!) to export each of my .doc files to .txt and .pdf formats. Create a sql table to hold the .txt contents of my .doc files, along with a reference to the meeting date and the name of the corresponding .pdf file. Upload my two sets of files with an ftp client and then use a script to load the table with my .txt file data. Why not use php to upload the set of files? Now I just need a couple of scripts to allow a user to locate a file and bring up the pdf for when he wants to read about a meeting. And a second script to accept user input (search words) and perform a query against the textual data and present some kind of results - probably a listing containing a reference to the meeting date and a tbd-length string showing the matching result for each occurrence, ie, something like n chars in front of and after the match so the user can see the context of the match. Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in .txt format. (actually, if I 'print' the .doc as a pdf instead of using the Word's File,Save as, the resulting pdf is only 70kb. Might need a new macro!) Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing searching docs
On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for all the posts. After reading and googling all afternoon, I think the best approach for me is: Create two macros in Word (done!) to export each of my .doc files to .txt and .pdf formats. Create a sql table to hold the .txt contents of my .doc files, along with a reference to the meeting date and the name of the corresponding .pdf file. Upload my two sets of files with an ftp client and then use a script to load the table with my .txt file data. Now I just need a couple of scripts to allow a user to locate a file and bring up the pdf for when he wants to read about a meeting. And a second script to accept user input (search words) and perform a query against the textual data and present some kind of results - probably a listing containing a reference to the meeting date and a tbd-length string showing the matching result for each occurrence, ie, something like n chars in front of and after the match so the user can see the context of the match. Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in .txt format. (actually, if I 'print' the .doc as a pdf instead of using the Word's File,Save as, the resulting pdf is only 70kb. Might need a new macro!) PDF might be better looking than this, but how big is an HTML doc exported from Word? Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing searching docs
On Dec 15, 2012 7:29 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for all the posts. After reading and googling all afternoon, I think the best approach for me is: Create two macros in Word (done!) to export each of my .doc files to .txt and .pdf formats. Create a sql table to hold the .txt contents of my .doc files, along with a reference to the meeting date and the name of the corresponding .pdf file. Upload my two sets of files with an ftp client and then use a script to load the table with my .txt file data. Now I just need a couple of scripts to allow a user to locate a file and bring up the pdf for when he wants to read about a meeting. And a second script to accept user input (search words) and perform a query against the textual data and present some kind of results - probably a listing containing a reference to the meeting date and a tbd-length string showing the matching result for each occurrence, ie, something like n chars in front of and after the match so the user can see the context of the match. Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in .txt format. (actually, if I 'print' the .doc as a pdf instead of using the Word's File,Save as, the resulting pdf is only 70kb. Might need a new macro!) PDF might be better looking than this, but how big is an HTML doc exported from Word? Sorry for the disjointed replies, it's still early... You could export just the HTML, upload it, and your script could strip the HTML to have both formats available, I.e. plain text for indexing, HTML for presentation... or even, say, run the HTML through pandoc and produce markdown... As I say, it's early, these might be bad ideas, but it's how I'd approach it. Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Formatting -- defining sections of code
On Dec 14, 2012 9:49 AM, Andy McKenzie amckenz...@gmail.com wrote: Hey folks, kind of a strange question here. Basically, I've been trying to move my style from self taught to Oh yeah, there IS a standard for this. One of the things I frequently want to do is define sections of my code: to take a simplistic example, this outputs everything that needs to be in file A, this outputs what needs to be in file B, and so on. Up until now, I've used my own standards (generally SectionName, since it's easy to search for). But it occurs to me to wonder; IS there a standard for this? Most likely, the programming world being what it is, there either isn't one or there are lots of competing standards, but I'd be interested to know... Thanks, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Actually, yes. Write smaller functions that do only one thing. DRY. Refactor. Etc. Php include is cheap. Use the file system and names to organize things. And if you aren't using a decent IDE or CMS, start now.
Re: [PHP] storing searching docs
On Sat, Dec 15, 2012 at 11:21 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 12/15/2012 8:26 AM, tamouse mailing lists wrote: On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for all the posts. After reading and googling all afternoon, I think the best approach for me is: Create two macros in Word (done!) to export each of my .doc files to .txt and .pdf formats. Create a sql table to hold the .txt contents of my .doc files, along with a reference to the meeting date and the name of the corresponding .pdf file. Upload my two sets of files with an ftp client and then use a script to load the table with my .txt file data. Why not use php to upload the set of files? Now I just need a couple of scripts to allow a user to locate a file and bring up the pdf for when he wants to read about a meeting. And a second script to accept user input (search words) and perform a query against the textual data and present some kind of results - probably a listing containing a reference to the meeting date and a tbd-length string showing the matching result for each occurrence, ie, something like n chars in front of and after the match so the user can see the context of the match. Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in .txt format. (actually, if I 'print' the .doc as a pdf instead of using the Word's File,Save as, the resulting pdf is only 70kb. Might need a new macro!) Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php cause I dont' now how php could do such a thing? The only way I know of is thru a 'file' input on an html page which is a pia since I would have to do it for each file. With an ftp client I can just drag/drop the files in 10 seconds. In the future, as I add additional docs, one at a time, I'll have a simple html form for doing that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yeah, bulk upload is a bigger problem. I was thinking just the one-at-a-time thing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing searching docs
On Sat, Dec 15, 2012 at 11:22 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 12/15/2012 8:29 AM, tamouse mailing lists wrote: On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for all the posts. After reading and googling all afternoon, I think the best approach for me is: Create two macros in Word (done!) to export each of my .doc files to .txt and .pdf formats. Create a sql table to hold the .txt contents of my .doc files, along with a reference to the meeting date and the name of the corresponding .pdf file. Upload my two sets of files with an ftp client and then use a script to load the table with my .txt file data. Now I just need a couple of scripts to allow a user to locate a file and bring up the pdf for when he wants to read about a meeting. And a second script to accept user input (search words) and perform a query against the textual data and present some kind of results - probably a listing containing a reference to the meeting date and a tbd-length string showing the matching result for each occurrence, ie, something like n chars in front of and after the match so the user can see the context of the match. Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in .txt format. (actually, if I 'print' the .doc as a pdf instead of using the Word's File,Save as, the resulting pdf is only 70kb. Might need a new macro!) PDF might be better looking than this, but how big is an HTML doc exported from Word? Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Word generates very many many words (!) when creating an html doc. Not a good html generator at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think my next email talked about sending the HTML through pandoc to make a plain text file, perhaps in markdown, which could be the thing you save, and then run it through a markdown filter to produce (a much, much leaner) HTML. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On Fri, Dec 7, 2012 at 2:04 PM, Jim Giner jim.gi...@albanyhandball.com wrote: On 12/7/2012 2:59 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:54 PM, Jim Giner jim.gi...@albanyhandball.com wrote: What if my sub-domain names are not in the form of 'a.domain.com' and 'b.domain.com'. A subdomain is a subdomain. Unless you've discovered a new magical form of subdomain that is not, you should be fine. And if you have, in fact, made that discovery, you're probably the reason the Mayans predicted a very short winter this year. Thanks for screwing us, Jim. OK - now that I've messed us all up, help me to understand your proposed solution. I added the ini-set line to my first script. Then I called my second one and still had the same problem with a missing session var. Is there a corresponding line I need in the 'called' script? And does it matter where this line is place within the script? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php also remember to clear cookies (on browser), and session caches (on server) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: shared memory on php servers?
On Tue, Dec 4, 2012 at 7:02 AM, Alessandro Pellizzari a...@amiran.it wrote: Il Tue, 04 Dec 2012 11:49:22 +0100, rene7705 ha scritto: I'm wondering, what's the fastest way to put a large and deep array() structure in shared memory on a PHP server? Using MongoDB. :) +++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to read emails with php
On Tue, Dec 4, 2012 at 12:24 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Warning: imap_open() [function.imap-open]: Couldn't open stream mail.mydomain.net:143/pop3INBOX in C:\xampp\htdocs\mail.php on line 6 Warning: imap_check() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mail.php on line 10 Notice: Unknown: Can't open mailbox mail.mydomain.net:143/pop3INBOX: no such mailbox (errflg=2) in Unknown on line 0 this is my code $host = 'mail.mydomain.net:143/pop3'; I'm not hugely familiar with PHP's imap -- but are you trying to connect using the IMAP port (143) but with the POP3 protocol? POP3 is port 110... $user = 'x...@mydomain.net'; $password = 'myPassword'; $mailbox = {$host}INBOX; $mbx = imap_open($mailbox , $user , $password); You might consider checking if $mbx === false here, since if imap_open, it will return false. Then check imap_last_errors/imap_errors to see what the error(s) is(are). if (false === $mbx) exit (can't connect to $mailbox: . imap_last_error() . PHP_EOL); $check = imap_check($mbx); On 12/4/12, Jonathan Sundquist jsundqu...@gmail.com wrote: What does it say when you call imap_errors or imap_last_error? On Tue, Dec 4, 2012 at 10:02 AM, Farzan Dalaee farzan.dal...@gmail.comwrote: i dont have access to log files on server On Azar 14, 1391, at 5:51 PM, Daniel Brown wrote: On Tue, Dec 4, 2012 at 8:10 AM, Farzan Dalaee farzan.dal...@gmail.com wrote: hi guys i want to open an email content ( subject ,body , attachment ) with php i use imap_php but its wont connect to host what should i do? thanx Start by finding out why it won't connect. Check the logs on the server if you can, that's always the best place to look first. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php