Re: [PHP] file_put_contents problem

2009-09-14 Thread J DeBord
On Mon, Sep 14, 2009 at 4:19 PM, Andres Gonzalez and...@packetstorm.comwrote:

 I have read in the contents of a file using file_get_contents. I can verify
 that the data has actually been read in by echoing its contents.

 But then if I do this:

 $ret = file_put_contents(/tmp/bla, $bk);

 The return value gives the correct size of string $bk, and the file
 /tmp/bla
 is created in /tmp, but the length is 0.

 Why are not the contents written to the file?


Hmmm. Hard to say.

This works for me:

$contents = 'Testing contents';
var_dump(file_put_contents(APPLICATION_PATH . '/../data/test.txt',
$contents));

Outputs: Int 16 and creates the file test.txt, and writes 'Testing contents'
to the file.



 -Andres

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger

2009-09-13 Thread J DeBord
On Mon, Sep 14, 2009 at 2:05 AM, tedd tedd.sperl...@gmail.com wrote:

 At 10:49 PM +0200 9/13/09, Andrea Giammarchi wrote:

 I was expecting somebody that develop massive Ajax application, not a link
 with 3 pages and zero point about the reply.


 You asked if anyone did any ajax? So, I replied and provided you with an
 example.

 Who cares if my example only has three pages? It could be hundreds -- the
 technique scales.

 In all fairness Tedd, your example is a bit of a joke. Send some JSON back
and forth, do some database queries, and use a webservice all at the same
time. Your AJAX calls won't be so simple then.

I think the point of Andrea's project is to make debugging easier. Just like
firebug and Charles do in their own respect. Is it something you can do
without? Yes, especially if you have  a great development environment set
up. Is is something that could make inspecting what is getting thrown around
in your AJAX calls and the PHP errors that occur easier? Yes, especially
when sending JSON or remote object calls.

Charles is a great tool when doing Flash and Flex remoting, and AJAX. I have
the impression that Andrea's tool is perhaps doing something similar, but
taking it a step further. Maybe not everyone's cup of tea, but I think it is
difficult to write off as useless.

In any event, I provided you an example that does not need your debugger --
 it works and works good.

 But then you get all testy because I did not read your documentation. I
 never said I did AND there was never any requirement for me to do so before
 posting. I was simply replying to your question.

 But instead of establishing a constructive line of communication, you start
 off my criticizing me because I didn't read your documentation.

 You ask not to be treated as a noob, but you come in here telling others
 where to get off and bragging about your credentials (as if the rest of us
 can't do better) -- I'm not sure who you think you are, but you sure act
 like an noob.

 If nothing else, you have a lot to learn about making a point.


 tedd


 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com



Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger

2009-09-12 Thread J DeBord
On Sat, Sep 12, 2009 at 8:47 PM, Jim Lucas li...@cmsws.com wrote:

 Andrea Giammarchi wrote:

 something I cannot find in any other library or framework.


 This should tell you something then...

 If something like Formandehyde isn't useful, then why is Charles so popular
(note: popular from my perspective. I wouldn't dare think that it is popular
with anyone on this list unless they expressly told me so)
http://www.charlesproxy.com/ . I can't say anything about the responses
Andrea has gotten without sounding rude and likely starting an internet
fight, so I won't say anything. Except for this. Tedd, the ajax example you
linked to does not need any debugging, that is for sure.


 --
 Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

 Twelfth Night, Act II, Scene V
by William Shakespeare


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] htaccess question

2009-09-11 Thread J DeBord
On Fri, Sep 11, 2009 at 4:46 PM, tedd t...@sperling.com wrote:

 Hi gang:

 Is there a way I can use a htaccess directive to require a php script to be
 included within each file contained within that directory?

 For example, let's say I have a directory with 100 scripts in it, but I
 want each script within that directory to pass through an authorization
 script before executing.

 The hard way is for me to go through each of the 100 scripts and add the
 statement require(auth.php), but I don't want to do that (I'm too lazy and
 beside there is too great of a chance of an error). So, is there a way for
 me to circumvent this problem by using a htaccess directive?

 Now, I know that I can use htaccess to require basic authorization, like
 so:

 AuthType Basic
 AuthName admin
 AuthUserFile /home/httpd/vhosts/mydomain.com/.htpass
 require valid-user

 But I don't want a file containing user ids and encrypted passwords in the
 file system. Instead, I want to move the user ids and passwords into the
 database and out of the file system. I can do this with an authorization
 script, but I don't want to alter 100 scripts to do it.

 Here is a link to the manual.

http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file

*PHP_INI_PERDIR* Entry can be set in php.ini, .htaccess or httpd.conf

Opinions and suggestions welcomed.

 Thanks,

 tedd
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP6 Stable Release Schedule

2009-09-05 Thread J DeBord
On Sat, Sep 5, 2009 at 6:19 PM, Richard Heyes rich...@php.net wrote:

 Hi,

  E_STRICT is now part of E_ALL


*In PHP 6
*

 Oopsy. Shows how much PHP I do these days...

 --
 Richard Heyes
 HTML5 graphing: RGraph - www.rgraph.net (updated 5th September)
 Lots of PHP and Javascript code - http://www.phpguru.org
 50% reseller discount on licensing now available - ideal for web designers

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Some help with SimpleXML :`(

2009-09-04 Thread J DeBord
On Fri, Sep 4, 2009 at 10:23 AM, Matthew Croud m...@obviousdigital.comwrote:


 Well, you guys are awesome.

 So the script below doesn't cause any errors (nice), however it doesn't
 save the newly added child to the xml file (items.xml):



 $xml = simplexml_load_file(items.xml);

 $item = $xml-addChild('item');
 $item-addChild('name', $name);
 $item-addChild('desc', $desc);
 $item-addChild('size', $size);
 $item-addChild('price', $price);



 I thought it would ?  would i need to write using fwrite ?


You'll need to save your xml to the file once you are done manipulating it.
Use $xml-asXML('filename'); Check here:
http://www.php.net/manual/en/simplexmlelement.asXML.php

J


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Date Comparison

2009-09-03 Thread J DeBord
Telling someone RTFM is just rude and mean. Manipulating dates and times can
be confusing for beginners and experienced people alike. I would suggest
that when a question asked here causes you to respond with RTFM, don't
respond at all. Save yourself the time and trouble and save the person
asking the question the grief of being insulted. And Tedd your condescending
response caused me to lose respect for you. I'm sure the OP would have been
more than thankful to receive the same response without the RTFM. I'll read
any response to this, but I won't have anything more to say. This list has
been polluted enough lately with nonsense. Incredible.


On Sat, Aug 29, 2009 at 3:44 PM, tedd tedd.sperl...@gmail.com wrote:

 At 1:01 PM -0400 8/28/09, David Stoltz wrote:

 Hey Stuart -

 RTFM yourselfI did read it, and obviously misunderstood...

 I'm really sorry to bother you. I thought that was what a listserv like
 this was for - to ask questions...

 I'll try not to ask questions I should know the answer to next time.


 Whoa dude!

 You just received advice from a brilliant man and you are bitching about
 it?!?

 Look child, you are being told what you should do by a professional who is
 donating his time freely to help you. Just how did you not understand that?

 So, just do what he advised and say Thank you sir, may I have another?

 I've posted some dumb-ass questions before, but only after I took the time
 to research the question myself. And when someone took the time to
 straighten me out and help, I appreciated it.

 Hopefully next time you'll read the manual and take the time to understand
 what you read -- it would cut down on post that demonstrate just how
 ignorant and thankless you are at this.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Some help with SimpleXML :`(

2009-09-03 Thread J DeBord
You almost had it...

Since clothes is the root element you can think of your initial $xml as
clothes. So, you add a child to it. That error message is kinda cryptic
though.

?php

$xml = EOD
?xml version=1.0 encoding=iso-8859-1?
clothes

 item
   nameRed Gloves/name
   desca pair of red gloves/desc
   sizeadult/size
   price12.99/price
 /item

 item
   nameSnow Boots/name
   descsome snow boots/desc
   sizechild/size
   price23.99/price
 /item

/clothes
EOD;

$sxml = simplexml_load_string($xml);

$item = $sxml-addChild('item');
$item-addChild('name', 'Blue Gloves');

echo $sxml-asXML();

exit;


On Thu, Sep 3, 2009 at 5:03 PM, Matthew Croud m...@obviousdigital.comwrote:

 Hi foks,

 Could someone lend me a little hand with simpleXML ?
 I've been looking at examples in the PHP manual and W3C, i'm at the
 pinnacle of figuring it out but alas i need a hand from the mailing list
 dudes.

 My aim is to add another item node, so i'll start with my XML file called
 items.xml

 Item.xml_

 ?xml version=1.0 encoding=iso-8859-1?
 clothes

  item
nameRed Gloves/name
desca pair of red gloves/desc
sizeadult/size
price12.99/price
  /item

  item
nameSnow Boots/name
descsome snow boots/desc
sizechild/size
price23.99/price
  /item

 /clothes
 __


 And now the PHP i'm using to create a new item node:


 $xml = simplexml_load_file('items.xml');

 $item = $xml-clothes-addChild('item');
 $item-addChild('name', 'blue gloves');
 $item-addChild('desc', 'some blue gloves');
 $item-addChild('size', 'adult');
 $item-addChild('price', '4.99');

 __

 The error i'm getting is:  Cannot add child. Parent is not a permanent
 member of the XML tree


 Help me Gamesmaster!
 Matt

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Best way to test for form submission?

2009-08-29 Thread J DeBord
I've heard stories like this before, but never encountered it myself.

I forgot to mention that it is a good idea to give your submit buttons a
value attribute. Regardless of how the form is submitted, you should then
have a value for ['submit'].

Reminding the user that they must do anything other than the simplest things
is usually not a good approach. There will inevitably be users who do not
see/follow your reminder and use the enter button. Give the submit button a
value.


On Sat, Aug 29, 2009 at 6:50 AM, Keith survivor_...@hotmail.com wrote:

 I've encountered issue with checking $_POST['submit']
   if(isset($_POST['submit'])) {}

 If the form consists of checkbox/radio and text field, some of my forms can
 be submitted by just press [ENTER] at the end of one of the text field. In
 this case, the $_POST['submit'] is set even the  submit button was not
 clicked.
 However, in some of my forms, $_POST['submit'] will not be set if I submit
 the form by pressing [ENTER] in one of the text field.
 So, if the later case happen, I need to remind the user to explicitly click
 the [Submit] button.
 I don't know why or in what condition that pressing [ENTER] will not submit
 the whole form include the $_POST['submit'].

 Keith


 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1251467419.27899.106.ca...@localhost...

  On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote:

 On 08/27/2009 11:09 PM, Adam Jimerson wrote:
  This question might give away the fact that I am a php noob, but I am
  looking for the best way to test for form submission in PHP.  I know in
  Perl this can be done with
 
  if (param)
 
  but I don't know if that will work with PHP.  I have read the Learning
  PHP 5 book and the only thing that was mentioned in the book was the 
 use
  of something like this
 
  print pHello .$_POST['username']./p;

 Sorry copied and pasted the wrong line (long day)

 if (array_key_exists('username',$_POST))
 
  I'm sure that this is not the best/recommended way to do this but I'm
  hoping someone here will point me in the right direction.



 The best way I've found is to do something like this:

 if(isset($_POST['submit']))
 {}

 Note that in-place of submit you can put the name of any form element. I
 chose submit here, because every form should have a submit button. Note
 also that this will only work if you have given your submit button a
 name:

 input type=submit name=submit value=Submit/

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Calling extension function from another

2009-08-29 Thread J DeBord
On Sat, Aug 29, 2009 at 10:14 AM, leledumbo leledumbo_c...@yahoo.co.idwrote:


 extension A has function a, extension B has function b. How can I make b
 calls a?


What is an extension?



 --
 View this message in context:
 http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25200892.html
 Sent from the PHP - General mailing list archive at Nabble.com.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread J DeBord
If you want to check that a *form* was submiited, you need to at minimum
check that one of the form elements exist in the post data, assuming the
method is post. The submit button is a good one to use. Just checking that
there *is* POST data isn't a great idea. Anyone can post anything. Checking
for a key named 'submit' in the POST array is no more difficult than any
other method. That being said anyone could POST a key value pair with the
key being 'submit'. So validate everything!

On Fri, Aug 28, 2009 at 7:29 PM, Martin Scotta martinsco...@gmail.comwrote:

 On Fri, Aug 28, 2009 at 1:59 PM, Ben Dunlap bdun...@agentintellect.com
 wrote:

   Well, as far as I'm aware $_SERVER isn't reliable from server to
 server.
   That said, I've never had a problem using it.
 
  Thanks -- I just looked it up and the manual says: There is no
  guarantee that every web server will provide any of these; servers may
  omit some, or provide others not listed here. That said, a large
  number of these variables are accounted for in the ยป CGI 1.1
  specification, so you should be able to expect those.
 
  So I guess it wouldn't make sense to rely on anything in $_SERVER if
  you're building an app for widespread use; e.g., CodeIgniter, as
  mentioned above.
 
   tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
   benefit of being able to work with both arrays (as well as $_SESSION
 and
   $_COOKIE) without any drawbacks.
 
  For now I'm inclined against $_REQUEST, since it's not yet supported
  by filter_input(). I think filter_input() is the bee's knees and I've
  stopped touching $_POST or $_GET directly since I discovered it.
 
  Ben
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 When the request is PUT your $_SERVER['REQUEST_METHOD'] detection will
 fail,
 but the $_POST will be populated.

 I think the best way is by count( $_POST )  0 but this only applies for
 application/x-www-form-urlencoded forms.
 Other content-type will not populate the $_POST and therefore need to be
 validated by other method.

 PHP provides non-yet-standard HttpRequest class that can handle this
 perfectly


 --
 Martin Scotta