php-general Digest 30 Sep 2013 18:03:46 -0000 Issue 8383
Topics (messages 322219 through 322226):
Re: delete S3 bucket with AWS PHP SDK
322219 by: Ashley Sheridan
322221 by: Aziz Saleh
322222 by: Tim Dunphy
322223 by: Aziz Saleh
322225 by: Tim Dunphy
Re: Switch Statement
322220 by: mrfroasty
Re: Sending PHP mail with Authentication
322224 by: Paul M Foster
Re: Is correct to override XML standards?
322226 by: buzon.alejandro.ceballos.info
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
----------------------------------------------------------------------
--- Begin Message ---
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
> 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
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
--- End Message ---
--- Begin Message ---
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
>
--- End Message ---
--- Begin Message ---
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 '<center>Deleted Bucket';
echo '<br /><br />';
echo '<a href=listbuckets.php>List Buckets</a></center>';
} else {
echo (string) $response->body->Message;
}
//echo '<br /><br />';
}
?>
<body>
<center><h3>Delete S3 Bucket</h3>
<form name="delete_bucket" method="post" action="delete_bucket.php">
<label for="bucket_name">Bucket Name:</label><br />
* <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))
>> {
>> // @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
>>
>
>
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
--- End Message ---
--- Begin Message ---
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 '<center>Deleted Bucket';
> echo '<br /><br />';
> echo '<a href=listbuckets.php>List Buckets</a></center>';
> } else {
> echo (string) $response->body->Message;
> }
> //echo '<br /><br />';
> }
> ?>
> <body>
> <center><h3>Delete S3 Bucket</h3>
> <form name="delete_bucket" method="post" action="delete_bucket.php">
> <label for="bucket_name">Bucket Name:</label><br />
> * <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))
>>> {
>>> // @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
>>>
>>
>>
>
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>
>
--- End Message ---
--- Begin Message ---
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 '<center>Deleted Bucket';
echo '<br /><br />';
echo '<a href=listbuckets.php>List Buckets</a></center>';
} else {
echo (string) $response->body->Message;
}
//echo '<br /><br />';
}
?>
<body>
<center><h3>Delete S3 Bucket</h3>
<form name="delete_bucket" method="post" action="delete_bucket.php">
<label for="bucket_name">Bucket Name:</label><br />
* <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 '<center>Deleted Bucket';
>> echo '<br /><br />';
>> echo '<a href=listbuckets.php>List Buckets</a></center>';
>> } else {
>> echo (string) $response->body->Message;
>> }
>> //echo '<br /><br />';
>> }
>> ?>
>> <body>
>> <center><h3>Delete S3 Bucket</h3>
>> <form name="delete_bucket" method="post" action="delete_bucket.php">
>> <label for="bucket_name">Bucket Name:</label><br />
>> * <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))
>>>> {
>>>> // @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
>>>>
>>>
>>>
>>
>>
>> --
>> GPG me!!
>>
>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>>
>>
>
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
I am working with some WSDL call for a provider.
The strange thing is that the SOAP used (for me, as client) should
include an 'xml' element, and it is supported by the Php constructor,
even that is not correct under XML syntaxis.
Why? Is somekind of not validation?
This works:
<?php
$client = new SoapClient($url_wsdl);
$params = array( "xml" => $xml_content, "login" => $login );
$response = $client->__soapCall("wsdl_method", array($params));
?>
But W3 standards:
All SOAP messages are encoded using XML (see [W3C Recommendation "The
XML Specification"] for more information on XML).
Source: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383492
(Relation with SOAP)
Names beginning with the string "xml", or with any string which would
match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for
standardization in this or future versions of this specification.
Source: http://www.w3.org/TR/REC-xml/#sec-common-syn (Common Syntactic
Constructs)
--- End Message ---