[PHP] delete S3 bucket with AWS PHP SDK
Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 I hope that clarifies my situation a bit. Sorry for not providing that sooner! Thanks Tim On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh azizsa...@gmail.com wrote: Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436
[PHP] Re: Apache
On 23 Sep 2013 at 11:37, Domain nikha.org m...@nikha.org wrote: The problem is the weak PHP upload mechanism! I'd have said the problem is weak metadata provision - overloading the filename for other purposes. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Friday's Question
On 20 Sep 2013 at 17:51, Tedd Sperling t...@sperling.com wrote: Age: Fast approaching doddering old fossil stage Mousepad: Yes. I use an Apple Mighty Mouse so that I can scroll my Excel spreadsheet in two directions at once while moving the mouse pointer across the screen. The optics works slightly better on the pad (covered in butterfly pix) than it would on the pine desktop. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Friday's Question
On 20 Sep 2013 at 18:20, Jen Rasmussen j...@cetaceasound.com wrote: -Original Message- From: Tedd Sperling [mailto:t...@sperling.com] 70Toothpaste, Deodorant, Aftershave, Minoxidil, Preparation-H, Bag Bomb, Fixodent LOL. What in the heck is a Bag Bomb? I have no idea what most of these items are except the toothpaste. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: exec and system do not work
On 26 Aug 2013 at 22:01, PhD Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: if( !file_exists(/var/www/orders.txt)); ^ | What's the semicolon doing there ---+ { echo system(touch /var/www/orders.txt, $ret); echo system(chmod 766 /var/www/orders.txt, $ret); echo 'file2br /'; echo file_exists(/var/www/orders.txt); } If you would point out my syntax errors, I will fix them. See above. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP vs JAVA
On 20 Aug 2013 at 23:59, PHP List phpl...@arashidigital.com wrote: While I don't have any references to back it up - my guess would be that Java may be seen as more versatile in general programming terms. A staggering number of enterprise level web applications are built with Java, add to that the possibility of writing Android apps with the same knowledge. To me the salient point is, does java has as extensive a library or set of interfaces to other packages (such as SQLite, mysql, etc)? I would say that, in general, the other teacher is incorrect speaking strictly in terms of web development. PHP has already won that crown many times over. That said, when I was in University, it was difficult to find a programming class that taught anything but Java - and that was 10yrs ago now. I chalked it up to the education bubble not being able to see what the rest of the world is actually doing. Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking down its nose at PHP. There being lots of courses proves nothing in and of itself. 20 years ago, there were lots of PC mags you could buy, which caused some folks to say look how much better the PC is supported than other platforms. Truth was, at the time, such support was needed given the mess of 640k limits, DOS, IRQs and the like, most of which issues have ceased to be relevant. Anyway, why should one need a course to learn PHP, assuming you already know other languages. It's simple enough. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to see all sessions sets in server
On 04 Aug 2013 at 11:28, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Like Matijn said, unless you're using some kind of client-side method to continually poll the server, you can't know if they've just closed their browser. There are Javascript events for exiting a page, but they don't work correctly on Safari and iOS Safari. onbeforeunload works fine in Safari; I use it all the time. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Foreach and mydql_query problem
On 22 Jul 2013 at 12:56, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Yes, i know that only one a singe row is updated and that is the problem. What can I do to update several rows at the same time? Which several rows? The row that will be updated is that (or those) that match your WHERE clause. Seems to me you should make sure your WHERE is correct. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: htaccess
On 07 Jul 2013 at 21:22, Tedd Sperling t...@sperling.com wrote: Confirmed. Those two lines cause the problem. However, commenting out those lines causes other problems. Are there similar statements to these: AddType application/x-httpd-php .php .htm .html This one tells apache to recognise .php, .htm, and .html as suffixes of files that need to be sent to PHP. You probably don't want to remove that [1]. AddHandler x-httpd-php5-cgi .php .htm .html Dunno what this one does. [1] But, having said that, realise that *all* files with those suffixes will be sent to PHP by apache, whether they contain any PHP code or not. Is that what you want? If I have an html file that contains some PHP code, I tend to use .phtml as suffix and so my AddType looks like: AddType application/x-httpd-php .php .phtml -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mongo usage
Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010',); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
| Could the comma after the last element in your array be causing the problem? I tried removing it, but there was no change. Thanks for the suggestion! On Sat, Jul 6, 2013 at 2:55 PM, Thomas Punt unassailable...@hotmail.comwrote: Could the comma after the last element in your array be causing the problem? Date: Sat, 6 Jul 2013 14:42:07 -0400 From: bluethu...@gmail.com To: php-general@lists.php.net Subject: [PHP] mongo usage Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010', ); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
| You commented out the setting of yhe addresses variable Those were both equivalent ways of stating the same thing. I tried substituting the other statement but there was no change: $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-adresses; Thanks again! On Sat, Jul 6, 2013 at 2:57 PM, Jonathan Sundquist jsundqu...@gmail.comwrote: You commented out the setting of yhe addresses variable On Jul 6, 2013 1:42 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey all, I'm trying to pick up some basic use of MongoDB using PHP. I seem to have hit an early obstacle that I'd like your opinion on. I try to pass an array to the mongo insert function, but for some reason the function does not recognize the array I'm passing. Even though I can perform a var_dump() on the array and see the contents. Here's the output I'm seeing (with error): Mongo Test Page array(6) { [first_name]= string(5) Peter [last_name]= string(6) Parker [address]= string(16) 175 Fifth Avenue [city]= string(8) New York [state]= string(2) NY [zip]= string(5) 10010 } *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php* on line *36* *Fatal error*: Call to a member function insert() on a non-object in * /var/www/mongomaven/index.php* on line *36* * * And here's the code: html head titleMongo Test/title /head body Mongo Test Page ?php $connection = new Mongo(); $db = $connection-jfdb; $collection = $db-addresses; //$adresses = $connection-jfdb-adresses; $address = array( 'first_name' = 'Peter', 'last_name' = 'Parker', 'address' = '175 Fifth Avenue', 'city' = 'New York', 'state' = 'NY', 'zip' = '10010',); var_dump($address); echo 'br /'; $addresses-insert($address); ? /body /html I'd appreciate any advice you might have. Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] mongo usage
| You seem to spell the variable differently (1 'd' vs. 2 'd's)? Thanks! Fixed the type-o. Still no change. $connection = new Mongo(); $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-addresses; Any other suggestions? Appreciated. Tim On Sat, Jul 6, 2013 at 5:39 PM, Matijn Woudt tijn...@gmail.com wrote: On Sat, Jul 6, 2013 at 9:16 PM, Tim Dunphy bluethu...@gmail.com wrote: | You commented out the setting of yhe addresses variable Those were both equivalent ways of stating the same thing. I tried substituting the other statement but there was no change: $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-adresses; Thanks again! You seem to spell the variable differently (1 'd' vs. 2 'd's)? - Matijn -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
[PHP] Re: mongo usage
On 06 Jul 2013 at 23:27, Tim Dunphy bluethu...@gmail.com wrote: | You seem to spell the variable differently (1 'd' vs. 2 'd's)? Thanks! Fixed the type-o. Still no change. $connection = new Mongo(); $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-addresses; ~ Any other suggestions? Appreciated. Fix the other typo. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mongo usage
Thanks. Sorry to bug you guys with this. That did it. sigh On Sat, Jul 6, 2013 at 6:49 PM, Tim Streater t...@clothears.org.uk wrote: On 06 Jul 2013 at 23:27, Tim Dunphy bluethu...@gmail.com wrote: | You seem to spell the variable differently (1 'd' vs. 2 'd's)? Thanks! Fixed the type-o. Still no change. $connection = new Mongo(); $db = $connection-jfdb; //$collection = $db-addresses; $adresses = $connection-jfdb-addresses; ~ Any other suggestions? Appreciated. Fix the other typo. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
[PHP] Re: One more newbie question. About foreach..
On 23 Jun 2013 at 16:11, Karl-Arne Gjersøyen karlar...@gmail.com wrote: // Foreach get all given serialnumbers as I want it foreach($serialnumber as $snr){ // I got the number of serialnumbers given in the array $count = count($serialnumber); Why not do this *before* the foreach loop? // I thought that a for loop would do the trick together with foreach // And repeat the $sql = SELECT below but that did not happen. for($i = 0; $i = $count; $i++){ // Connect and get only those records with given serialnumber $sql = SELECT * FROM explosive WHERE serialnumber = '$snr'; } // End of for loop } // End of foreach loop All this for loop does is overwrite $sql each time. $result = mysql_query($sql, $connect) or die(mysql_error()); $count = mysql_num_rows($result); You need to have your mysql_query *inside* the for loop. Then, what are you doing with the results of the mysql_query? Nothing? Also, why do you need the for loop anyway? What is it supposed to do? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] limit access to php page
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
Re: [PHP] iterate javascript verification
[] = input type='text' required id='department_$counter.' name='department[$counter]' /br /br /; $tmp[] = label for='title_$counter'Title:/labelbr /; $tmp[] = input type='text' required id'title_.$counter' name='title[$counter]' /br /br /; $tmp[] = label for='email_.$counter'Email:/labelbr /; $tmp[] = input type='email' required id='email_.$counter' name='email[$counter]' /br /br /; $tmp[] = label for='phone_$counter'Phone:/labelbr /; $tmp[] = input type='text' required id='phone_$counter' name='phone[$counter]' /br /br /; } You can DRY this up (the HTML input fields) similarly to the way you did the validation above... for ($i = 1;$i = $num_forms; ++$i) { foreach ($fields as $fld) { $tmp[]=label for='$fld_$counter' . ucwords(str_replace('_',' ',$fld) . :/labelbr /; $tmp[]=input type='text' required id='$fld_$counter' name='$fld[$counter]' /br /br /; } } Further, you could also check the validity of field right at the point of generation and issue the error right next to the field in error, which is usually a better UX. $tmp[] = input type='hidden' id='num_forms' name='num_forms' value='$num_forms' /br /br /; $tmp[] = input type='hidden' id='requestor_email' name='requestor_email' value='$requestor_email' /; $tmp[] = input type='submit' name='submit' value='Create Ticket' /; $tmp[] = /form/div; ? !DOCTYPE html html head titleLDAP Form/title body ?php echo implode(\n,$tmp) . \n; ? /body /html You will notice that I moved the code for the form to above the HTML section. I believe that very little PHP should be interspersed with the HTML -- it makes for cleaner code. You can use single quotes around form attributes so you don't have to escape the double quotes. The names in the form are now arrays. This makes your life much easier when extracting the values later in PHP. When you check the page in a HTML5 aware brower, you will see how the validation is done. Ken At 10:17 PM 5/24/2013, musicdev wrote: You can validate via JS if required, for example: (JS CODE): if(element.value.length == 0){ // handle 0 length value } I do agree with Ken that you SHOULD NOT perform JS validation. It is preferable to use php or the new HTML5 features. JS can be turned-off by the user which will make JS validation impossible. On Fri, May 24, 2013 at 8:07 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I have a php script that creates a variable number of forms based on a $_POST variable from a preceding page. It then takes the data input into the form and neatly packages the result into an email sent to an email address (eventually to be a ticketing system). Almost everything on the page works great. The only thing I can't seem to get working is how to verify that the fields in the form are not left empty using javascript. The syntax I'm using seems like it should work, however when I leave one or more of the fields empty, the email gets sent anyway with the missing data. Here's the app I was hoping someone might be able to suggest a successful approach: html head titleLDAP Form/title body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; ? script function validateForm() { var a=document.forms[ldap_accounts][first_name_].value; if (a==null || a==) { alert
Re: [PHP] iterate javascript verification
Sounds good! Thanks Ken. Very clear now. Tim Sent from my iPhone On May 27, 2013, at 1:57 PM, Ken Robinson kenrb...@rbnsn.com wrote: When you do validation of the form in the same script that shows the form, the normal way to do this is ?php if (isset($_POST['submit'])) { // // validation here // } ? This won't work if you're getting to the page via another form, since the $_POST['submit'] is set. There two ways of avoiding this: 1) use hidden fields in each form to indicate which form was submitted 2) use a different name for each form's submit button and use that in the above code Ken At 12:52 PM 5/27/2013, Tim Dunphy wrote: Hey guys, Thanks for the input! This is pretty nice, and DOES work. I like the fact that the fields have been into an iterative array. It's a very elegant solution. However the problem with this approach is that if you load the page directly it works. But if you call the page from the index.php page you get an initial error on all fields as they are all quite naturally empty when you first load the page. Here's the index.php page. All it is is HTML, no php: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? Why this happens when you call the ldap.php page from index.php but not when you load the page directly beats me. But maybe someone can shed some light on that? Thanks! On Sat, May 25, 2013 at 3:45 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 9:51 PM, Ken Robinson kenrb...@rbnsn.com wrote: I took your code and modified it to use HTML5 validation (and few other changes). You can see the results at http://my-testbed.com/test1/form_validation.php http://my-testbed.com/test1/form_validation.php My code follows: ?php $fields = array('first_name','last_name','department','title','email','phone'); $num_forms = 1; $tmp = array(); $errors = array(); if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; for ($i = 1;$i = $num_forms; ++$i) { foreach ($fields as $fld) { if ($_POST[$fld][$i] == '') { $errors[] = ucwords(str_replace('_',' ',$fld)) . for account $i can not be blank; } } } } if (!empty($errors)) { $tmp[] = The following fields are in error:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp
[PHP] iterate javascript verification
Hello list, I have a php script that creates a variable number of forms based on a $_POST variable from a preceding page. It then takes the data input into the form and neatly packages the result into an email sent to an email address (eventually to be a ticketing system). Almost everything on the page works great. The only thing I can't seem to get working is how to verify that the fields in the form are not left empty using javascript. The syntax I'm using seems like it should work, however when I leave one or more of the fields empty, the email gets sent anyway with the missing data. Here's the app I was hoping someone might be able to suggest a successful approach: html head titleLDAP Form/title body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; ? script function validateForm() { var a=document.forms[ldap_accounts][first_name_].value; if (a==null || a==) { alert(User $counter first name must be filled out.); return false; } var b=document.forms[ldap_accounts][last_name_].value; if (b==null || b==) { alert(User $counter last name must be filled out.); return false; } var c=document.forms[ldap_accounts][department_].value; if (c==null || c==) { alert(User $counter department must be filled out.); return false; } var d=document.forms[ldap_accounts][title_].value; if (d==null || d==) { alert(User $counter title must be filled out.); return false; } var d=document.forms[ldap_accounts][email_].value; if (d==null || d==) { alert(User $counter address must be filled out.); return false; } var d=document.forms[ldap_accounts][phone_].value; if (d==null || d==) { alert(User $counter phone name must be filled out.); return false; } } /script ?php } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? /body /html Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Question about session_id() and session_start()
On 20/05/2013, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 20-5-2013 22:14, Tim Schofield wrote: Matijn There are well over half a million lines of source code in PHP. It seems a little unhelpful to tell someone to go and read half a million lines of C when you could just tell them the answer? Thanks Tim Course View Towers, Plot 21 Yusuf Lule Road, Kampala T +256 (0) 312 314 418 M +256 (0) 752 963 325 www.weberpafrica.com Twitter: @TimSchofield2 Blog: http://weberpafrica.blogspot.co.uk On May 20, 2013 6:24 PM, Matijn Woudt tijn...@gmail.com wrote: On Mon, May 20, 2013 at 5:33 AM, 孟远涛 yuantao.m...@gmail.com wrote: I find the Note in PHP document. http://www.php.net/manual/en/function.session-id.php Note: When using session cookies, specifying an id for session_id() will always send a new cookie when session_start() is called, regardless if the current session id is identical to the one being set. I feel puzzled about this feature. Even if the current session id is identical to the one one being set, session_start will send a new cookie. I want to know why session_start behave in this way. Forgive my poor English. Thanks in advance. You will find the answer in the PHP source code. If you don't want this to happen, check if the current session id matches with the value you want to set it to, and don't set if they match. - Matijn Tim, first of all, please bottom-post on this list. Tell that to the designers of the android gmail app :-) Secondly, a simple google search for php c session_start resulted in this: https://github.com/php/php-src/blob/master/ext/session/session.c#L1303 That wasn't the advice given. The advice given was to read the source code. My point was that is not very helpful advice. With a few notable exceptions the help given on this list has become less and less friendly over the years I have been reading it. This can't be good for the PHP community. - Tul Tim -- Course View Towers, Plot 21 Yusuf Lule Road, Kampala T +256 (0) 312 314 418 M +256 (0) 752 963 325 www.weberpafrica.com @TimSchofield2 Blog: http://weberpafrica.blogspot.co.uk/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about session_id() and session_start()
Matijn There are well over half a million lines of source code in PHP. It seems a little unhelpful to tell someone to go and read half a million lines of C when you could just tell them the answer? Thanks Tim Course View Towers, Plot 21 Yusuf Lule Road, Kampala T +256 (0) 312 314 418 M +256 (0) 752 963 325 www.weberpafrica.com Twitter: @TimSchofield2 Blog: http://weberpafrica.blogspot.co.uk On May 20, 2013 6:24 PM, Matijn Woudt tijn...@gmail.com wrote: On Mon, May 20, 2013 at 5:33 AM, 孟远涛 yuantao.m...@gmail.com wrote: I find the Note in PHP document. http://www.php.net/manual/en/function.session-id.php Note: When using session cookies, specifying an id for session_id() will always send a new cookie when session_start() is called, regardless if the current session id is identical to the one being set. I feel puzzled about this feature. Even if the current session id is identical to the one one being set, session_start will send a new cookie. I want to know why session_start behave in this way. Forgive my poor English. Thanks in advance. You will find the answer in the PHP source code. If you don't want this to happen, check if the current session id matches with the value you want to set it to, and don't set if they match. - Matijn
[PHP] Re: generate onfly PDF
I have had outstanding success with wkhtmltopdf: https://code.google.com/p/wkhtmltopdf/ It's a self-contained standalone program that you can call from PHP. It uses a full-bodied HTML interpreter based on Webkit. Highly recommended, I've been using it for years. It's open source and free. I should say, I've used the Linux version. It looks like there's a Windows version, but I have no experience with that, if that's what you need. Tim Rafnewsraf.n...@gmail.com wrote: Hi, 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. thx Al. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: rather a HTML Q; however 2-FRAME
On 15 Mar 2013 at 11:00, tamouse mailing lists tamouse.li...@gmail.com wrote: 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). Meaning, in other words, that they *are* supported. It's unlikely in any case that any feature will ever be removed from a browser. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Undefined index....
On 15 Mar 2013 at 13:10, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) { // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Why do I get the notice that $xml is an undefined index? Because it's undefined. So is $pos. From what you've written above, both are local to includeXML. But neither is passed in as a parameter, nor is global. You can't initialise it within the function, it seems to me. If $xml is supposed to be appended to and grown as you recurse up and down, then you have two choices: 1) Make them global 2) Pass both as extra parameters to includeXML In both cases, each needs to be initialised before the first call to the recursive function Solution (1) $xml = ''; $pos = 0;// Presumably. includeXML ($file, $locale, $url, 1); ... function includeXML ($file, $locale, $url, $level = 1) { global $xml, $pos; // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML ('repository/' . $included, $locale, (int)$level + $pos - 1); } } } Solution (2) $xml = ''; $pos = 0;// Presumably. includeXML ($xml, $pos, $file, $locale, $url, 1); ... function includeXML ($xml, $pos, $file, $locale, $url, $level = 1) {// Note the on the first parameter // stuff while(($line = fgets($fp)) !== false) { if($pos === false) { $xml .= $line; } else { includeXML ($xml, $pos, 'repository/' . $included, $locale, (int)$level + $pos - 1); } } } BTW it seems to me that you'll have the same problem with $included unless there's other code in includeXML that you've omitted. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Populate input from another form
On 08 Mar 2013 at 19:45, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca 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]);? What purpose does this field serve? 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? You mean the script that processes the submitted page? No. Submitting causes your page to get replaced by the form's action, CRTP_Query.php in this case. Hmm, although it looks like you want a frame to receive the new page rather than replace the page. You'd probably need JavaScript to do that. Do I need to use jquery? Avoid, IMO. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Open form in new window
On 04 Mar 2013 at 17:10, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: button type=button onclick=OpenWindow()Submit/button will not submit the form contents. Nothing to stop your OpenWindow() function doing a submit as in: button type=button onclick=OpenWindow(this.form)Submit/button function OpenWindow (formPtr) { // Some actions formPtr.submit (); } Personally I never submit forms. I use ajax to communicate with PHP scripts and do something with the data that is returned by the script. You can see a simple example at http://www.clothears.org.uk -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Open form in new window
On 04 Mar 2013 at 20:17, Paul M Foster pa...@quillandmouse.com wrote: On Mon, Mar 04, 2013 at 05:39:00PM +, Tim Streater wrote: Personally I never submit forms. I use ajax to communicate with PHP scripts and do something with the data that is returned by the script. You can see a simple example at http://www.clothears.org.uk I'm trying to figure out where the net gain in that is. The PHP file being called via AJAX is doing its processing on the server either way. So it appears the only difference is an asynchronous Javascript/AJAX call or a synchronous PHP call (on a standard PHP form submission). What am I missing? ISTM it's better for the user if, rather than reloading a whole page, you can get some bits of data from the server and use them to just alter the parts of the page that need updating. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Strip emails from a document
On 26 Jan 2013 at 16:24, Tedd Sperling t...@sperling.com wrote: I thought I had a function to strip emails from a document, but I can't find it. So, before I start writing a common script, do any of you have a simple script to do this? I have a function that will take a comma separated string consisting of emails in these formats: Soap, Joe joe.s...@example.com Joe Soap joe.s...@example.com (Joe Soap) joe.s...@example.com and turn them into a list where all the above examples are converted to: Joe Soap joe.s...@example.com but it won't handle things like: joe@soap@example.com which I understand is also valid. You are welcome to it if you wish. Cheers, -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Boolean type forced on string assignment inside if statement
On 02 Jan 2013 at 16:05, Stephen stephe...@rogers.com wrote: On 13-01-02 10:53 AM, Marc Guay wrote: Hi folks, if ($a = foo $b = bar){ echo $a.br /.$b; } Returns: 1 bar I expect: foo bar Is this documented? takes precedence over = http://php.net/manual/en/language.operators.precedence.php You may want to use brackets OP may want to avoid doing something unusual which may confuse a casual reader. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Strange string stuff -- maybe everything is ending...
On 22 Dec 2012 at 16:50, Tedd Sperling t...@sperling.com wrote: On Dec 21, 2012, at 8: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? It depends upon the language -- while it is true that the start of a string is located at a memory address, the chars of the string are identical to the chars in an array. As such, you can view a string as an array. Each index is representative of a char (one byte) in the string. That is explicitly documented here: http://php.net/manual/en/language.types.string.php String access and modification by character Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. Think of a string as an array of characters for this purpose. The functions substr() and substr_replace() can be used when you want to extract or replace more than 1 character. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Switch - Case Statement Questions
On 18 Nov 2012 at 14:44, Jim Giner jim.gi...@albanyhandball.com wrote: 2. Using Switch {ALWAYS FIRST CASE!!!} //$boxes = 1; //switch ($count) { //case ($count 14): //$boxes = 3; //break; //case ($count 7 $count = 14): //$boxes = 2; //break; //case ($count = 7): //default : //$boxes = 1; //break; //} To answer Iñigo's comment - the OP's version is very much like an If-ElseIF structure, and nothing like a Switch. Just so. Perhaps those who are not grasping the point could re-read their copy of The Elements of Programming Style by Kernighan and Plauger where this sort of issue is covered. See, it's all about expectations. When I worked at SLAC, there was a wise guy there who had removed the catalytic converter from his Scirocco and who though it clever to race up 280 from San Jose to SLAC at 100mph, sometimes slipstreaming behind another idiot doing the same. If I look in my rear-view mirror, I expect those I can see to be doing 70mph tops (that's what a lot of people did 30 years ago on 280), not 100, and to make judgements accordingly. Equally, I have certain expectations when I see a switch statement; it trying hard to look like if-elseif-etc is not one of them. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Switch - Case Statement Questions
On 17 Nov 2012 at 01:33, Iñigo Medina imed...@grosshat.com wrote: On Fri, 16 Nov 2012, Jim Giner wrote: Maybe I'm way out of touch, but when I look at php.net for the syntax of the switch statement I see: switch($var){ case (value): (do something) case (other value): (do something else) } IN your example, you are using a switch syntax that is nothing like that. I think that your case statements are not actually evaluating the value of $count, but are themselves evaluating to a true value that has nothing to do with $count. That `switch` is evaluating to true each case. It's an alternative of using if-elseif structure. It may be an alternative, but it breaks the principle of least surprise. If I'm looking through someone's code, and I see a switch, I expect to see it used as Jim described. If the writer needs a different type of logic to make a decision, that is what the cascaded if-elseif-elseif construct is for, when the tests don't fall into a simple set-of-values choice. The job of a programmer is not to be clever with a view to impress those who follow, but to achieve the desired outcome while at the same time making life easy for those who follow. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Switch - Case Statement Questions
On 16 Nov 2012 at 12:10, Omar Muhsin mrfroa...@gmail.com wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instead always I get the first case. 1.Using nested if statement {THE INTENDED BEHAVIOR}: if ($count 14) $boxes = 3; elseif($count 7 $count = 14) You don't need the count=14 part as you will *only* get there if $count=14. $boxes = 2; else $boxes = 1; 2. Using Switch {ALWAYS FIRST CASE!!!} //$boxes = 1; //switch ($count) { //case ($count 14): //$boxes = 3; //break; //case ($count 7 $count = 14): //$boxes = 2; //break; //case ($count = 7): //default : //$boxes = 1; //break; //} Does anyone know the answer why using the Switch it always execute the first case ? As has been pointed out you need switch(true). That's a strange way of writing a switch, IMO. You should be using the if version. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: appreciation
On 12 Oct 2012 at 12:36, Maciek Sokolewicz tula...@php.net wrote: However, this is likely not what the OP wants. What he likely does want is to check if the filename is not '.' or '..'. Of course, there are numerous ways to do this. From very simple things like: if ( $filename != '.' $filename != '..') Personally if I have a loop looking at filenames in a directory, I'll start it with: while (something) { if ($filename=='.' || $filename=='..') continue; // rest of loop } That way, the unwanted cases don't clutter up the logic for the cases I do/might want. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: limiting
On 10 Oct 2012 at 19:17, David McGlone da...@dmcentral.net wrote: BTW - in any of your other computer languages didn't they utilize a 'return' statement? PHP's is no different. back in like '85, I learned Pascal that's the only language I learned and I don't recall if it used return. Mmmm. There's the problem. Pascal doesn't *have* a return statement. In Pascal, implicitly, you return when execution reaches the end of a function. In fact the same is true of PHP and JavaScript, but in those languages you can return early just by saying return. IMO, this is a major limitation of Pascal. I use returns wherever I feel like it - if I detect there's nothing more for the function to do, I return. Purists object to this; they say you should enter a function at one place and leave at one place. Well, that's a point of view. But more often that not it just leads to convoluted code in order to achieve that. The one time I *had* to use Pascal as that was the only option, I simply put a 999: label at the end of the function and did goto 999 wherever I wanted to do a return. Simples! -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: limiting
On 10 Oct 2012 at 19:53, David McGlone da...@dmcentral.net wrote: On Wednesday, October 10, 2012 07:36:00 PM Tim Streater wrote: On 10 Oct 2012 at 19:17, David McGlone da...@dmcentral.net wrote: BTW - in any of your other computer languages didn't they utilize a 'return' statement? PHP's is no different. back in like '85, I learned Pascal that's the only language I learned and I don't recall if it used return. Mmmm. There's the problem. Pascal doesn't *have* a return statement. The one time I *had* to use Pascal as that was the only option, I simply put a 999: label at the end of the function and did goto 999 wherever I wanted to do a return. Simples! goto was the thing that got on my nerves. Even to this day I hate that word with a passion. Hu! Apart from what I described above, I haven't needed to use GOTO since I stopped writing FORTRAN in 1978. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: limiting
On 09 Oct 2012 at 20:46, Matijn Woudt tijn...@gmail.com wrote: For example your previous post, you could have just looked up what the 'echo' and 'return' statements do in the PHP manual, and they are probably explained pretty OK in those books you own too. You probably could have answered the questions you posted here yourself, after reading PHP manual carefully. Here, the phrase PHP manual means: http://www.php.net/manual/en/ which I consider to be an excellent written resource for the language. In fact, I own no PHP books at all (whereas I do for JavaScript/HTML/CSS/SQLite) so that must say something about the quality of the on-line documentation. Further, it is written in a straightforward way, not trying to be clever (unlike some languages I could mention), so I can recommend it. It's available in languages other than English, too. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Differences
On 04 Oct 2012 at 01:48, David McGlone da...@dmcentral.net wrote: Hi everyone, I have been playing around with some code the list helped me with a while back and I'm not grasping the concept between return and echo and the PHP manual doesn't answer this, unless I'm missing something. There is an example at the very bottom of PHP's return manual, but it's confusing. It's a poor example, for one thing. As others have said, echo and return have nothing to do with each other. So now I'm left wondering why return will only give me the first result in an array, but echo will give me all the results of the array. Using stuart's example he had sent me a while back I've messed around with it and modified it to better understand it: function filename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ return $filename; } } echo completeImageFilename($row['MLS_No']); With the above code I only get the first image of each picture name, but when I change return to echo, it groups and displays all the pics that have the same picture name. I assume that where you have function filename above, you really mean function completeImageFilename. Why do you think that the return you have coded above should give more than one filename when you've written return $filename? That's one filename. You then echo that out with your echo statement (because it's the return value of the function), and that's what you see. If you change the return to an echo, then instead of returning after once round your while loop, the while loop goes round and round dealing with each filename you have in $matches, and echoes out each one. When the while loop has completed, the function returns, but returns nothing at all. So your original echo then does nothing at all. And so you see the observed behaviour. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with my login script
On 02 Oct 2012 at 12:07, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 02-10-2012 11:59, Bálint Horváth wrote: The problem was already solved. I forgot to send a copy to the list... Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT use break at all (in a loop)... (switch is an exception) I personally find this statement to be utter bullshit. There is nothing wrong with using break. There is a very good reason why it's available in the language. In very many cases, it costs a lot less code to add a break than to add additional clauses to your while-conditional. Agree 100%. -- Cheers -- Tim
Re: [PHP] Re: php can't insert data mysql table
hey thanks guys adding debugging info worked. Actually it was mysqli_error() providing me with a specific error of where the problem was. Cannot insert query:Duplicate entry '0' for key 'PRIMARY' This is the data in the table mysql select * from guitarwars; ++-+---+---+---+ | id | date| name | score | screenshot| ++-+---+---+---+ | 0 | 2012-10-01 11:55:45 | Tommy Tutone | 2442 | bg_titlestrip.jpg | | 1 | 2012-10-01 08:34:18 | Dunphy| 2 | proof.jpg | | 2 | 2012-10-01 00:25:53 | ray davies| NULL | 2241 | | 3 | 2008-04-22 14:37:34 | Paco Jastorius| NULL | NULL | | 4 | 2008-04-22 21:27:54 | Nevil Johansson | NULL | NULL | | 5 | 2008-04-23 09:12:53 | Belita Chevy | NULL | NULL | | 6 | 2008-04-23 14:09:50 | Kenny Lavitz | NULL | NULL | | 7 | 2008-04-24 08:13:52 | Phiz Lairston | NULL | NULL | | 8 | 2008-04-25 07:22:19 | Jean Paul Jones | NULL | NULL | | 9 | 2008-04-25 11:49:23 | Jacob Scorcherson | NULL | NULL | ++-+---+---+---+ This was the query I was using: $query = INSERT INTO guitarwars (date, name, score, screenshot) VALUES (NOW(), '$name', '$score', '$screenshot'); It seems to be inserting a default value of 0 since the id is not being specified and that's when I realized that I had failed to auto_increment the id column. D'oh! So once I did that everything worked like a charm. @Ken First -- NEVER post code with your database username/password. Since you did, change your db password immediately. Well actually I did not. Did you really think 'secretsauce' was my password? :) But I guess you're right in that this may be a little ambiguous when seeking advice in lists so from now on I will take your advice on making login information unambiguously fake in the form of user='' and password='xxx'. @Stuart But take note of what everyone else is saying. You should be getting the error message when this happens which will tell you exactly what the problem is, above and beyond Cannot insert query (which, btw, makes no sense at all :)). Ok well I'm using an 'insert' query so I'm not sure why you say that this makes no sense at all. :)) If you don't mind giving this n00b advice what would be a better/more accurate error message? They take away from this for me was.. don't skimp on the error messages! The one I got was so clear that fixing the problem was easy at that point. But thanks again guys.. this list has been an indispensable source source of wisdom on my journey in learning PHP. Tim Thanks again guys, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Re: php can't insert data mysql table
I think the comment about your cannot insert query was because it really did not make sense. Once truly cannot insert a query. Since you ask tho, a more approp message might be Insert query failed to execute.brError returned was . mysqli_error() . brQuery was $q As for your index issue - you are using an autoincrement(?) field as the primary key. Is this related to another record in your db? If not, why even have the primary key? Hey! I really like your error message. Borrowing it! :) Yes I am now using auto_increment, and that's what seemed to solve my issue. Looks like a simple omission in forgetting to use auto_increment and using primary key. I usually know better. I'll blame this one on the clonopin. lol thank you tim On Mon, Oct 1, 2012 at 12:30 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 10/1/2012 12:20 PM, Tim Dunphy wrote: hey thanks guys adding debugging info worked. Actually it was mysqli_error() providing me with a specific error of where the problem was. Cannot insert query:Duplicate entry '0' for key 'PRIMARY' This is the data in the table mysql select * from guitarwars; ++-+--**-+---+** ---+ | id | date| name | score | screenshot | ++-+--**-+---+** ---+ | 0 | 2012-10-01 11:55:45 | Tommy Tutone | 2442 | bg_titlestrip.jpg | | 1 | 2012-10-01 08:34:18 | Dunphy| 2 | proof.jpg | | 2 | 2012-10-01 00:25:53 | ray davies| NULL | 2241 | | 3 | 2008-04-22 14:37:34 | Paco Jastorius| NULL | NULL | | 4 | 2008-04-22 21:27:54 | Nevil Johansson | NULL | NULL | | 5 | 2008-04-23 09:12:53 | Belita Chevy | NULL | NULL | | 6 | 2008-04-23 14:09:50 | Kenny Lavitz | NULL | NULL | | 7 | 2008-04-24 08:13:52 | Phiz Lairston | NULL | NULL | | 8 | 2008-04-25 07:22:19 | Jean Paul Jones | NULL | NULL | | 9 | 2008-04-25 11:49:23 | Jacob Scorcherson | NULL | NULL | ++-+--**-+---+** ---+ This was the query I was using: $query = INSERT INTO guitarwars (date, name, score, screenshot) VALUES (NOW(), '$name', '$score', '$screenshot'); It seems to be inserting a default value of 0 since the id is not being specified and that's when I realized that I had failed to auto_increment the id column. D'oh! So once I did that everything worked like a charm. @Ken First -- NEVER post code with your database username/password. Since you did, change your db password immediately. Well actually I did not. Did you really think 'secretsauce' was my password? :) But I guess you're right in that this may be a little ambiguous when seeking advice in lists so from now on I will take your advice on making login information unambiguously fake in the form of user='' and password='xxx'. @Stuart But take note of what everyone else is saying. You should be getting the error message when this happens which will tell you exactly what the problem is, above and beyond Cannot insert query (which, btw, makes no sense at all :)). Ok well I'm using an 'insert' query so I'm not sure why you say that this makes no sense at all. :)) If you don't mind giving this n00b advice what would be a better/more accurate error message? They take away from this for me was.. don't skimp on the error messages! The one I got was so clear that fixing the problem was easy at that point. But thanks again guys.. this list has been an indispensable source source of wisdom on my journey in learning PHP. Tim Thanks again guys, Tim I think the comment about your cannot insert query was because it really did not make sense. Once truly cannot insert a query. Since you ask tho, a more approp message might be Insert query failed to execute.brError returned was . mysqli_error() . brQuery was $q As for your index issue - you are using an autoincrement(?) field as the primary key. Is this related to another record in your db? If not, why even have the primary key? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
[PHP] Re: PHP Bounce messages
On 21 Sep 2012 at 08:40, Lester Caine les...@lsces.co.uk wrote: I know that the php list are one of the 'reply to sender' email handling camp rather than reply to list. I don't understand this. I reply (not that I mail that often) just to the list, if possible. Why would I do anything else? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Re: PHP Bounce messages
On 21 Sep 2012 at 20:56, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Sep 21, 2012 at 4:17 AM, Tim Streater t...@clothears.org.uk wrote: On 21 Sep 2012 at 08:40, Lester Caine les...@lsces.co.uk wrote: I know that the php list are one of the 'reply to sender' email handling camp rather than reply to list. I don't understand this. I reply (not that I mail that often) just to the list, if possible. Why would I do anything else? I believe Lester is referring to the behaviour of the Reply-To: field sent by the list serv, which is the sender's address. Some other listservs put the list reply address in Reply-To: Thanks, I'm with you now. And I also do the To: cc: musical chairs. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Re: Programmers and developers needed
On 19 Sep 2012 at 16:32, Matijn Woudt tijn...@gmail.com wrote: unless they were a majority is the thing that bothers me. Getting a majority is hard, take for example the Dutch Politics [1]. Our country is now led by a parliament of 10 different political parties. Getting things done now is really hard, because each party has their own goals and finding a majority is for almost impossible. If all the parties were strictly following their own will, there would probably only a handful things done. The only way to get things done now is by making compromises. And so Dutch governments only last short periods of time, and it takes a long time to create a coalition. This is why Proportional Representation is such a bad idea. Better to have strong government with a clear mandate, and if you don't like it, vote it out next time. By the way what does any of this have to do with PHP? Nothing, I think. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Programmers and developers needed
On Fri, Sep 14, 2012 at 3:00 PM, Robert Cummings rob...@interjinn.comwrote: On 12-09-13 06:10 PM, Ashley Sheridan wrote: On Thu, 2012-09-13 at 16:48 -0400, Tedd Sperling wrote: On Sep 13, 2012, at 3:45 AM, agbo onyador onya...@gmail.com wrote: Hello there! We are looking for programmers and developers to create a world wide system. Your comments are welcome. Wow! I'm looking for world wide money. tedd Join the queue... There's a queue? Bah humbug... I've been waiting for delivery all this time. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I hear that there's this thing-a-ma-jig called the world wide web.. do we really need a world WIDER web? maybe that's what they have in mind! holds cup out to african royalty -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] Programmers and developers needed
We are looking for programmers and developers to create a world wide system. Is it bigger than a bread box? On Thu, Sep 13, 2012 at 3:45 AM, agbo onyador onya...@gmail.com wrote: Hello there! We are looking for programmers and developers to create a world wide system. Your comments are welcome. -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] What do you call the end-user?
On 19 Jul 2012 at 18:26, Tedd Sperling t...@sperling.com wrote: First question: What do you call the people who ultimately use your code? I expect I'll call her Dear. See, my app, a replacement for Eudora, is used by yours truly only at the mo. However, come time to upgrade SWMBO's Mini, which will run Lion or perhaps ML, Eudora will cease to function and I'll move her onto my app. This question transcends your code working correctly, accurately, and securely -- no need to comment on those aspects. But rather more specifically do you consider how easily your whomever can use your work efforts? In principle, yes. But that's a bit hard at the moment. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On 17 Jul 2012 at 21:58, Paul M Foster pa...@quillandmouse.com wrote: On Wed, Jul 18, 2012 at 08:45:34AM +1200, James Newman wrote: Just to put my 2cents in, you might want to try jQuery if you're going to go down the AJAX road. JQuery is a LOT of code to include if you're just going to do an AJAX call or two. There are examples of doing straight AJAX with Javascript on the 'Net. Once you work through them, you find that there's a static part that you can include in all the files you want to make AJAX calls. And then there's the part that deals directly with the data you get back from whatever PHP or other script is feeding you data from outside the website. That's the part that needs custom work. I *hate* Javascript, but I managed to figure it out. I agree about JQuery. You can look here: http://www.clothears.org.uk/examples-ajax.php to see a simple example of how to use AJAX. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On 16 Jul 2012 at 21:19, Jen Rasmussen j...@cetaceasound.com wrote: Sometimes I need to use javascript to fill a drop down box based on the value of a previous drop down box. However, the information to fill the latter is stored in mysql and can be a lot, what I have been doing is that, using PHP, I create hidden fields with all the possible information that might be needed to fill the second drop down. For example, the user chooses a bank from a drop down, and then a list of clients is displayed on the following drop down. I use PHP to read all clients from all the banks and put that as hidden fields on the html page. It is very cumbersome. Well it would be. This approach doesn't scale. I do not want to read the database (which changes dynamically) from javascript directly due to confidentiality and because a lot of care has been taken to create the appropriate queries with checks and protect misuse of the information using PHP. I doubt if you can read it from JavaScript. My questions are: 1) Do people just normally use hidden fields to store possible information to fill the drop downs? 2) any suggestions? You could use ajax to request the information needed to load the second drop down. Once the user chooses their bank, then your JavaScript makes an ajax request to a PHP script that returns the clients list. You use this to populate the second drop down. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unexpected Notice message
On 04 Jul 2012 at 16:51, Marc Guay marc.g...@gmail.com wrote: Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in I would guess that it's asking you to add quotes around QUERY_STRING...? As in: if (strlen($_SERVER['QUERY_STRING']) 0) { -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] embedding php inside of php
On 01 Jul 2012 at 01:00, Tim Dunphy bluethu...@gmail.com wrote: I am trying to get the hang of php using some examples that I found in a book. I've been making progress lately, but one thing has me a bit stumped. In an HTML form that I am echoing through PHP I would like to embed smaller chunks of php in the code like so: echo 'br /br / form method=post action=sendemail.php label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text value=?php echo $subject;?br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40?php echo $text;? /textareabr / input type=submit name=Submit value=Submit / /form'; You don't need the nested echoes. Just concatenate instead: echo 'br /br / form method=post action=sendemail.php label for=subjectSubject of email:/labelbr / input id=subject name=subject type=text value=' . $subject . 'br / label for=elvismailBody of email:/labelbr / textarea id=elvismail name=elvismail rows=8 cols=40' . $text . ' /textareabr / input type=submit name=Submit value=Submit / /form'; In short you're doing this : echo 'Some HTML text here ' . $subject . ' some more HTML text ' . $text . ' and finally other stuff here'; -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: show info from mysql db
wow! this fixed it.. $dbc = mysqli_connect('127.0.0.1','admin',secret','trek_db') or die ('Could not connect to database'); used to be... $dbc = mysqli_conect('127.0.0.1','admin','Duk30fZh0u','trek_db') or die ('Could not connect to database'); d'oh!! spelling counts!!! :) On Sun, Jun 10, 2012 at 1:15 AM, Tim Dunphy bluethu...@gmail.com wrote: hello list, I tried designing a very basic couple of web pages tonight that was solely meant to build some php chops. intentionally cheesy. I got half the way there by designing a page that grabs some info from an html form and puts that info into a mysql database. This part works. You can see that page here: html headtitleStarship Crew/title/head body bgcolor=black centerimg src=logo.jpg alt=Star Trek Logo / /center font size=3 color=white style .box{ font-family:Tahoma, Geneva, sans-serif; font-size:16px; text-align: center } /style pEnter your First Name, Last Name, Rank, Division,Ship and Email address./p form method=post action=addcrew.php trtdlabel for=firstnameFirst name:/label input type=text id=firstname name=firstname //td/trbr / trlabel for=lastnameLast name:/label input type=text id=lastname name=lastname //trbr / trlabel for=rankRank:/label input type=text id=rank name=rank /br //tr trlabel for=divisionDivision:/label input type=text id=division name=division /br //tr trlabel for=shipShip:/label input type=text id=ship name=ship /br //tr tr/trlabel for=emailEmail:/label input type=text id=email name=email /br //tr input type=submit name=Submit value=Submit / /form a href='showcrew.php'Show crew manifest/a centerimg src=enterprise.jpg alt=Enterprise / /center /font /body /html This is the one table in the database: mysql describe crew_manifest; ++-+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | ++-+--+-+-+---+ | first_name | varchar(20) | YES | | NULL | | | last_name | varchar(20) | YES | | NULL | | | rank | varchar(10) | YES | | NULL | | | division | varchar(10) | YES | | NULL | | | ship | varchar(20) | YES | | NULL | | | email | varchar(20) | YES | | NULL | | ++-+--+-+-+---+ 6 rows in set (0.06 sec) and this is the corresponding php page that inputs the info: ?php $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $rank = $_POST['rank']; $division = $_POST['division']; $ship = $_POST['ship']; $email = $_POST['email']; $dbc = mysqli_connect('127.0.0.1','admin','secret','trek_db') or die('Error connecting to MySQL database'); $query = INSERT INTO crew_manifest VALUES ('$first_name','$last_name','$rank','$division','$ship','$email'); $result = mysqli_query($dbc,$query) or die('Error querying database'); echo crew member added; mysqli_close($dbc); ? But the page that reads the info is the problem: html head titleShow Crew/title /head body bgcolor=black centerimg src=ncc1701.jpg alt=NCC 1701 / /center font size=3 color=white style .box{ font-family:Tahoma, Geneva, sans-serif; font-size:16px; text-align: center } /style centerCrew Manifest/center ?php $dbc = mysqli_conect('127.0.0.1','admin','secret','trek_db') or die ('Could not connect to database'); $query = SELECT * FROM crew_manifest; $result = mysqli_query($dbc,$query); while ($row = mysqli_fetch_array($result)) { $first_name = $row['first_name']; $last_name = $row['last_name']; $rank = $row['rank']; $division = $row['division']; $ship = $row['ship']; $email = $row['email']; echo $rank . 'br /'; } mysqli_close($dbc); ? /font /html What I'd like to find out is why the while loop does not display info from the database? The page does show up, but not any info from the db. Thanks in advance. tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: show info from mysql db
You had been keeping the password secret, but it looks like you accidentally leaked it, so a replacement might be in order :) oh wow.. gotta hate when you do that!!! on it! Glad you got it fixed. Typos can be little buggers to find sometimes. me too.. fell back to the old 'echo hello' test strategy .. have to try to remember that strategy before i go running for help.. :) tim On Sun, Jun 10, 2012 at 12:15 PM, Adam Richardson simples...@gmail.com wrote: On Sun, Jun 10, 2012 at 8:25 AM, Tim Dunphy bluethu...@gmail.com wrote: $dbc = mysqli_connect('127.0.0.1','admin',secret','trek_db') or die ('Could not connect to database'); used to be... $dbc = mysqli_conect('127.0.0.1','admin','Duk30fZh0u','trek_db') or die ('Could not connect to database'); You had been keeping the password secret, but it looks like you accidentally leaked it, so a replacement might be in order :) Glad you got it fixed. Typos can be little buggers to find sometimes. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hungarian Notation interest with PHP
On 04 Jun 2012 at 15:43, Mihamina Rakotomandimby miham...@rktmb.org wrote: I have a colleague stuck with this thing named Hungarian Notation http://goo.gl/xYv8O We try to define our internal coding standards, which is very close to the Symfony ones http://goo.gl/f2rcO But we're in conflict because the colleague really argue about his Hungarian Notation. This simply adds far too much noise to code. If I need to know what type a variable has, I'll look at its declaration, if any. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Function size
On 03 Jun 2012 at 10:02, Tony Marston tonymars...@hotmail.com wrote: tamouse mailing lists wrote in message news:cahuc_t__sw-_yhrw4n4uqr-fa46+cebunzgehboaatrafla...@mail.gmail.com... There is a point: if you are unfamiliar with code, wading through screens and screens of a function to find things like block beginning/ends makes for difficult time finding places where changes need to be made. I *never* have huge numbers of lines between a block beginning and end. Even if I did my IDE can quickly find the other end of the block for me. E.g. TextWrangler does this easily enough: just double-click immediately after an opening brace, and everything is highlighted to the closing brace. - all those functions should be arranged in alphabetical order within their containing file - having them in a random sequence makes it difficult to find the one you want. Also correct; this is a key point in making sure your scripts are maintainable. Ah-ha! So someone agrees with me on that point after all. +1 - when browsing through the code you have to keep jumping to another function, and then returning to where you came from. I don't know about you, but I would rather use the scroll wheel on my mouse than keep jumping from one position in the file to another. May I suggest an editor/IDE that lets you navigate to functions directly, then? I am *NOT* going to change my IDE just to suit *YOUR* preferences. TW provided a popup list of your functions. It still helps to have them in alpha order though, for ease of navigation in the popup list. [snip arguments] I write functions to do specific things. E.g. I have a function (actually in JavaScript) called switchTab() which switches from one user view to another. It's just over 200 lines long and is mostly a giant case statement - and it's already loaded with function calls. I suppose I could break it up into five separate functions, more or less one for each case value, but then I'd have lots of unimportant local variables to pass around as argument values, and, what's worse, lots of unimportant functions cluttering the place up. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] errors not showing
hello, list! I have 'error_reporting = E_ALL' set in my php.ini file. However when I run a php script that has errors in it all that happens is that the page WSODs. I am running Mac OS X 10.6. Any thoughts on why errors don't show up in the browser and how to correct this? Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] errors not showing
Hello Simon, Thanks for your response. However I still can't seem to get errors to show up. [dunphy@localhost:~/jf-current] #cat /private/etc/php.ini | grep -e error_reporting -e display_errors ; display_errors ; error_reporting error_reporting = E_ALL E_NOTICE ;error_reporting = E_ALL ~E_DEPRECATED display_errors = On ; separately from display_errors. PHP's default behavior is to suppress those ; Eval the expression with current error_reporting(). Set to true if you want ; error_reporting(0) around the eval(). [dunphy@localhost:~/jf-current] #sudo apachectl -t Syntax OK [dunphy@localhost:~/jf-current] #sudo apachectl restart [dunphy@localhost:~/jf-current] #uname -a Darwin localhost 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386 I was wondering if there might be something else I might've missed? Thanks Tim On Sat, May 19, 2012 at 11:57 PM, Simon J Welsh si...@welsh.co.nz wrote: On 20/05/2012, at 3:55 PM, Tim Dunphy wrote: hello, list! I have 'error_reporting = E_ALL' set in my php.ini file. However when I run a php script that has errors in it all that happens is that the page WSODs. I am running Mac OS X 10.6. Any thoughts on why errors don't show up in the browser and how to correct this? Thanks Tim You also need to set display_errors to On. --- Simon Welsh Admin of http://simon.geek.nz/ -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On 27 Apr 2012 at 16:56, Chris Stinemetz chrisstinem...@gmail.com wrote: On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas stu...@3ft9.com wrote: On 26 Apr 2012, at 18:37, Jim Giner wrote: Im no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. A query string has nothing to do with databases. I still haven't been able to find a solution. Is there anyone out there that knows how to keep the query string intact? As was posted previously, you need to encode the query string. If you have: http://westeng/forum/store.php?id=Wiser Communication, LLC - - Sprague Ave that is going to be split in two unless you encode the Wiser Communication, LLC - - Sprague Ave portion. I would do that with JavaScript on the html page. This is not a PHP question. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] learning resources for PHP
I've been having a lot of fun with Beginning PHP 5.3 by Matt Doyle. Covers basics nicely... Nice! I'll give that a try! Thanks for the suggestion! On Wed, Apr 18, 2012 at 6:18 PM, sono...@fannullone.us wrote: On Apr 18, 2012, at 1:30 PM, Henry Martinez wrote: I've been having a lot of fun with Beginning PHP 5.3 by Matt Doyle. Covers basics nicely... Also, the code samples and explanations are top notch, and you come to really understand what it is you're doing.. +1 Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strftime silliness
On 11 Apr 2012 at 01:47, Geoff Shang ge...@quitelikely.com wrote: On Wed, 10 Apr 2012, Tim Streater wrote: I want to format a date/time using a 12 hour representation of the time part. I can do this with, say, %d %b %Y %l:%M %p, where the first time format specifier is the lower-case L. But, this gives me a leading space in the case that the hour is less than 12. I don't want this space. Anyone know of an simple way to avoid it? There appears to be no specifier to do this. Of course, I can call strftime twice, once for the date portion and once for the time portion, trimming the latter, but that seems clumsy. You can use %-l to achieve this. You could also use %-I as this will also drop leading zeros if present. I forget where I read about this. I'm almost certain that it was *not* in any PHP documentation. Ah - thanks. My post wasn't a complete waste of time after all then. I ended up using date(). But is %-l officially supported? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php in windows
On 11 Apr 2012 at 03:13, Kirk Bailey kbai...@howlermonkey.net wrote: It means it does nothing. I have a small server in the computer that works fine. I also installed python in this box- and it worked perfectly without having to do anything to the server. Php on the other hand merely occupies disk space. So you don't want to tell us what does nothing means etc as per my previous post. Fine. Aside:Holy cow, you know nothing about windows?!? Considering that Boll Bates and co. are almost as omnipresent as Satan, and have been accused of BEING Satan, that's quite an accomplishment. I exaggerate for effect. Sometimes I volunteer a small office that, inevitably, uses it. And when my dopey BiL downloaded iTunes and then asked me what to do next, I sent him to the Start menu. But I actively resist knowing more than I absolutely need to. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php in windows
On 10 Apr 2012 at 03:05, Kirk Bailey kbai...@howlermonkey.net wrote: The edition of php for windows I instaklled does not work. Which flavor of windows php DOES work properly in windows? What does does not work mean? You need to say which OS, which PHP version, what happens, and what you expect to happen. Not that I can help, as I know nothing about Windows, but with that info perhaps another can. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strftime silliness
I want to format a date/time using a 12 hour representation of the time part. I can do this with, say, %d %b %Y %l:%M %p, where the first time format specifier is the lower-case L. But, this gives me a leading space in the case that the hour is less than 12. I don't want this space. Anyone know of an simple way to avoid it? There appears to be no specifier to do this. Of course, I can call strftime twice, once for the date portion and once for the time portion, trimming the latter, but that seems clumsy. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strftime silliness
On Apr 10th, 2012 at 10:40pm, Tim Streater t...@clothears.org.uk wrote: I want to format a date/time using a 12 hour representation of the time part. I can do this with, say, %d %b %Y %l:%M %p, where the first time format specifier is the lower-case L. But, this gives me a leading space in the case that the hour is less than 12. I don't want this space. Anyone know of an simple way to avoid it? There appears to be no specifier to do this. Of course, I can call strftime twice, once for the date portion and once for the time portion, trimming the latter, but that seems clumsy. OK belay that, sorry: I'm using the wrong function (shouldn't code this late at night). -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] learning resources for PHP
Hello list, I am quite sure that you've heard this question at least a few times before. :) But I have been dabbling a bit in PHP for years and I've decided that its' high time that became serious about getting a solid grounding in it. Currently I work as a Sysadmin and have modest but reliable skills in bash and perl. But I consider PHP more of an artform and I really need to 'pick up a brush and start painting' so to speak. So what I was wondering what websites, and books you'd recommend to someone who (for all intents and purpose) is just starting out. On my hit list of things to learn are basic php / database interaction (mysql mainly).. then how to accelerate php interraction through memcache.. and eventually one I have all that down onto using some of the NoSQLs (mongo/cassandra/membase, etc). Thanks! -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Websocket using php
On 31 Mar 2012 at 16:14, Leandro Dardini ldard...@gmail.com wrote: Hello, I have the need to use websockets for the server part of an application I am developing and I found with a big surprise no websocket class or procedure is available on the net. Have I missed looking in some place? Being really interested in using this protocol with PHP, I start from the closest working thing: http://code.google.com/p/phpwebsocket/ and start adapting it to the lastest RFC describing the protocol http://tools.ietf.org/html/rfc6455, but it is really heavy to code and I feel like reinventing the wheel. Is there anyone out there who has already written a websocket server in PHP and like to share the code? https://github.com/jam1401/PHP-Websockets-Server -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Got HTML5 History API + caching LICKED, I think, grin
On 18 Mar 2012 at 16:39, Tamara Temple tamouse.li...@tamaratemple.com wrote: On Fri, 16 Mar 2012 19:57:38 +0100, rene7705 rene7...@gmail.com sent: I could waste a lot of text on what I've accomplished during the last months, but the easiest thing is if you have a (another) look at (the source of) http://mediabeez.ws I seem a bit late to this party, but just wanted to say that the artwork is quite impressive, although I doubt I'd have really much use for the code parts. I don't like: a) menus that just spring into life because you happen to mouse near them. You should have to sick to activate a menu. b) bright flashy distracting items on a website. Like the OP's menus. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Got HTML5 History API + caching LICKED, I think, grin
On 18 Mar 2012 at 17:06, Tim Streater t...@clothears.org.uk wrote: I don't like: a) menus that just spring into life because you happen to mouse near them. You should have to sick to activate a menu. Damned autocorrect. s/sick/click/ -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse errors
After recently omitting a semicolon from the end of a statement, and having the result be a JavaScript error in an odd place, I'm trying to pin down just what PHP does with such errors. I made a small test script to run at CLI, which does some echoes and then, after that, I miss out a semicolon. On the command line, all I get is the parse error message with line number. The script where I'd left the semicolon out of my production code is reached via AJAX, and sends some results back. It consists of a number of functions, then the main code appears, starting with two requires. The first such included file has some functions, puts out a header and does an echo, and calls set_error_handler. It's in the second included file that the semicolon is missed off (inside yet another function). I would have expected that the results sent back would just consist of the Parse error: message, but for some reason the echo done in the first included file shows up as well (this is important as it frames the parse error message for me). Is this the expected behaviour? The doc for set_error_handler says you can't use it to recover from E_PARSE and the like, and the function I supply to it doesn't appear to be called. I was just surprised that the initial echo statement's output made it back to the JavaScript side. (I obviously don't expect to have parse errors show up in production, but having them nicely visible and logged during testing is useful) -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse errors
On 18 Mar 2012 at 17:46, Simon J Welsh si...@welsh.co.nz wrote: This is expected. The error doesn't occur to the second file is included, so everything in the first included file is parsed and run before execution is halted. Simon, Thanks for that. Looks like I should be able to catch most places where an error might occur. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
On 13 Mar 2012 at 15:59, Tedd Sperling tedd.sperl...@gmail.com wrote: I'm not sure what would have saved bacon in the above case. I don't see how your example would work. I think it contained a typo. In what I think you were trying to demonstrate, I would just pass $x by reference ($x) -- or -- return $x by value. I would not have used a global, In any event, I seldom use globals anyway. This was more an academic discussion. As was my example - and yes, it had a typo. Worse, trying it in a shell it doesn't exhibit the failure mode I thought I'd had. Never mind. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
On 12 Mar 2012 at 20:07, Tedd Sperling tedd.sperl...@gmail.com wrote: Tim: I read somewhere that using: global $x; is not recommended. Whereas, it is recommended to use: $x = $GLOBALS['x']; echo $x; Tedd, That may well be, although as I write I can't recollect having seen that anywhere; so I don't use that form. However I have been caught by something like the following: ?php function yes ($a) { global $x; if ($a) $x = yes\n; } first (true); echo $x; ? but I haven't looked into $GLOBALS enough to know whether using them instead would have saved my bacon. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
On 11 Mar 2012 at 18:16, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: On Sat, Mar 10, 2012 at 10:37, Tedd Sperling tedd.sperl...@gmail.com wrote: As such, there are no globals in PHP other than SuperGlobals. As I said, if I'm wrong, please show me otherwise. A superglobal is predefined at run-time by the parser, environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, _SESSION, _COOKIE), whereas a global can be defined at any time, and is available to the current instance. All superglobals are globals, but not all globals are superglobals. Now I'm confused. My understanding is that all variables defined within the main script are accessible within the main script because they are all within scope by definition. Additionally, main script variables are not accessible out of scope (such as in a function) unless one uses $GLOBALS to retrieve those values. In the following, $x is a global but not a super-global (AFAIK). ?php function echox () { global $x; echo $x; } $x = Hello world\n; echox (); ? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable number of arguments problem
I have a function defined thus: function my_func ($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) { // code here } I call this with variously the first three arguments only, or all six, taking care that if I call it with fewer arguments then I don't try to acces $arg4, $arg5, or $arg6 (which is passed by reference, as is $arg1). On my first attempt to execute this, I'm getting: Missing argument 4 for my_func(), called in /path/to/source/file1.php at line 556 and defined in /path/to/source/file2.php at line 3 Is this because $arg6 is passed by reference? There is some reference to this in the docs and the user notes but it's a little unclear. Or is there another reason? Thanks, -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Variable number of arguments problem
On 12 Feb 2012 at 19:01, Stuart Dallas stu...@3ft9.com wrote: Optional arguments must be given a default value... function my_func($arg1, $arg2, $arg3, $arg4 = null, $arg5 = null, $arg6 = null) Note that passing a default value by reference was not supported prior to PHP5. All the relevant details are here: http://php.net/functions.arguments Thanks, I do see an example now, although it's not stated explicitly. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: Re: [PHP] What's Your Favorite Design Pattern?
On 07 Feb 2012 at 22:31, Paul M Foster pa...@quillandmouse.com wrote: Design Patterns are Way Nifty Kewl patterns of code which are supposed to facilitate certain types of operations. (Was that sarcasm you detected? Yes it was.) For example, the Singleton pattern. Let's say you had a configuration class that held the configuration values for your application, and you wanted to make sure there was only one object of that class instantiated, no matter how many times it was called in your code. You'd arrange the code and call the class in a certain way to ensure that only one object of that class resulted. To make your configuration class a singleton, you'd probably make the class have a *private* constructor (so no outside routine could call it), and then provide a method called get_instance() which tested for the existence of an object of that class. If such an instance was found, someone calling configuration::get_instance() would simply get the existing object returned to them. Otherwise, configuration::get_instance() would instantiate the class and then return the new object to the caller. As you can see, that's a peculiar way of setting up your code for a specific purpose. Other design patterns do other things and dictate setting up things in other ways. The definitive work on this (and where it first gained the most publicity) is a book called Design Patterns by four authors (Gamma, Helm, Johnson and Vlissides). It essentially contains a chapter about each (known at the time) design pattern and some pseudocode about how it might be constructed. I imagine the authors looked at a lot of code and discovered that programmers were coming up with code that, in each case was remarkably similar for solving certain types of programming problems. So they codified what that found and wrote a book about it. I have the book on my shelf, and it's decent technology, but you could spend your whole career and never use any of it, and get along just fine. Mmmm. Well, at this point I feel underwhelmed - but its entirely possible that I'm missing something profound [1]. After looking at some of the reviews of the book you mention on Amazon, I might be inclined to get a simpler intro. [1] In June 1982 (or was it '83?) I visited PARC with a small group from SLAC. We saw the Star or whatever it was, with bit-mapped display and mouse pointer. Whoosh !! (Well, to be fair, we'd gone along to look into XNS). -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] What's Your Favorite Design Pattern?
On 07 Feb 2012 at 19:34, Daniel Brown danbr...@php.net wrote: On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh mike.mackint...@angrystatic.com wrote: I was curious to see what everyones favorite design patterns were, if you use any, and why/when have you used it? Choices include slots and signals (observer), singleton, mvc, hmvc, factory, commander etc.. Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit), as that's what I encounter no less than 80% of the time in the wild. Since I have no idea what anyone is talking about, I can only conclude that you're playing Mornington Crescent (q.v.), on a non-standard board. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Long Live GOTO
On 06 Feb 2012 at 07:47, Adam Richardson simples...@gmail.com wrote: While not purely focused on PHP, I toss this out to the group because I believe there are some novel, interesting points regarding the potential benefits of using the goto construct as implemented in PHP: http://adamjonrichardson.com/2012/02/06/long-live-the-goto-statement/ Your val_nested() function looks like a straw-man to me. I've not used a goto since I stopped writing in FORTRAN in 1978, and not missed it [1]. Neither do I ever have deeply nested if-then-else - these are a good source of bugs. I suppose the rest of your article might have been dealing with simplifying val_nested() but TBH I wasn't interested enough to find out. [1] Not quite true - a Pascal compiler I once had to use in 1983 lacked a return statement, so I had to fake it by putting a 999: label at the end of the function and goto-ing to that. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Long Live GOTO
On 06 Feb 2012 at 15:05, Robert Cummings rob...@interjinn.com wrote: I've had a strong opinion on goto for a very long time. I was one of the proponents who argued on internals for its inclusion several years ago. I stand by its utility and refer the reader to the fact that many open source projects, especially ones that use some kind of parser, have goto hidden within their implementation. You can find it in the C code for the PHP, MySQL, and Apache to name a few easily recognizable projects. All of which is no doubt true but that doesn't mean I have to like it, although obviously I'll have to put up with it. Anyway, discussions of this sort tend to be, or become, futile. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Long Live GOTO
On 06 Feb 2012 at 09:48, Adam Richardson simples...@gmail.com wrote: On Mon, Feb 6, 2012 at 4:25 AM, Adam Richardson simples...@gmail.comwrote: On Mon, Feb 6, 2012 at 4:07 AM, Tim Streater t...@clothears.org.uk wrote: I disagree that the nested function is a straw-man. I (just as the other authors I'd linked to describing the arrow pattern of code) have seen plenty of examples of similar code. I guess what I meant was, that I'd never have written it that way in the first place, so as an example it felt contrived. Amateurs or people with no training (in particular physicists at CERN 40 years ago) should be kept well clear of the goto. I'd probably write your function like this: function val_nested ($name = null, $value = null, $is_mutable = false) { static $values = array(); static $mutables = array(); if ($name===null) return $values; if ($value===null) return isset($values[$name]) ? $values[$name] : null; if (isset($values[$name])) { if (!$val_is_mutable = in_array($name, $mutables))// Set existing value { $msg = 'The value ' . $name . ' is immutable and has already been set to ' . $values[$name] . '.'; throw new Exception ($msg); } return $values[$name] = $value; } if ($is_mutable) $mutables[] = $name; // Set new value $values[$name] = $value; return $value; } I always add blank lines for clarity. Remove those and the above is 30% shorter than yours - as far as I could tell, none of the else clauses was required. My approach is: 1) deal with the trivial and error cases first 2) deal with the real work next -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Long Live GOTO
On 06 Feb 2012 at 20:51, Simon J Welsh si...@welsh.co.nz wrote: On 7/02/2012, at 9:44 AM, Marco Behnke wrote: Am 06.02.12 17:23, schrieb Alain Williams: However: a few GOTOs can make things clearer. Think of a function that can fail in several different places (eg data validation, ...). But it is reading a file which needs to be closed before the function returns. I have seen code where some $IsError variable is tested in many places to see if things should be done. That is just as bad as lots of GOTO -- often when having to write something like that I will have a GOTO (in Good code uses Exceptions and try catch for that kind of scenarios. Exceptions have a lot of overhead and should only be used in exceptional circumstances. I don't see how data validation failing is an exceptional circumstance. I find that using Exceptions and try/catch for something this trivial to be more confusing and harder to read (thus worse code) than a goto. It is also much easier to make a mistake, especially if you're expecting the catching to happen outside of the validation function. While it is true that try/catch adds another level just like an extra if-then-else, there are times when it's unavoidable. During initialisation of my app, I have to check which of the files in a directory may be SQLite databases that belong to the app. So I have to check: a) whether this file is an SQLite database b) whether it has the two tables I expect to find there Last time I checked the SQLite API in question, it looked as though try/catch was my only option. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looking for the string functions
I'm keen to look at the C source of such as substr_replace() and stripos(). I've downloaded the 5.3.9 PHP source, but am having difficulty locating the string functions. Could someone point me at the right directory or .c file? Thanks, -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Measuring CPU time
I haven't found a function to allow me to see elapsed CPU time to date in a function. Am I right in thinking none such exists? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: RE: [PHP] passing variables to php script
On 13 Jan 2012 at 15:05, David Savage dsav...@cytelcom.com wrote: I open the html file up from a windows explorer window (Q:\asterisk\), and so IE opens it up, but the problem lies in the fact that I cannot find apache service running in the background...haven't figured out why yet. The test configuration start menu option (under configure apache server) just displays a console window for a brief moment, then immediately disappears. The icon I see near my time says Running none of 1 Apache servicesSo I have to get that straightened out first...I believe that's been my problem all along. Well, that's going to be part of it, but it's never going to work if you open it via Explorer. If you do that, apache won't be involved whether it's running or not. This will only work if you have IE (or other browser) open and put http://localhost/your-webpage.html into the browser's address bar. Further, both the webpage and PHP file need to be in your document-root. Look in your apache config file for that). -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: [PHP] passing variables to php script
On 12 Jan 2012 at 18:51, David Savage dsav...@cytelcom.com wrote: Installed apache onto a win2K server, and have the html file php file in the same folder (Q:\ASTERISK\) on the Q: drive (which is just another drive in this same server). I opened the html file using IE 6.0. What I'm thinking is there may be an issue with some setting on the web server. The php statements I posted were the first few statements in the script, so apparently the script didn't see the variables, so I'll have to review the httpd.conf and php.ini files to find whatever settings is preventing the acctnum, year, and month from being passed to the php script. You say: I opened the html file using IE 6.0 I don't like the sound of that. Do you mean you double-clicked the file and it opened in IE or do you mean you put Q:\... into the IE address bar or what? What you should be doing is putting http://localhost/your-file.html in the IE address bar. What is your document-root? Is the Q:\thingy part of it? -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange foreach reference issue
On 1/9/2012 10:35 AM, David Harkness wrote: On Sat, Jan 7, 2012 at 5:01 PM, Tim Behrendsen t...@behrendsen.com mailto:t...@behrendsen.com wrote: The first loop is leaving a reference to the final element. But then the second foreach is doing a straight assignment to the $row variable, but $row is a reference to the final element. So the foreach is assigning its iterated value to the final element of the array, instead of a normal variable. Exactly, and the fact that it shows 1, 2, 2 in the second loop adds more confusion, but it makes sense. In the second loop, it assigns the indexed row value into the third row and displays it. Thus it displays row 1, row 2, and then ... row 3, but row 3 is the one that keeps getting overwritten. And in the third iteration, it overwrites the third row with the third row which currently holds what was in row 2. The moral is always unset the iterator variable when doing foreach with a reference, like the manual says. :) While you can certainly follow the above advice, in my view it's dangerous to have these two loops a) reuse the same variable name for a different purpose and b) exist in the same scope. More and more I find myself dropping the subtle tricks I've learned over the years in favor of writing code that is as easy to understand as possible. Code gets read and modified a lot more than it gets written, and all those tricks just trip up more junior teammates--and often even myself. :) David Agreed, in fact, I decided to create a new style naming convention where _ref is always suffixed to variable names that are references, along with doing the unset, just in case. This goes to show that references can be a recipe for subtle bugs to creep in, so best to isolate them as much as possible to their own convention. If the convention is followed, it should eliminate the possibility of this bug, even if the unset is left out. Tim
[PHP] Strange foreach reference issue
Hello, This sure looks like a bug, but maybe there's some subtlety going on that I don't understand, so I would appreciate some insight. After much debugging, I tracked down a bug in my code to this test program. My PHP version is 5.3.3, running under Fedora Linux. ?php $row_list = array( array( 'Title' = 'Title #1', ), array( 'Title' = 'Title #2', ), array( 'Title' = 'Title #3', ) ); printRows at start: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title A $idx: {$row['Title']}\n; } printRows are now: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title B $idx: {$row['Title']}\n; } ? When you run the program, it gives the following output: -- Rows at start: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title A 0: Title #1 Title A 1: Title #2 Title A 2: Title #3 Rows are now: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title B 0: Title #1 Title B 1: Title #2 Title B 2: Title #2 -- Note that the second foreach repeats the second row, even though the index is correct and the print_r shows things as correct. Now, if you change the name of the reference variable from '$row' to '$rowx' (for example), things will work. So clearly there's some issue with $row being previously used as a reference that's contaminating the subsequent use of $row in the foreach. If there's some logic to this, it's escaping me. Any insight on this would be appreciated. Regards, Tim Behrendsen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange foreach reference issue
On 1/7/2012 4:18 PM, Matijn Woudt wrote: On Sun, Jan 8, 2012 at 12:29 AM, Tim Behrendsent...@behrendsen.com wrote: Hello, This sure looks like a bug, but maybe there's some subtlety going on that I don't understand, so I would appreciate some insight. After much debugging, I tracked down a bug in my code to this test program. My PHP version is 5.3.3, running under Fedora Linux. ?php $row_list = array( array( 'Title' = 'Title #1', ), array( 'Title' = 'Title #2', ), array( 'Title' = 'Title #3', ) ); printRows at start: . print_r($row_list, true); foreach ($row_list as $idx = $row) { Why is there an '' before $row here? That seems like the problem to me.. Matijn When you use an ampersand on the variable, that creates a reference to the array elements, allowing you to potentially change the array elements themselves (which I'm not doing here). http://www.php.net/manual/en/control-structures.foreach.php I do notice in the manual that it says, Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). But that doesn't really explain why it contaminates the next foreach loop in such an odd way. You would think that the $row in the second loop would be assigned a non-reference value. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange foreach reference issue
On 1/7/2012 4:44 PM, Stephen wrote: On 12-01-07 07:30 PM, Tim Behrendsen wrote: When you use an ampersand on the variable, that creates a reference to the array elements, allowing you to potentially change the array elements themselves (which I'm not doing here). http://www.php.net/manual/en/control-structures.foreach.php I do notice in the manual that it says, Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). But that doesn't really explain why it contaminates the next foreach loop in such an odd way. You would think that the $row in the second loop would be assigned a non-reference value. Tim Tim, You are using the $variable in an unintended (by PHP designers), and I suggest undefined manner. So the outcome cannot, but definition be explained. Was this intended, and what were you trying to accomplish? Stephen In the real code, I just happen to use the same variable name first as a reference, and then as a normal non-reference, and was getting the mysterious duplicate rows. I think I'm using everything in a completely reasonable way; the second foreach is reassigning the loop variable. Nothing that comes before using that variable ought to cause undefined behavior. The warning in the manual is about using the loop variable as a reference after exiting the loop, but I'm not doing that. I'm reassigning it, exactly as if I just decided to do a straight assignment of $row Ah ha, wait a minute, that's the key. OK, this is making more sense. The first loop is leaving a reference to the final element. But then the second foreach is doing a straight assignment to the $row variable, but $row is a reference to the final element. So the foreach is assigning its iterated value to the final element of the array, instead of a normal variable. OK, I understand the logic now. The world now makes sense. The moral is always unset the iterator variable when doing foreach with a reference, like the manual says. :) Thanks for everyone's help. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to mac and trying to define a php.ini file.
On 04 Jan 2012 at 14:09, Richard Quadling rquadl...@gmail.com wrote: Where do I put my php.ini file for a MacBook Air? I've only had it 2 days and having trouble with the date.timezone setting. Hmmm, looks like I haven't got one on my Mini. Which doesn't appear to matter as a number of PHP scripts will have been run here in order for you to see this mail. What I do seem to have is /etc/php.ini.default which I suppose you could rename to php.ini if you really wanted to modify it. I'm however carefully ensuring that the client and server aspects of my app (which will both run on the user's machine) don't use anything except what comes with the standard OS X distribution, so to fix the date time issue I do: date_default_timezone_set (@date_default_timezone_get ()); systematically in my scripts. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] New to mac and trying to define a php.ini file.
On 04 Jan 2012 at 21:01, Robert Williams rewilli...@thesba.com wrote: On 1/4/12 13:33, Tim Streater t...@clothears.org.uk wrote: Also, if I remember right, Apple sets up Apache so that each user has his/her own config file inside the conf folder. You should make any config changes, such as turning on PHP, in there, rather than in the primary config file. The latter is subject to being overwritten on OS updates and upgrades, while the former is not. Segregating your changes also makes it easier to tell exactly what you've changed from the defaults. This is true. I'm however carefully ensuring that the client and server aspects of my app (which will both run on the user's machine) don't use anything except what comes with the standard OS X distribution, so to fix the date time issue I do: date_default_timezone_set (@date_default_timezone_get ()); I recommend against this. First of all, in PHP 5.4, this is just going to return UTC if you haven't explicitly set the time zone, and that's probably not what you want. Plus, the use of @ here leaves a nasty taste in the mouth (as it does in most cases). Instead, I suggest creating a php.ini file and changing this setting there by setting it to a specific time zone. For example, in mine, I have this line: date.timezone = 'America/Phoenix' As I hinted in my previous mail, client and server side of my app are always on the user's machine. When the user starts the app, I create an apache config file on the fly and run an instance of apache just for the user. So I'm not messing with the standard OS X Web Sharing. For the same reason, I don't want to start modifying or creating a php.ini file. This ensures that PHP is always using the same zone no matter what script is running, avoids PHP errors if you forget to make the change in a script, avoids you having to modify all your scripts in the first place, and lets you easily change the time zone used by your applications to whatever you want independently of the server's own time zone (or in 5.4, to something other than UTC). Hmm, just looked more carefully at the docs. I see I'm going to have to add a prefs setting so the user can tell my app what timezone they are in. I find it odd that the OS can't provide this information. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] New to mac and trying to define a php.ini file.
On 04 Jan 2012 at 21:59, Robert Williams rewilli...@thesba.com wrote: On 1/4/12 14:34, Tim Streater t...@clothears.org.uk wrote: As I hinted in my previous mail, client and server side of my app are always on the user's machine. When the user starts the app, I create an apache config file on the fly and run an instance of apache just for the user. So I'm not messing with the standard OS X Web Sharing. For the same reason, I don't want to start modifying or creating a php.ini file. In that case, you might consider setting it via the Apache config file that you're creating, which you can do with something like: php_value date.timezone 'America/Phoenix' OK. That'll have the same effect (and benefits) as setting it via php.ini. Hmm, just looked more carefully at the docs. I see I'm going to have to add a prefs setting so the user can tell my app what timezone they are in. I find it odd that the OS can't provide this information. Well, it typically can, or at least can make a guess at it. The problem is that it's not something you can rely on across different OSes, as some handle it differently, or less reliably, or not at all. Basically, the result is non-deterministic. It's for this reason that, as of 5.4, PHP won't even ask the OS but will always return UTC (and complain a bit) if something else hasn't been set. This way, you at least have a chance of consistent results. If you're only supporting OS X, you can have your script that generates the Apache config file retrieve the system time zone, and then use that value in the php_value setting. If the script is in PHP, you can do this: $timeZone = `/usr/sbin/systemsetup -gettimezone`; Which just calls the systemsetup command line utility (basically, a CLI front-end to the settings controlled via System Preferences). Here's what that call returns when run on the command line on my system: H012316WHPV:~ rewilliams$ systemsetup -gettimezone Time Zone: America/Phoenix That is a very helpful hint - thanks. Yes, it's OS X only at the moment as I don't have access to or a great interest in the other platforms. Not sure if this has greatly help the OP though :-) -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class instance pointers
Is there any benefit to setting a pointer to a class instance to null before returning from a function? As in: function myfunc () { $p = new myclass (); // do stuff $p = null; } Thanks. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Class instance pointers
On 29 Nov 2011 at 17:01, cimodev cimo...@googlemail.com wrote: Am 29.11.2011 16:56, schrieb Tim Streater: Is there any benefit to setting a pointer to a class instance to null before returning from a function? As in: function myfunc () { $p = new myclass (); // do stuff $p = null; } No! In this case the GC will do that for you :) Thanks, I expected that to be the case, but it's not been crucial up to now. Rather than having a script that runs for a while and quits, I'm hoping to run a small server written in PHP and wanted to be 100% sure that I didn't need to. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On 20 Nov 2011 at 23:46, Tamara Temple tamouse.li...@tamaratemple.com wrote: Tim Streater t...@clothears.org.uk wrote: At the moment I'm using an instance of apache to run PHP scripts, as and when required via AJAX. Having got some understanding of web sockets, I'm minded to look at having a small server to execute these functions as required. The scripts, some 50 or so, are only about 300kbytes of source code, which seems small enough that it could all be loaded with include, as in: ?php $fn = 'wiggy.php'; include $fn; ? This appears to work although I couldn't see it documented. I'm really not sure what you're looking for here -- that is pretty standard php practice to load php files with include -- what were you expecting here? I'm looking for confirmation that: include $fn; is an allowed form of the include statement. While it's certainly possible to rig up something using sockets, I don't think that's how AJAX works, and you'd need a JS library that did. Hmmm, I think perhaps I've not made myself clear - sorry about that. At present I'm using AJAX and apache; I'd like to *stop* doing that (and not use another web server, either). In my case, client and server are the same machine - the user's machine. There is a browser window and JavaScript within it which makes the AJAX requests. I just happen to use apache to have a variety of PHP scripts run to provide results back to the browser window. Generally, you should only really need to dynamically replace parts of a long-running program if you don't want to restart it. However, php scripts are not long-running programs in general, unlike the apache server itself, for example, and certainly if the php scripts are running under apache, they will be time- and space-limited by whatever is set in the php.ini file. If these little scripts are merely responding to AJAX requests, they should be really short-lived. At present these scripts generally are short-lived, but with some notable exceptions. Hence my exploration of whether I could use websockets instead. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include
On 21 Nov 2011 at 11:10, Tommy Pham tommy...@gmail.com wrote: On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater t...@clothears.org.uk wrote: I'm looking for confirmation that: include $fn; is an allowed form of the include statement. RTFM [1] example #6 ;) [1] http://php.net/function.include Thanks - I missed that one. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] include
On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com wrote: I think you're approaching this the wrong way. 1) have a clear understanding of PHP - syntax, capabilities, etc. That's what I'm doing - gathering information about bits of PHP that I've not used (or not used very much) before to see how my new setup could be structured. 2) have a clear understand of what you're intending to do - application's function/purpose, features, manageability, expandability, portability, etc... I have a clear idea about *that*. I want to figure out if it's possible to use web sockets with a small server written in PHP to replace my current structure of ajax + apache + processes (which I suppose it forks). I see these benefits: 1) possible benefit - presumably when an ajax request arrives, a new process is started and so PHP has to be loaded and initialised each time. But perhaps this is in some way optimised so the PHP process is left running and apache then just tells it to read/execute a new script. 2) Definite benefit - when a browser makes an ajax request to run a script, it gets no information back until the script completes. Then it gets all of it. I have a couple of unsatisfactory workarounds for that in my existing structure. Websockets appears to offer a way for the browser to receive timely information. 3) understand design patterns I don't know what this means. What your asking is practically impossible in any programming language akin to 'how to un-import packages in Java' or 'how to un-using namespace in C#'. If you don't want to use it, don't include it ;) I do want to use it but would like to be able to replace it with a newer version. If there is no way to do this then that is a data point. And here's another question. Can a child forked by pcntl_fork() use a socket that the parent obtained? Reading the socket stuff in the PHP doc, there are a number of user-supplied notes hinting this might be problematic. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php