php-general Digest 29 Sep 2013 16:30:23 -0000 Issue 8382
php-general Digest 29 Sep 2013 16:30:23 - Issue 8382 Topics (messages 322207 through 322218): Re: Switch Statement 322207 by: Aziz Saleh 322209 by: Jim Giner 322210 by: Jim Giner 322212 by: Ethan Rosenberg 322213 by: Ethan Rosenberg 322214 by: Jim Giner 322215 by: Jim Giner 322217 by: Aziz Saleh Re: create a local temp table in local machine 322208 by: Bastien 322211 by: iccsi Running a command without shell 322216 by: vitalif.yourcmc.ru delete S3 bucket with AWS PHP SDK 322218 by: Tim Dunphy Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz On Sat, Sep 28, 2013 at 10:33 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_**errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$**password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_**seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST); //post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On 9/28/2013 10:33 PM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch (
[PHP] Running a command without shell
Hi! Is it possible to run a command and capture its output via an FD (like in proc_open()), but without using the shell? As far as I can see now there is no way to do it. I think that's a simple feature, maybe just add it to proc_open()? (for example run command directly using exec() if the first argument is an array?) it would be rational because there is already such option for Windows... -- With best regards, Vitaliy Filippov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch Statement
What is the output? On Sun, Sep 29, 2013 at 1:34 AM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: On 09/28/2013 10:53 PM, Aziz Saleh wrote: Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz snip Aziz - Used var_dump no further information Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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
On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy 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 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 Your code is failing because $bucket_name, I suspect, is null. Where do you define this variable before you use it in this bit of code: $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Switch Statement
Hello, I suggest you put default in that switch statement and var_dump the $_POST.That should be enough for a programmer to pin point what goes wrong. P:S **You might want to consider versioning your codes to go back into its history to see what has changed. Muhsin On 09/29/2013 04:33 AM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST);//post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- Extra details: OSS:Gentoo Linux profile:x86 Hardware:msi geforce 8600GT asus p5k-se location:/home/muhsin language(s):C/C++,PHP Typo:40WPM url:http://www.mzalendo.net url:http://www.zanbytes.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
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)) { // @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
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): 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.comwrote: 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):
Re: [PHP] Re: Sending PHP mail with Authentication
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote: [snip] I'm sure I'm going to annoy people with this, but I would advise to never use PEAR. It's the biggest load of extremely badly coded PHP you'll ever find. Creating an SMTP client (with the purpose of just sending mail) is very easy to do yourself (and also a good challenge if you're not yet very skilled with PHP). Alternatively, you can indeed use a package such as PHPMailer; it's not perfect, and quite bloated for what you want probably, but it works rather well. I have to agree on the code bloat. Unless your requirements are extraordinary (which the OP's are), the native PHP mail() function is generally quite adequate. Never thought about creating a PHP email client. Interesting idea... Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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