[PHP] Pros/Cons of using mysqli prepared statments
I'm wondering what the advantages/disadvantage of using prepared statements with mysqli are. I'm used to using the mysqli::query and mysqli::fetch_assoc functions to deal with retrieving data and bulding my sql statement in php code. Tamara Temple -- aka tamouse__ tam...@tamaratemple.com "May you never see a stranger's face in the mirror." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pros/Cons of using mysqli prepared statments
Tamara, In one of the earlier threads, it was mentioned mysqli APIs are more secure, faster, and actually maintained. Also, if you use some of the mysql_xxx(), you actually get a warning saying that it will be or it is being deprecated and paves the way for you to approach the same thing with mysqli_xxx(). The seniors perhaps can give you more facts which they have seen and experienced. Regards, Shreyas On Thu, Nov 4, 2010 at 1:18 PM, Tamara Temple wrote: > I'm wondering what the advantages/disadvantage of using prepared statements > with mysqli are. I'm used to using the mysqli::query and mysqli::fetch_assoc > functions to deal with retrieving data and bulding my sql statement in php > code. > > Tamara Temple >-- aka tamouse__ > tam...@tamaratemple.com > > > "May you never see a stranger's face in the mirror." > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Regards, Shreyas Agasthya
[PHP] Re: Apache mod_pagespeed
'Twas brillig, and Daniel P. Brown at 03/11/10 19:34 did gyre and gimble: > On Wed, Nov 3, 2010 at 14:48, Shreyas Agasthya wrote: >> Thiago, >> >> I would like to join this. Let me know how I can help you with this. Please >> be explicit with your requests so that we can totally test it and see if it >> could pose any risk to acceleration services provided by CDNs. > > I've yet to read the specs behind it (I was out of the office), > but from the overview I did see, it should not only be of no detriment > to CDNs. In fact, Google is working with an existing company, > Cotendo, to integrate the core into their CDN. > Yeah it seems like a nice idea. Basically we already do a "pre-process stage where we minify css and js before we deploy the application (dev versions are nicely verbose so that the "javascript error on line 1" debugging does not plague us!). We also try to pngcrush pngs and optimise jpegs etc. But this module seems to do all that stuff for you on the fly which is pretty nice. It would save over head in terms of application deployment processes here and I'd likely be happier using it than doing all this stuff myself. That said, it's often nice to think about these things rather and learn about the consequences than just blunder on and hope for the best. This module will result in a bit of "dumbing down" of devs, but that's not to say I'm against it generally. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 3 November 2010 21:42, Alexander Holodny wrote: > To exclude unexcepted behavior in case of wrongly formated input data, > it would be much better to use such type-casting method: > intval(ltrim(trim($inStr), '0')) > > 2010/11/3, Nicholas Kell : >> >> On Nov 3, 2010, at 4:22 PM, robert mena wrote: >> >>> Hi, >>> >>> I have a text file (utf-8 encoded) which contains lines with numbers and >>> text separated by \t. I need to convert the numbers that contains 0 (at >>> left) to integers. >>> >>> For some reason one line that contains 0002 is casted to 0 instead of >>> 2. >>> Bellow the output of the cast (int) $field[0] where I get this from >>> explode each line. >>> >>> 0 0002 >>> 4 0004 >> >> >> >> My first guess is wondering how you are grabbing the strings from the file. >> Seems to me like it would just drop the zeros on the left by default. Are >> you including the \t in the string by accident? If so, that may be hosing >> it. Otherwise, have you tried ltrim on it? >> >> Ex: >> >> $_castableString = ltrim($_yourString, '0'); >> >> // Now cast $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } else { break; } } // Close the file. fclose($fp_TabbedFile); // Delete the file. unlink($s_TabbedFilename); outputs ... array(2) { [0]=> string(1) "0" [1]=> string(8) "0002" } array(2) { [0]=> int(0) [1]=> int(2) } array(2) { [0]=> string(1) "4" [1]=> string(8) "0004" } array(2) { [0]=> int(4) [1]=> int(4) } intval() operates as standard on base 10, so no need to worry about leading zeros' being thought of as base8/octal. What is your code? Can you reduce it to something as small like the above to see if you can repeat the issue? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 10:33, Richard Quadling wrote: > // Create test file. > $s_TabbedFilename = './test.tab'; > file_put_contents($s_TabbedFilename, "0\t0002" . PHP_EOL . > "4\t0004" . PHP_EOL); > > // Open test file. > $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die("Could not open > {$s_TabbedFilename}\n"); > > // Iterate file. while(False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, "\t"))) { var_dump($a_Line); foreach($a_Line as $i_Index => $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } > > // Close the file. > fclose($fp_TabbedFile); > > // Delete the file. > unlink($s_TabbedFilename); -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pros/Cons of using mysqli prepared statments
On 4 November 2010 08:19, Shreyas Agasthya wrote: > Tamara, > > In one of the earlier threads, it was mentioned mysqli APIs are more secure, > faster, and actually maintained. > > Also, if you use some of the mysql_xxx(), you actually get a warning saying > that it will be or it is being deprecated and paves the way for you to > approach the same thing with mysqli_xxx(). > > The seniors perhaps can give you more facts which they have seen and > experienced. > > Regards, > Shreyas > > On Thu, Nov 4, 2010 at 1:18 PM, Tamara Temple wrote: > >> I'm wondering what the advantages/disadvantage of using prepared statements >> with mysqli are. I'm used to using the mysqli::query and mysqli::fetch_assoc >> functions to deal with retrieving data and bulding my sql statement in php >> code. >> >> Tamara Temple >> -- aka tamouse__ >> tam...@tamaratemple.com >> >> >> "May you never see a stranger's face in the mirror." >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > -- > Regards, > Shreyas Agasthya > I don't use mysql, I use MS SQL, but the principles are pretty much the same. A prepared statement allows the SQL server to work out what needs to be done prior to actually doing it. The server essentially compiles the SQL statement and provides places for you to put in type appropriate values. A prepared statement can be executed repeatedly with different data, without the need of the SQL server having to recompile the query. Due to the SQL server knowing the column types you are using when you are going to supply data to the query, the data types are managed for you. Hmm, I've not explained that very well. Basically, a prepared statement is a lot harder to get SQL injection code working. Normally SQL will handle a string as a string and not as part of the SQL statement. So a password of "' or 1" will be treated as that and NOT as an or statement on a where clause (assuming a simple SQL injection). http://en.wikipedia.org/wiki/Prepared_statements#Parameterized_statements covers this sort of stuff. Now, taking this one stage further. If you have a query in your PHP code, which you are going to be executing a lot, even if you are using prepared statements, you can go one further by creating a stored procedure. Now the SQL server will only ever need to compile the statement once. No matter how many times it is used. You only need to supply the data which will be type appropriate. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pros/Cons of using mysqli prepared statments
On 4 November 2010 10:42, Richard Quadling wrote: > On 4 November 2010 08:19, Shreyas Agasthya wrote: >> Tamara, >> >> In one of the earlier threads, it was mentioned mysqli APIs are more secure, >> faster, and actually maintained. >> >> Also, if you use some of the mysql_xxx(), you actually get a warning saying >> that it will be or it is being deprecated and paves the way for you to >> approach the same thing with mysqli_xxx(). >> >> The seniors perhaps can give you more facts which they have seen and >> experienced. >> >> Regards, >> Shreyas >> >> On Thu, Nov 4, 2010 at 1:18 PM, Tamara Temple wrote: >> >>> I'm wondering what the advantages/disadvantage of using prepared statements >>> with mysqli are. I'm used to using the mysqli::query and mysqli::fetch_assoc >>> functions to deal with retrieving data and bulding my sql statement in php >>> code. >>> >>> Tamara Temple >>> -- aka tamouse__ >>> tam...@tamaratemple.com >>> >>> >>> "May you never see a stranger's face in the mirror." >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >> -- >> Regards, >> Shreyas Agasthya >> > > I don't use mysql, I use MS SQL, but the principles are pretty much the same. > > A prepared statement allows the SQL server to work out what needs to > be done prior to actually doing it. The server essentially compiles > the SQL statement and provides places for you to put in type > appropriate values. > > A prepared statement can be executed repeatedly with different data, > without the need of the SQL server having to recompile the query. > > Due to the SQL server knowing the column types you are using when you > are going to supply data to the query, the data types are managed for > you. Hmm, I've not explained that very well. Basically, a prepared > statement is a lot harder to get SQL injection code working. > > Normally SQL will handle a string as a string and not as part of the > SQL statement. So a password of "' or 1" will be treated as that and > NOT as an or statement on a where clause (assuming a simple SQL > injection). > > http://en.wikipedia.org/wiki/Prepared_statements#Parameterized_statements > covers this sort of stuff. > > Now, taking this one stage further. > > If you have a query in your PHP code, which you are going to be > executing a lot, even if you are using prepared statements, you can go > one further by creating a stored procedure. Now the SQL server will > only ever need to compile the statement once. No matter how many times > it is used. You only need to supply the data which will be type > appropriate. > > > > -- > Richard Quadling > Twitter : EE : Zend > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY > And why this sort of thing should be taught at school ... http://xkcd.com/327/ -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pros/Cons of using mysqli prepared statments
[snip] If you have a query in your PHP code, which you are going to be executing a lot, even if you are using prepared statements, you can go one further by creating a stored procedure. Now the SQL server will only ever need to compile the statement once. No matter how many times it is used. You only need to supply the data which will be type appropriate. [/snip] I second this, using stored procedures has a lot of advantages. If you need to change your SQL you can do it in one spot. It reinforces MVS or modular coding behavior, the SP becomes very re-usable. Security is improved. Performance can be improved. You can put the bulk of the data handling on the database where it really belongs because SP's can perform complex operations complete with control structures. Lastly it simplifies your PHP code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP sessions - users being automatically logged out
I'm having trouble with a PHP site whereby some users are being logged out on a regular basis. This will usually happen after they have been using the site for a few minutes, they can login without any problems and access a few pages, but then suddenly they will request a page and be sent to the login form, which suggests that their session no longer exists. However, this doesn't affect all users - I can login and use the application without any problems, as can some other users. According to phpinfo(), the following session values are set (all are what I'd expect - either the default or something I've deliberately changed): session.auto_start = Off session.bug_compat_42 = On session.bug_compat_warn = On session.cache_expire = 180 session.cache_limiter = nocache session.cookie_domain = no value session.cookie_httponly = Off session.cookie_lifetime = 0 session.cookie_path = / session.cookie_secure = Off session.entropy_file = no value session.entropy_length = 0 session.gc_divisor = 100 session.gc_maxlifetime = 1440 session.gc_probability = 1 session.hash_bits_per_character = 4 session.hash_function = 0 session.name = PHPSESSID session.referer_check = no value session.save_handler = files session.save_path = /shared/sessions session.serialize_handler = php session.use_cookies = On session.use_only_cookies = Off session.use_trans_sid = 0 I've tried checking a few obvious things: * IP addresses - the site doesn't use the IP address as part of the authentication process, and almost all our users (including the ones experiencing problems) have static IP addresses anyway. * Number of sessions - there are between 40-60 session files on disk at any one time, so I doubt there's a "maximum number of session files" limit being broken, if such a configuration option exists. * Permissions - the web server user (www-data) has read/write permissions to the directory where the sessions are stored and all the files within it, and they are all owned by this user. Is there anything else obvious which could be causing the problem? This seemed to occur when we moved hosts, and I haven't changed the site's session handling code for some time, so I suspect it might be a configuration issue but can't figure out what. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Apache mod_pagespeed
On Thu, Nov 4, 2010 at 05:12, Colin Guthrie wrote: > > Yeah it seems like a nice idea. Basically we already do a "pre-process > stage where we minify css and js before we deploy the application (dev > versions are nicely verbose so that the "javascript error on line 1" > debugging does not plague us!). We also try to pngcrush pngs and > optimise jpegs etc. I'm also working toward detecting if a browser can accept them, and if it can, serving WebP images instead of PNGs, JPegs, or GIFs. Typing the sentence out, I'm not sure why I hadn't thought of it before, but it would be a greater speed increase to do it as a PHP extension than to have it run through the parser. Looks like I'll be starting over > But this module seems to do all that stuff for you on the fly which is > pretty nice. It would save over head in terms of application deployment > processes here and I'd likely be happier using it than doing all this > stuff myself. Yeah, we were compressing JavaScript with some projects as well, and trying to minify CSS and scripts, consolidating files for production (like you, development versions are the fully-bloated version, because there's nothing worse than being told you have six-hundred errors on line one). In preliminary testing yesterday, though, I'm already highly impressed with mod_pagespeed. It even removes excess spaces - such as those in tags - without any adverse reactions I've seen so far. > That said, it's often nice to think about these things rather and learn > about the consequences than just blunder on and hope for the best. This > module will result in a bit of "dumbing down" of devs, but that's not to > say I'm against it generally. I agree to a point: but I also think those of us who already know how to do the work will gain at least two added benefits from this. First, we can even further improve page-load times by doing all of the optimizations to code, layout, and media, as well as server-tuning, caching, et cetera. Second, from a purely commercial standpoint, by being some of the first to gain experience with it, it's another thing you can already tell a client, "yes, now that you've heard about this and are foaming at the mouth and simply MUST HAVE IT (NOW, FOR GOD'S SAKE), we can install that for you, no problem." In any case, there are some minor quirks I've found, so I'm not ready to put this into production for any of my client's servers yet, but I can see myself starting to do so in two to four weeks, barring any horrible discoveries. -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
We added the extension=sockets.so to php.ini but it didn't work. However, the problem was there was no sockets.so extension anywhere to be found. i searched if I could install or add sockets.so extension. Couldn't find anything. Still looking for it. Thank you for all the help. -Suyash On Tue, Nov 2, 2010 at 5:30 PM, Nicholas Kell wrote: > > On Nov 2, 2010, at 3:23 PM, Suyash R wrote: > > > > > No, our dept.'s admin wants to know where is sockets.so file on disk and > why should we try this when the phpinfo() displays sockets being enabled? > > > > Can help me find sockets.so file I don't know where it is It's a shared > object right are they stored on disk as individual files or all together > compiled into a binary > > > > Thank you > > > > Suyash Ramineni > > On Tue, Nov 2, 2010 at 3:55 PM, Nicholas Kell > wrote: > > > > On Nov 2, 2010, at 2:50 PM, Suyash R wrote: > > > > > My admin disagrees and I have questions too. > > > > > > The phpinfo() fuction displays that sockets have been enabled. If > > > extension=sockets.so is an alternate way to enable sockets, then why > should > > > this be done twice? > > > > > > Suyash Ramineni > > > On Mon, Nov 1, 2010 at 2:35 PM, Nicholas Kell > wrote: > > > > > >> > > >> On Nov 1, 2010, at 1:12 PM, Suyash R wrote: > > >> > > >>> No, sockets.so in not included in any of the machines php.ini file. > > >> However, I found that Linux machine's php.ini doesn't include > sockets.so and > > >> sockets work fine on it but don't work on the Solaris machine. > > >>> > > >>> Is it required to be included only in Solaris? > > >>> > > >>> On Mon, Nov 1, 2010 at 1:41 PM, Nicholas Kell > > > >> wrote: > > >>> > > >>> On Nov 1, 2010, at 12:08 PM, crrr errr wrote: > > >>> > > Yes, the http ( Apache user) has rl ( read permission) on the php > file > > >> with > > sockets code in it. I think write access is unnecessary for Apache > > >> user. > > > > On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell < > n...@monkeyknight.com > > >>> wrote: > > > > > > > > On Nov 1, 2010, at 11:44 AM, crrr errr wrote: > > > > > >> Yes, the phpinfo() shows that sockets are enabled in both > machines. > > >> On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert > > > > wrote: > > >> > > >>> On Mon, Nov 1, 2010 at 12:40 PM, crrr errr < > > >> r.suy...@gmail.com> > > >>> wrote: > > Hello, > > > > I was trying to create a socket connection from a Solaris > machine > > >> to a > > >>> Red > > Hat machine to get the PATH in Red Hat machine remotely on > Solaris > > >>> machine > > and display it to the user. > > > > We have a PHP 5.1.6 installation on a Linux server (Apache) and > PHP > > >>> 5.2.6. > > on a Unix(Solaris) server(Apache) . The PHP version on Solaris > is > > >>> compiled > > with --enable sockets and phpinfo() displays that the sockets > are > > >>> enabled. > > In spite of this we get the following error when using this > piece > > >> of > > > code > > from the Solaris machine. > > > > > > The error: > > > > PHP Fatal error: Call to undefined function socket_create() in > > >> /XXX/ > > 5server.php< > > >>> > http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php > > >>> > > on > > line 21 > > > > The code; > > > > > > > set_time_limit(0); > > > > //ip of the server > > $addr = 'xxx.xxx.xxx.xxx'; > > > > //port of the server > > $port = 2xxx; > > > > //create a socket > > $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This > is > > >> line > > > no > > >>> 21 > > in the code. i have ommitted a few header comments */ > > > > //bind this socket with the above ip and port > > $ret = socket_bind($sock, $addr, $port); > > > > do { > > $ret = socket_listen($sock, 10); > > $msgSock = socket_accept($sock); > > $buf = socket_read($msgSock, 1024); > > > > > > Please let me know if you need any further details I might have > > >> missed. > > > > Thank you. > > > > Suyash Ramineni > > > > >>> > > >>> > > >>> check phpinfo() to see if the sockets have been activated in the > ini > > > file. > > >>> -- > > >>> > > >>> Bastien > > >>> > > >>> Cat, the other other white meat > > >>> > > > > > > > > > I think that I messed up sending my last email, I apologize. > > > > > > Is the user that Apache is running under configured for the proper > > >> read > > > write access to the socket file? > > > > > > > > > -- > > > PHP Gene
Re: [PHP] PHP sessions - users being automatically logged out
Inc session.cache_expire. You have only 3 minutes. This means browser will drop cookie containing session id in three minutes, or even less, of clients inactivity. I prefer to set expire-time to zero. So, browser will never forget session id. In other case, if security requires, i usually set it to 24 hours, to avoid some mystic problems, in case of misconfigured servers and/or clients TZ; they are rare. 2010/11/4, Paul Waring : > I'm having trouble with a PHP site whereby some users are being logged > out on a regular basis. This will usually happen after they have been > using the site for a few minutes, they can login without any problems > and access a few pages, but then suddenly they will request a page and > be sent to the login form, which suggests that their session no longer > exists. However, this doesn't affect all users - I can login and use the > application without any problems, as can some other users. > > According to phpinfo(), the following session values are set (all are > what I'd expect - either the default or something I've deliberately > changed): > > session.auto_start = Off > session.bug_compat_42 = On > session.bug_compat_warn = On > session.cache_expire = 180 > session.cache_limiter = nocache > session.cookie_domain = no value > session.cookie_httponly = Off > session.cookie_lifetime = 0 > session.cookie_path = / > session.cookie_secure = Off > session.entropy_file = no value > session.entropy_length = 0 > session.gc_divisor = 100 > session.gc_maxlifetime = 1440 > session.gc_probability = 1 > session.hash_bits_per_character = 4 > session.hash_function = 0 > session.name = PHPSESSID > session.referer_check = no value > session.save_handler = files > session.save_path = /shared/sessions > session.serialize_handler = php > session.use_cookies = On > session.use_only_cookies = Off > session.use_trans_sid = 0 > > I've tried checking a few obvious things: > > * IP addresses - the site doesn't use the IP address as part of the > authentication process, and almost all our users (including the ones > experiencing problems) have static IP addresses anyway. > > * Number of sessions - there are between 40-60 session files on disk at > any one time, so I doubt there's a "maximum number of session files" > limit being broken, if such a configuration option exists. > > * Permissions - the web server user (www-data) has read/write > permissions to the directory where the sessions are stored and all the > files within it, and they are all owned by this user. > > Is there anything else obvious which could be causing the problem? This > seemed to occur when we moved hosts, and I haven't changed the site's > session handling code for some time, so I suspect it might be a > configuration issue but can't figure out what. > > Thanks, > > Paul > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Apache mod_pagespeed
'Twas brillig, and Daniel P. Brown at 04/11/10 14:36 did gyre and gimble: > I'm already highly impressed with mod_pagespeed. It even > removes excess spaces - such as those in tags - without any > adverse reactions I've seen so far. Nice. I still stick spaces in my tags due to the parsing error in IE(somethingold) but I'm pretty sure that was pre-IE6 and thus something I really don't care about now! That said, I'm not sure I'd really want it to optimise all my HTML pages. CSS, JS and images yes, no problem, but the storage overhead of the disk cache all the dynamic pages is probably not worth it for me. But that's presumably just one of the things it can do. > In any case, there are some minor quirks I've found, so I'm not > ready to put this into production for any of my client's servers yet, > but I can see myself starting to do so in two to four weeks, barring > any horrible discoveries. The build process looks very ugly And it's strange their build page seems to suggest GCC 4.2 but CentOS 5.5 only has GCC 4.1 so I'm a bit puzzled as to why it's one of their recommended systems :s I'll take the build process for a spin at some point, but they really do need to make it more streamlined. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sessions - users being automatically logged out
On 04/11/10 14:56, Alexander Holodny wrote: Inc session.cache_expire. You have only 3 minutes. This means browser will drop cookie containing session id in three minutes, or even less, of clients inactivity. According to the PHP manual: "session.cache_expire specifies time-to-live for cached session pages in minutes, this has no effect for nocache limiter." So the value of session.cache_expire should be ignored, as session.cache_limiter is set to nocache. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Apache mod_pagespeed
On Thu, Nov 4, 2010 at 10:58, Colin Guthrie wrote: > > Nice. I still stick spaces in my tags due to the parsing error in > IE(somethingold) but I'm pretty sure that was pre-IE6 and thus something > I really don't care about now! > > That said, I'm not sure I'd really want it to optimise all my HTML > pages. CSS, JS and images yes, no problem, but the storage overhead of > the disk cache all the dynamic pages is probably not worth it for me. > But that's presumably just one of the things it can do. Yeah, you can choose which things to allow it to do via the configuration directives as well. > The build process looks very ugly And it's strange their build page > seems to suggest GCC 4.2 but CentOS 5.5 only has GCC 4.1 so I'm a bit > puzzled as to why it's one of their recommended systems :s > > I'll take the build process for a spin at some point, but they really do > need to make it more streamlined. Agreed. It's a bit convoluted, to be sure. In their discussions, they've admitted the same, but it's a very young project. One with a lot of potential, but a very young project nonetheless. -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
Hi, The core of the code is simply $fp = fopen('file.tab', 'rb'); while(!feof($fp)) { $line = fgets($fp); $data = explode("\t", $line); ... } So I try to manipulate the $data[X]. For example $data[0] is supposed to be numeric so I $n = (int) $data[0] One other thing if the second column should contain a string. If I check the string visually it is correct but a if( $data[1] == 'stringX') is false even if in the file I can see this (and print those two) I even did a md5 of both and they are different. I seems to be an encoding issue. Is it safe to use explode with utf8 strings? I even tried this code but no match found (jst to replace the explode) $str = "abc 文字化けefg"; $results = array(); preg_match_all("/\t/u", $str, $results); var_dump($results[0]); (I am sending this again without the reply because the first email was refused for some reason)
[PHP] suhosin simulation blocks script
Hello, I am searching through the internet how to work with suhosin. I am using debain lenny with apache2 and php 5.2 in production and my problem is: I have scripts that need for example exec() functions, but in general conf - suhosin.ini the exec function is disabled, so I turned on suhosin simulation mode. Now it is logging ALERT-SIMULATION messages in syslog, but it also blocks the scripts with exec() function. As I read on php.net, when simulation mode is on, it should not block the script, only log the alert. Does anyone have same issue? Thank you in advance. Regards, -- David Oros System Administrator Platon Technologies Ltd., Hlavna 3, Sala SK-92701 +421 903 PLATON - i...@platon.org - http://platon.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 15:11, robert mena wrote: > Hi, > The core of the code is simply > $fp = fopen('file.tab', 'rb'); > while(!feof($fp)) > { > $line = fgets($fp); > $data = explode("\t", $line); > ... > } > So I try to manipulate the $data[X]. For example $data[0] is supposed to be > numeric so I $n = (int) $data[0] > One other thing if the second column should contain a string. If I check > the string visually it is correct but a if( $data[1] == 'stringX') is false > even if in the file I can see this (and print those two) > I even did a md5 of both and they are different. > I seems to be an encoding issue. Is it safe to use explode with utf8 > strings? > I even tried this code but no match found (jst to replace the explode) > $str = "abc 文字化け efg"; > $results = array(); > preg_match_all("/\t/u", $str, $results); > var_dump($results[0]); > On Thu, Nov 4, 2010 at 6:33 AM, Richard Quadling > wrote: >> >> On 3 November 2010 21:42, Alexander Holodny >> wrote: >> > To exclude unexcepted behavior in case of wrongly formated input data, >> > it would be much better to use such type-casting method: >> > intval(ltrim(trim($inStr), '0')) >> > >> > 2010/11/3, Nicholas Kell : >> >> >> >> On Nov 3, 2010, at 4:22 PM, robert mena wrote: >> >> >> >>> Hi, >> >>> >> >>> I have a text file (utf-8 encoded) which contains lines with numbers >> >>> and >> >>> text separated by \t. I need to convert the numbers that contains 0 >> >>> (at >> >>> left) to integers. >> >>> >> >>> For some reason one line that contains 0002 is casted to 0 instead >> >>> of >> >>> 2. >> >>> Bellow the output of the cast (int) $field[0] where I get this from >> >>> explode each line. >> >>> >> >>> 0 0002 >> >>> 4 0004 >> >> >> >> >> >> >> >> My first guess is wondering how you are grabbing the strings from the >> >> file. >> >> Seems to me like it would just drop the zeros on the left by default. >> >> Are >> >> you including the \t in the string by accident? If so, that may be >> >> hosing >> >> it. Otherwise, have you tried ltrim on it? >> >> >> >> Ex: >> >> >> >> $_castableString = ltrim($_yourString, '0'); >> >> >> >> // Now cast >> >> > // Create test file. >> $s_TabbedFilename = './test.tab'; >> file_put_contents($s_TabbedFilename, "0\t0002" . PHP_EOL . >> "4\t0004" . PHP_EOL); >> >> // Open test file. >> $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die("Could not open >> {$s_TabbedFilename}\n"); >> >> // Iterate file. >> while(True) >> { >> if (False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, "\t"))) >> { >> var_dump($a_Line); >> foreach($a_Line as $i_Index => $m_Value) >> { >> $a_Line[$i_Index] = intval($m_Value); >> } >> var_dump($a_Line); >> } >> else >> { >> break; >> } >> } >> >> // Close the file. >> fclose($fp_TabbedFile); >> >> // Delete the file. >> unlink($s_TabbedFilename); >> >> >> outputs ... >> >> array(2) { >> [0]=> >> string(1) "0" >> [1]=> >> string(8) "0002" >> } >> array(2) { >> [0]=> >> int(0) >> [1]=> >> int(2) >> } >> array(2) { >> [0]=> >> string(1) "4" >> [1]=> >> string(8) "0004" >> } >> array(2) { >> [0]=> >> int(4) >> [1]=> >> int(4) >> } >> >> intval() operates as standard on base 10, so no need to worry about >> leading zeros' being thought of as base8/octal. >> >> What is your code? Can you reduce it to something as small like the >> above to see if you can repeat the issue? Please don't top post. With regards to utf-8 data, no, PHP is not unicode aware. If a multi-byte character is comprised of a 0x09 byte, then it will be broken. Can you supply the file you are working on? b64encode it and drop it into a pastebin. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] suhosin simulation blocks script
2010/11/4 David Oros : > > I have scripts that need for example exec() functions, but in general conf - > suhosin.ini the exec function is disabled, so I turned on suhosin simulation > mode. Now it is logging ALERT-SIMULATION messages in syslog, but it also > blocks the scripts with exec() function. As I read on php.net, when > simulation mode is on, it should not block the script, only log the alert. I believe that you're probably referring to a user-submitted note, because we (php.net) do not maintain or support the Suhosin project. That is instead a completely third-party patch. Unfortunately, it appears as though their support forums are down at this time, but if you continue to experience this issue, you may want to contact the maintainers directly. Their website is http://www.hardened-php.net/suhosin/. That said, I haven't had the same issue myself before. You did remember to restart Apache for it to take effect, correct? -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 15:31, robert mena wrote: > Hi Richard, > I am not top posting. I am just explaining other symptoms that may point to > the cause since they may be the same and this is happening with the same > file. I'll try to get approval to release the file. > Meanwhile, In your opinion what would be the safest way to read and explode > (using \t) a text file encoded in UTF-8? > > On Thu, Nov 4, 2010 at 11:22 AM, Richard Quadling > wrote: >> >> On 4 November 2010 15:11, robert mena wrote: >> > Hi, >> > The core of the code is simply >> > $fp = fopen('file.tab', 'rb'); >> > while(!feof($fp)) >> > { >> > $line = fgets($fp); >> > $data = explode("\t", $line); >> > ... >> > } >> > So I try to manipulate the $data[X]. For example $data[0] is supposed >> > to be >> > numeric so I $n = (int) $data[0] >> > One other thing if the second column should contain a string. If I >> > check >> > the string visually it is correct but a if( $data[1] == 'stringX') is >> > false >> > even if in the file I can see this (and print those two) >> > I even did a md5 of both and they are different. >> > I seems to be an encoding issue. Is it safe to use explode with utf8 >> > strings? >> > I even tried this code but no match found (jst to replace the explode) >> > $str = "abc 文字化け efg"; >> > $results = array(); >> > preg_match_all("/\t/u", $str, $results); >> > var_dump($results[0]); >> > On Thu, Nov 4, 2010 at 6:33 AM, Richard Quadling >> > wrote: >> >> >> >> On 3 November 2010 21:42, Alexander Holodny >> >> >> >> wrote: >> >> > To exclude unexcepted behavior in case of wrongly formated input >> >> > data, >> >> > it would be much better to use such type-casting method: >> >> > intval(ltrim(trim($inStr), '0')) >> >> > >> >> > 2010/11/3, Nicholas Kell : >> >> >> >> >> >> On Nov 3, 2010, at 4:22 PM, robert mena wrote: >> >> >> >> >> >>> Hi, >> >> >>> >> >> >>> I have a text file (utf-8 encoded) which contains lines with >> >> >>> numbers >> >> >>> and >> >> >>> text separated by \t. I need to convert the numbers that contains >> >> >>> 0 >> >> >>> (at >> >> >>> left) to integers. >> >> >>> >> >> >>> For some reason one line that contains 0002 is casted to 0 >> >> >>> instead >> >> >>> of >> >> >>> 2. >> >> >>> Bellow the output of the cast (int) $field[0] where I get this >> >> >>> from >> >> >>> explode each line. >> >> >>> >> >> >>> 0 0002 >> >> >>> 4 0004 >> >> >> >> >> >> >> >> >> >> >> >> My first guess is wondering how you are grabbing the strings from >> >> >> the >> >> >> file. >> >> >> Seems to me like it would just drop the zeros on the left by >> >> >> default. >> >> >> Are >> >> >> you including the \t in the string by accident? If so, that may be >> >> >> hosing >> >> >> it. Otherwise, have you tried ltrim on it? >> >> >> >> >> >> Ex: >> >> >> >> >> >> $_castableString = ltrim($_yourString, '0'); >> >> >> >> >> >> // Now cast >> >> >> >> > >> // Create test file. >> >> $s_TabbedFilename = './test.tab'; >> >> file_put_contents($s_TabbedFilename, "0\t0002" . PHP_EOL . >> >> "4\t0004" . PHP_EOL); >> >> >> >> // Open test file. >> >> $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die("Could not open >> >> {$s_TabbedFilename}\n"); >> >> >> >> // Iterate file. >> >> while(True) >> >> { >> >> if (False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, "\t"))) >> >> { >> >> var_dump($a_Line); >> >> foreach($a_Line as $i_Index => $m_Value) >> >> { >> >> $a_Line[$i_Index] = intval($m_Value); >> >> } >> >> var_dump($a_Line); >> >> } >> >> else >> >> { >> >> break; >> >> } >> >> } >> >> >> >> // Close the file. >> >> fclose($fp_TabbedFile); >> >> >> >> // Delete the file. >> >> unlink($s_TabbedFilename); >> >> >> >> >> >> outputs ... >> >> >> >> array(2) { >> >> [0]=> >> >> string(1) "0" >> >> [1]=> >> >> string(8) "0002" >> >> } >> >> array(2) { >> >> [0]=> >> >> int(0) >> >> [1]=> >> >> int(2) >> >> } >> >> array(2) { >> >> [0]=> >> >> string(1) "4" >> >> [1]=> >> >> string(8) "0004" >> >> } >> >> array(2) { >> >> [0]=> >> >> int(4) >> >> [1]=> >> >> int(4) >> >> } >> >> >> >> intval() operates as standard on base 10, so no need to worry about >> >> leading zeros' being thought of as base8/octal. >> >> >> >> What is your code? Can you reduce it to something as small like the >> >> above to see if you can repeat the issue? >> >> Please don't top post. >> >> >> With regards to utf-8 data, no, PHP is not unicode aware. >> >> If a multi-byte character is comprised of a 0x09 byte, then it will be >> broken. >> >> Can you supply the file you are working on? >> >> b64encode it and drop it into a pastebin. >> >> >> -- >> Richard Quadling >> Twitter : EE : Zend >> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY > > I've not used it, but the mbstrin
[PHP] php-general-digest-unsubscr...@lists.php.net not working?
The bottom of my daily digest email says to unsubscribe, I should email php-general-digest-unsubscr...@lists.php.net I've done this several times -- sometimes with various combinations of blank and "unsubscribe" in the subject line and body. I keep getting the emails though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] suhosin simulation blocks script
Hi, I am just wondering if anybody have the same experience. Yes, I noticed that the Suhosin forum is down for maintenance, as soon as possible I will write them too. Answer to the question about apache, yes I did restart it. It just doesn`t make any sense. Regards, -- David Oros System Administrator Platon Technologies Ltd., Hlavna 3, Sala SK-92701 +421 903 PLATON - i...@platon.org - http://platon.org Dňa 4. 11. 2010 16:36, Daniel P. Brown wrote / napísal(a): 2010/11/4 David Oros: I have scripts that need for example exec() functions, but in general conf - suhosin.ini the exec function is disabled, so I turned on suhosin simulation mode. Now it is logging ALERT-SIMULATION messages in syslog, but it also blocks the scripts with exec() function. As I read on php.net, when simulation mode is on, it should not block the script, only log the alert. I believe that you're probably referring to a user-submitted note, because we (php.net) do not maintain or support the Suhosin project. That is instead a completely third-party patch. Unfortunately, it appears as though their support forums are down at this time, but if you continue to experience this issue, you may want to contact the maintainers directly. Their website is http://www.hardened-php.net/suhosin/. That said, I haven't had the same issue myself before. You did remember to restart Apache for it to take effect, correct? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
On 4 November 2010 16:00, Marc Abramowitz wrote: > The bottom of my daily digest email says to unsubscribe, I should email > php-general-digest-unsubscr...@lists.php.net > > I've done this several times -- sometimes with various combinations of blank > and "unsubscribe" in the subject line and body. I keep getting the emails > though. > That will unsubscribe you from the digest. Are you getting digest messages or individual messages? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
On Thu, Nov 4, 2010 at 12:00, Marc Abramowitz wrote: > The bottom of my daily digest email says to unsubscribe, I should email > php-general-digest-unsubscr...@lists.php.net > > I've done this several times -- sometimes with various combinations of blank > and "unsubscribe" in the subject line and body. I keep getting the emails > though. As Richard pointed out, that will only unsubscribe you from the digest version. To unsubscribe from the regular every-email version, you can either send an email to php-general-unsubscr...@lists.php.net or go to http://php.net/mailinglists, select the General list, select "Normal" and scroll to the bottom, enter the email address associated with the list, and click the "Unsubscribe" button. If you continue to have issues, let me know and I will remove you. -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
On Thu, Nov 4, 2010 at 12:33, Daniel P. Brown wrote: > > If you continue to have issues, let me know and I will remove you. From the list, that is, to be clear. Not the Earth. -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
On Thu, 2010-11-04 at 12:34 -0400, Daniel P. Brown wrote: > On Thu, Nov 4, 2010 at 12:33, Daniel P. Brown > wrote: > > > >If you continue to have issues, let me know and I will remove you. > > From the list, that is, to be clear. Not the Earth. > i lol'd. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Chinese words on a PHP web page
I’m writing a program that allows the user to click the flag and the test will change to that language and display. I’m trying to convert from English to Chinese using characters such as “ æ“迎” The browser interprets these into, in this case, Japanese but my code needs to display in Chinese. The internet is giving all kinds of code to convert from English into the Chinese language. I need to put in Unicode characters that the browser will make the final change into Chinese words. I’m using define("CHARSET","UTF-8"); So the question is how does one enter Chinese Unicode?? Thanks, /Ernie
Re: [PHP] Chinese words on a PHP web page
You could do it using the &1234; type codes, or copy it directly from another source, like a character map program. Bear in mind that if you do the latter, you'll need to output a utf 8 meta tag with the html output too. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ernie Kemp" Date: Thu, Nov 4, 2010 16:52 Subject: [PHP] Chinese words on a PHP web page To: "'PHP General List'" I’m writing a program that allows the user to click the flag and the test will change to that language and display. I’m trying to convert from English to Chinese using characters such as “ æ“迎” The browser interprets these into, in this case, Japanese but my code needs to display in Chinese. The internet is giving all kinds of code to convert from English into the Chinese language. I need to put in Unicode characters that the browser will make the final change into Chinese words. I’m using define("CHARSET","UTF-8"); So the question is how does one enter Chinese Unicode?? Thanks, /Ernie
Re: [PHP] suhosin simulation blocks script
On Thu, Nov 4, 2010 at 12:08, David Oros wrote: > Hi, > > I am just wondering if anybody have the same experience. Yes, I noticed that > the Suhosin forum is down for maintenance, as soon as possible I will write > them too. > > Answer to the question about apache, yes I did restart it. It just doesn`t > make any sense. This isn't on platon.org, is it? P.S. - In accordance with the mailing list rules (http://php.net/reST/php-src/README.MAILINGLIST_RULES), please don't top-post. -- Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Tue, Nov 2, 2010 at 5:49 PM, Nathan Nobbe wrote: > On Tue, Nov 2, 2010 at 2:33 PM, Suyash R wrote: > >> No, we didn't try it our dept.'s admin wants to know where is sockets.so >> file on disk >> > > lol, tell your dept.'s 'admin' to run > > locate sockets.so > yeah he couldn't find it either. He mentioned it's not in the php extensions so I am looking for way to install it or add it. > > >> and why should we try this when the phpinfo() displays sockets being >> enabled? >> > > probly there is no need to, however you should understand the difference > between adding support for and enabling an extension. > > compiling w/ --enable only makes the extension available. the extension is > not enabled unless you do what Nick has been saying. (there are other > options as well actually). there may be other files aside from php.ini > where this setting is made, depending on how the OS vendors package up the > code. for example using mac ports, i just installed sockets and now have a > shiny new sockets.ini file. > > anyway if phpinfo() shows that sockets are enabled you probly don't have to > worry about that, because it wouldn't be showing up otherwise (essentially). > > i'm wondering if you're trying to call socket_create() from the same place > you're running phpinfo(). are you sure the socket_create() code isn't > running from the cli perhaps? > yes to see the errors we ran it at cli. The browser page with sockets code is just blank. > > if so, a quick test to see if sockets are enabled on the cli is > > php -i | grep 'Sockets Support' > Yeah, this gives no results. Hence, I think sockets are not enabled yet as sockets.so is missing. > > if nothing comes back sockets aren't enabled for the cli. if that's the > case then you will have to head into the appropriate ini file to enable the > extension for the cli. or if that's too much for you admin you can always > try > > dl('sockets.so'); > > at the top of your script. you can also try > > var_dump(extension_loaded('sockets')); > > When I add this line (dl('sockets.so');) to the top of my script I get the following error: PHP Warning: dl(): Unable to load dynamic library './sockets.so' - ld.so.1: php: fatal: ./sockets.so: open failed: No such file or directory in //r.php on line 2 PHP Fatal error: Call to undefined function socket_create() in /.r.php on line 24 When I add this line (var_dump(extension_loaded('sockets'));) to the top of my script: bool(false) PHP Fatal error: Call to undefined function socket_create() in /../r.php on line 24 to see if sockets are actually enabled where you're trying to invoke them > from. > > -nathan > Can I get any help on how to add or install sockets.so to the php extensions... -Suyash
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, Nov 4, 2010 at 11:11 AM, Suyash R wrote: > On Tue, Nov 2, 2010 at 5:49 PM, Nathan Nobbe wrote: > >> On Tue, Nov 2, 2010 at 2:33 PM, Suyash R wrote: >> >>> No, we didn't try it our dept.'s admin wants to know where is sockets.so >>> file on disk >>> >> >> lol, tell your dept.'s 'admin' to run >> >> locate sockets.so >> > > yeah he couldn't find it either. He mentioned it's not in the php > extensions so I am looking for way to install it or add it. > you may need to update the locate database. this is typically done w/ the updatedb command. > and why should we try this when the phpinfo() displays sockets being >>> enabled? >>> >> >> probly there is no need to, however you should understand the difference >> between adding support for and enabling an extension. >> >> compiling w/ --enable only makes the extension available. the extension >> is not enabled unless you do what Nick has been saying. (there are other >> options as well actually). there may be other files aside from php.ini >> where this setting is made, depending on how the OS vendors package up the >> code. for example using mac ports, i just installed sockets and now have a >> shiny new sockets.ini file. >> >> anyway if phpinfo() shows that sockets are enabled you probly don't have >> to worry about that, because it wouldn't be showing up otherwise >> (essentially). >> >> i'm wondering if you're trying to call socket_create() from the same place >> you're running phpinfo(). are you sure the socket_create() code isn't >> running from the cli perhaps? >> > > yes to see the errors we ran it at cli. The browser page with sockets code > is just blank. > right, well if your report from the other day is accurate then it sounds like you have sockets setup in the web environment and not the cli. if the browser page is blank it could be b/c your not outputting anything from your script to the browser. > if so, a quick test to see if sockets are enabled on the cli is >> >> php -i | grep 'Sockets Support' >> > > Yeah, this gives no results. Hence, I think sockets are not enabled yet as > sockets.so is missing. > run updatedb first before running locate and see if it's there or not. im not sure how phpinfo() could possibly have reported sockets as being enabled if you were missing sockets.so. > if nothing comes back sockets aren't enabled for the cli. if that's the >> case then you will have to head into the appropriate ini file to enable the >> extension for the cli. or if that's too much for you admin you can always >> try >> >> dl('sockets.so'); >> >> at the top of your script. you can also try >> >> var_dump(extension_loaded('sockets')); >> >> > When I add this line (dl('sockets.so');) to the top of my script I get the > following error: > > > PHP Warning: dl(): Unable to load dynamic library './sockets.so' - > ld.so.1: php: fatal: ./sockets.so: open failed: No such file or directory in > //r.php on line 2 > PHP Fatal error: Call to undefined function socket_create() in > /.r.php on line 24 > > When I add this line (var_dump(extension_loaded('sockets'));) to the top of > my script: > bool(false) > PHP Fatal error: Call to undefined function socket_create() in > /../r.php on line 24 > so it's def not enabled on the cli. > to see if sockets are actually enabled where you're trying to invoke them >> from. >> >> -nathan >> > Can I get any help on how to add or install sockets.so to the php > extensions... im not much for red hat, do they even use yum on that system or is it still rpm? on a centos box we have a quick search turns up a sockets package, however if you built from source, i doubt that's how you want to install sockets support at this point. $ yum search php | grep -i socket php-pear-Net-Socket.noarch : Network Socket Interface also dude, it sounds like your admin is struggling... these questions are the sort an admin would be expected to answer pretty much anywhere ive ever worked. like, how do i install software on the os im responsible for .. OUCH! -nathan
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, Nov 4, 2010 at 11:43 AM, Nathan Nobbe wrote: > $ yum search php | grep -i socket > php-pear-Net-Socket.noarch : Network Socket Interface > check that - thats def *not* the package you're looking for, it's a userspace oo wrapper. you'd be best asking how to install this software on some sort of red hat / php list really. like i said, i tend to stay away from red hat. the gentoo guys have #gentoo-php on irc so i would expect there to be similar channels for other distros. still though, update the locate database and see if you just need to enable sockets in a cli specific ini file. -nathan
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, 2010-11-04 at 11:48 -0600, Nathan Nobbe wrote: > On Thu, Nov 4, 2010 at 11:43 AM, Nathan Nobbe wrote: > > > $ yum search php | grep -i socket > > php-pear-Net-Socket.noarch : Network Socket Interface > > > > check that - thats def *not* the package you're looking for, it's a > userspace oo wrapper. you'd be best asking how to install this software on > some sort of red hat / php list really. like i said, i tend to stay away > from red hat. > > the gentoo guys have #gentoo-php on irc so i would expect there to be > similar channels for other distros. > > still though, update the locate database and see if you just need to enable > sockets in a cli specific ini file. > > -nathan is there a PEAR module you can install that will do this? I know there are a lot of PEAR modules out there... just a thought... Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Chinese words on a PHP web page
At 12:52 PM -0400 11/4/10, Ernie Kemp wrote: I'm writing a program that allows the user to click the flag and the test will change to that language and display. I'm trying to convert from English to Chinese using characters such as " æ°©"è¿Î" The browser interprets these into, in this case, Japanese but my code needs to display in Chinese. The internet is giving all kinds of code to convert from English into the Chinese language. I need to put in Unicode characters that the browser will make the final change into Chinese words. I'm using define("CHARSET","UTF-8"); So the question is how does one enter Chinese Unicode?? Thanks, /Ernie Ernie: First of all, there is a definite difference between languages and using Unicode char sets are very specific. If you indeed used a Chinese character, then it should not be changed to a Japanese character except for those characters that may overlap -- but even then while they may look alike (same glyph), they have their own unique code-point so they are different. Here are some references re Unicode: http://www.joelonsoftware.com/articles/Unicode.html http://www.alanwood.net/unicode/ http://www.unicode.org/charts/ http://www.mandarintools.com/chardict_u8.html Also realize that you have not only Chinese and Japanese char sets, but there are "Traditional" and "Simplified" variations of both. Here's another reference: http://people.w3.org/rishida/scripts/chinese/ HTH's tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
On Thu, Nov 04, 2010 at 12:34:35PM -0400, Daniel P. Brown wrote: > On Thu, Nov 4, 2010 at 12:33, Daniel P. Brown > wrote: > > > > If you continue to have issues, let me know and I will remove you. > > From the list, that is, to be clear. Not the Earth. Dang! I was just about to send you a list of people to remove! ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Weird preg issue
Hi, I'm kind of new to this list, and so if there have been discussions about this, i am not quite aware of them (i tried searching), but i ran across this issue and i figured it would be interesting enough to show you guys here: I was looking for a way to replace all the text in a string that doesn't match a pattern with nothing (therefore string in, only part of the string that matches my pattern out), one line with no arrays in the middle; and i guess there is a way to do this with temp variables, well i know there is, but i kind of wanted a more elegant solution, so i came up with this match line $str = 'And the cow says "Mooo"'; preg_match('/(?:(?!"[a-zA-Z\s]*").)*/', $str, $matches); print_r($matches); output: Array ( [0] => And the cow says ) so i was pretty happy to see that, so if i pass that expression to preg_replace it should, hopefully, replace that text with nothing, and i theoretically should be left with "Mooo", which was my goal originally, so i run print_r(preg_replace('/(?:(?!"[a-zA-Z\s]*").)*/', '', $str)); output: " ... Hardly what i was expecting... Any ideas? bug, something i'm not getting, something in the way preg works? Thanks in advance, ~ Alex
[PHP] How to code in PHP an onchange event in a ?
Hi, List, I have this two files (index.php and include.php). They both work fine, but I want to substitute the code for de onchange event in the tag. Can I use PHP to code this event? How? Thanks. index.php: '; include_once 'include.php'; $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password'); tcl_MySQL_OpenDataBase($mysql_link, 'production'); $query = 'SELECT DISTINCT recipe.product_id, product.description FROM recipe, product WHERE recipe.product_id = product.product_id ORDER BY product.description'; $result = tcl_MySQL_DataQuery($mysql_link, $query); tcl_FillComboBox($result, 'Product', 'product_id', 'description', 'alert(\'Alert Message\')'); tcl_MySQL_CloseConnection($mysql_link); echo ''; ?> include.php: User '.strtoupper($user).' connected to MySQL server.'; return $link; } function tcl_MySQL_DataQuery($link, $query) { return mysql_query($query, $link); } function tcl_MySQL_OpenDataBase($link, $database) { mysql_select_db($database, $link); } function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) { echo ''.$label.''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ''.$line[$col2]; } echo ''; } ?> Aeropuerto Internacional Frank País García de Holguín. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to code in PHP an onchange event in a ?
On Nov 4, 2010, at 3:23 PM, Tomás Corrales Lemoine wrote: > Hi, List, > > I have this two files (“index.php” and “include.php”). They both work fine, > but I want to substitute the code for de onchange event in the tag. > Can I use PHP to code this event? How? > > Thanks. > > > > index.php: > > > echo ''; > > include_once 'include.php'; > > $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password'); > > tcl_MySQL_OpenDataBase($mysql_link, 'production'); > > $query = 'SELECT DISTINCT recipe.product_id, product.description FROM recipe, > product WHERE recipe.product_id = product.product_id ORDER BY > product.description'; > $result = tcl_MySQL_DataQuery($mysql_link, $query); > > tcl_FillComboBox($result, 'Product', 'product_id', 'description', > 'alert(\'Alert Message\')'); > > tcl_MySQL_CloseConnection($mysql_link); > > echo ''; > > ?> > > > > include.php: > > > function tcl_MySQL_CloseConnection($link) { > mysql_close($link); > } > > function tcl_MySQL_ConnectToServer($host, $user, $password) { > $link = mysql_connect($host, $user, $password); > if (!$link) { > die('No se pudo conectar: '.mysql_error()); > } > echo 'User '.strtoupper($user).' connected to MySQL server.'; > return $link; > } > > function tcl_MySQL_DataQuery($link, $query) { > return mysql_query($query, $link); > } > > function tcl_MySQL_OpenDataBase($link, $database) { > mysql_select_db($database, $link); > } > > function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) { > echo ''.$label.' value="">'; > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > echo ''.$line[$col2]; > } > echo ''; > } > > ?> > > > -- > Aeropuerto Internacional Frank País García de Holguín. -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php I think that what you are looking for is javascript. Check this out: http://www.decompile.com/dataflex/webappserver/combobox_auto_submit.htm
[PHP] Re: Weird preg issue
Ah, i seem to have figured out the problem here... if you run a preg_match_all it will return [0] => Array ( [0] => And the cow says [1] => [2] => Moo" [3] => ) And preg_replace is global by default, so in order for this to work correctly, not sure about the elegantly part, but you can just limit preg_replace preg_replace('/(?:(?!"[a-zA-Z\s]*").)*/', '', $str, 1); and that seems to work correctly... Neat... kinda... On Thu, Nov 4, 2010 at 3:47 PM, Alex Nikitin wrote: > Hi, > > I'm kind of new to this list, and so if there have been discussions about > this, i am not quite aware of them (i tried searching), but i ran across > this issue and i figured it would be interesting enough to show you guys > here: > > I was looking for a way to replace all the text in a string that doesn't > match a pattern with nothing (therefore string in, only part of the string > that matches my pattern out), one line with no arrays in the middle; and i > guess there is a way to do this with temp variables, well i know there is, > but i kind of wanted a more elegant solution, so i came up with this match > line > > $str = 'And the cow says "Mooo"'; > preg_match('/(?:(?!"[a-zA-Z\s]*").)*/', $str, $matches); > print_r($matches); > > output: > Array > ( > [0] => And the cow says > ) > > so i was pretty happy to see that, so if i pass that expression to > preg_replace it should, hopefully, replace that text with nothing, and i > theoretically should be left with "Mooo", which was my goal originally, so i > run > > print_r(preg_replace('/(?:(?!"[a-zA-Z\s]*").)*/', '', $str)); > > output: > " > > ... Hardly what i was expecting... Any ideas? bug, something i'm not > getting, something in the way preg works? > > Thanks in advance, > > > > ~ Alex >
[PHP] Re: Weird preg issue
but that doesnt work if you add something after the "Mooo" *sigh*. well it gets kept On Thu, Nov 4, 2010 at 3:47 PM, Alex Nikitin wrote: > Hi, > > I'm kind of new to this list, and so if there have been discussions about > this, i am not quite aware of them (i tried searching), but i ran across > this issue and i figured it would be interesting enough to show you guys > here: > > I was looking for a way to replace all the text in a string that doesn't > match a pattern with nothing (therefore string in, only part of the string > that matches my pattern out), one line with no arrays in the middle; and i > guess there is a way to do this with temp variables, well i know there is, > but i kind of wanted a more elegant solution, so i came up with this match > line > > $str = 'And the cow says "Mooo"'; > preg_match('/(?:(?!"[a-zA-Z\s]*").)*/', $str, $matches); > print_r($matches); > > output: > Array > ( > [0] => And the cow says > ) > > so i was pretty happy to see that, so if i pass that expression to > preg_replace it should, hopefully, replace that text with nothing, and i > theoretically should be left with "Mooo", which was my goal originally, so i > run > > print_r(preg_replace('/(?:(?!"[a-zA-Z\s]*").)*/', '', $str)); > > output: > " > > ... Hardly what i was expecting... Any ideas? bug, something i'm not > getting, something in the way preg works? > > Thanks in advance, > > > > ~ Alex >
Re: [PHP] php-general-digest-unsubscr...@lists.php.net not working?
Paul M Foster wrote: On Thu, Nov 04, 2010 at 12:34:35PM -0400, Daniel P. Brown wrote: On Thu, Nov 4, 2010 at 12:33, Daniel P. Brown wrote: If you continue to have issues, let me know and I will remove you. From the list, that is, to be clear. Not the Earth. Dang! I was just about to send you a list of people to remove! ;-} Paul Lord-a-mercy, yes!!! Daniel, what license for this service? BSD? CC? GPL? :-D Kevin Kinsey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to code in PHP an onchange event in a ?
On 2010-11-04, at 4:23 PM, Tomás Corrales Lemoine wrote: > Hi, List, > > > > I have this two files (“index.php” and “include.php”). They both work fine, > but I want to substitute the code for de onchange event in the tag. > Can I use PHP to code this event? How? > > > > Thanks. > > > > > > > > index.php: > > > > > > > echo ''; > > > > include_once 'include.php'; > > > > $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password'); > > > > tcl_MySQL_OpenDataBase($mysql_link, 'production'); > > > > $query = 'SELECT DISTINCT recipe.product_id, product.description FROM recipe, > product WHERE recipe.product_id = product.product_id ORDER BY > product.description'; > > $result = tcl_MySQL_DataQuery($mysql_link, $query); > > > > tcl_FillComboBox($result, 'Product', 'product_id', 'description', > 'alert(\'Alert Message\')'); > > > > tcl_MySQL_CloseConnection($mysql_link); > > > > echo ''; > > > > ?> > > > > > > > > include.php: > > > > > > > function tcl_MySQL_CloseConnection($link) { > > mysql_close($link); > > } > > > > function tcl_MySQL_ConnectToServer($host, $user, $password) { > > $link = mysql_connect($host, $user, $password); > > if (!$link) { > > die('No se pudo conectar: '.mysql_error()); > > } > > echo 'User '.strtoupper($user).' connected to MySQL server.'; > > return $link; > > } > > > > function tcl_MySQL_DataQuery($link, $query) { > > return mysql_query($query, $link); > > } > > > > function tcl_MySQL_OpenDataBase($link, $database) { > > mysql_select_db($database, $link); > > } > > > > function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) { > > echo ''.$label.' value="">'; > > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > > echo ''.$line[$col2]; > > } > > echo ''; > > } > > > > ?> > > > > > -- > Aeropuerto Internacional Frank País García de Holguín. > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Ajax back to the server to run the php Bastien Koert
RE: [PHP] Pros/Cons of using mysqli prepared statments
"Jay Blanchard" didst scribe: > using stored procedures has a lot of advantages. If you need to > change your SQL you can do it in one spot. It reinforces MVS or > modular coding behavior, the SP becomes very re-usable. Security > is improved. Performance can be improved. You can put the bulk of > the data handling on the database where it really belongs because > SP's can perform complex operations complete with control > structures. Lastly it simplifies your PHP code. Just don't go too far. Years and years ago, I worked on a project where there were about 100 stored procedures, many of which were 200-300 lines long, many of which called other stored procedures which called other stored procedures. These procedures were frequently modified. Attempting to debug this can of worms full of Pandora's boxes was like pulling hen's teeth. The initial idea was for the app to do almost nothing but call stored procedures and display results; this caused a number of problems which were ignored or solved badly. (I'd almost forgotten that horrible mess where I had no input on anything design-related, thank you for reminding me) -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pros/Cons of using mysqli prepared statments
[snip] Just don't go too far. [/snip] I absolutely agree! Doing SP's for SP sake is not desired and be truly careful about cascading the procedures. And always, ALWAYS document your code and put copious comments in the SP's. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pros/Cons of using mysqli prepared statments
One thing to remember is that dealing with results from prepared statements is different then getting results from queries, so if you are using both, confusion can easily set in (and lets face it, prepared statements arent always the best thing to use)... if its of any help, i have written a class to work around that, instantiate it with a query or result object from a statement and you get a uniform way to get the result array... http://pastebin.com/sAhZJcNX ~ Alex On Thu, Nov 4, 2010 at 5:38 PM, Jay Blanchard wrote: > [snip] > Just don't go too far. > [/snip] > > I absolutely agree! Doing SP's for SP sake is not desired and be truly > careful about cascading the procedures. And always, ALWAYS document your > code and put copious comments in the SP's. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Pros/Cons of using mysqli prepared statments
On Thu, 4 Nov 2010 02:48:55 -0500 Tamara Temple wrote: > I'm wondering what the advantages/disadvantage of using prepared > statements with mysqli are. I'm used to using the mysqli::query and > mysqli::fetch_assoc functions to deal with retrieving data and > bulding my sql statement in php code. Take a look at PHP PDO also. > Tamara Temple > -- aka tamouse__ > tam...@tamaratemple.com > > > "May you never see a stranger's face in the mirror." > > > -- > 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] How to code in PHP an onchange event in a ?
OnChange is Javascript. I might suggest you get yourself familiar with JQuery. JQuery makes your life a lot easier when there is a need for client browser interaction with site scripting. Richard L. Buskirk From: Tomás Corrales Lemoine [mailto:to...@hog.ecasa.avianet.cu] Sent: Thursday, November 04, 2010 4:23 PM To: php-general@lists.php.net Subject: [PHP] How to code in PHP an onchange event in a ? Hi, List, I have this two files (index.php and include.php). They both work fine, but I want to substitute the code for de onchange event in the tag. Can I use PHP to code this event? How? Thanks. index.php: '; include_once 'include.php'; $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password'); tcl_MySQL_OpenDataBase($mysql_link, 'production'); $query = 'SELECT DISTINCT recipe.product_id, product.description FROM recipe, product WHERE recipe.product_id = product.product_id ORDER BY product.description'; $result = tcl_MySQL_DataQuery($mysql_link, $query); tcl_FillComboBox($result, 'Product', 'product_id', 'description', 'alert(\'Alert Message\')'); tcl_MySQL_CloseConnection($mysql_link); echo ''; ?> include.php: User '.strtoupper($user).' connected to MySQL server.'; return $link; } function tcl_MySQL_DataQuery($link, $query) { return mysql_query($query, $link); } function tcl_MySQL_OpenDataBase($link, $database) { mysql_select_db($database, $link); } function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) { echo ''.$label.''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ''.$line[$col2]; } echo ''; } ?> -- Aeropuerto Internacional Frank País García de Holguín.
Re: [PHP] Pros/Cons of using mysqli prepared statments
On Nov 4, 2010, at 6:36 AM, Jay Blanchard wrote: [snip] If you have a query in your PHP code, which you are going to be executing a lot, even if you are using prepared statements, you can go one further by creating a stored procedure. Now the SQL server will only ever need to compile the statement once. No matter how many times it is used. You only need to supply the data which will be type appropriate. [/snip] I second this, using stored procedures has a lot of advantages. If you need to change your SQL you can do it in one spot. It reinforces MVS or modular coding behavior, the SP becomes very re-usable. Security is improved. Performance can be improved. You can put the bulk of the data handling on the database where it really belongs because SP's can perform complex operations complete with control structures. Lastly it simplifies your PHP code. (dangit, i sent this from the wrong address initially) I do know about stored procedures and have used them where appropriate (retrieving the entire contents of a table, one record from a table, etc.). It was the prepared statements that I haven't had experience with. I wasn't away that these were precompiled. That does make them more attractive for heavily executed pulls. On the other hand, the seem to require more intense maintenance than just changing some lines of code in a file if need be. (I assume prepared statements don't share the same efficiency of maintenance that stored procedures do across applications.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php