Re: [PHP] learning resources for PHP

2012-04-18 Thread Tim Dunphy
> 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,   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



[PHP] errors not showing

2012-05-19 Thread Tim Dunphy
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

2012-05-19 Thread Tim Dunphy
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  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



[PHP] Re: show info from mysql db

2012-06-10 Thread Tim Dunphy
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  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:
>
> 
> Starship Crew
> 
>  
> 
> 
>        .box{
>                font-family:Tahoma, Geneva, sans-serif;
>                font-size:16px;
>                text-align: center
>        }
> 
>
>  Enter your First Name, Last Name, Rank, Division,Ship and Email
> address.
>  
>
>    First name:
>    
>    Last name:
>    
>    Rank:
>    
>    Division:
>    
>    Ship:
>    
>    Email:
>    
>    
>  
>
>   Show crew manifest
>
>
>  
> 
> 
> 
>
> 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:
>
> 
> $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:
>
> 
> 
> Show Crew
> 
>
> 
>  
> 
> 
>        .box{
>                font-family:Tahoma, Geneva, sans-serif;
>                font-size:16px;
>                text-align: center
>        }
> 
> Crew Manifest
>
> 
>    $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 . '';
>  }
>
>   mysqli_close($dbc);
>
>
> ?>
> 
> 
>
> 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

2012-06-10 Thread Tim Dunphy
> 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  wrote:
> On Sun, Jun 10, 2012 at 8:25 AM, Tim Dunphy  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] Programmers and developers needed

2012-09-13 Thread Tim Dunphy
> 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  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] Programmers and developers needed

2012-09-14 Thread Tim Dunphy
On Fri, Sep 14, 2012 at 3:00 PM, Robert Cummings wrote:

> 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  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! 


-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B


Re: [PHP] Re: php can't insert data mysql table

2012-10-01 Thread Tim Dunphy
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

2012-10-01 Thread Tim Dunphy
>
> 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.Error returned was " . mysqli_error()
> . "Query 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 wrote:

> 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.Error returned was " . mysqli_error()
>> . "Query 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] iterate javascript verification

2013-05-24 Thread Tim Dunphy
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:



LDAP Form

  You will be creating $num_forms accounts
today.";
for($counter = 1;$counter<=$num_forms;$counter++) {
echo '';
echo '';
echo "Enter user: $counter";
echo "First Name:";
echo "";
echo "Last Name:";
echo "";
echo "Department:";
echo "";
echo "Title:";
echo "";
echo "Email:";
echo "";
echo "Phone:";
echo "";
  ?>
   
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;
}
  }
 
 ";
  echo "";
  echo "";
  echo "";

   ?>



Thanks,
Tim

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B


Re: [PHP] iterate javascript verification

2013-05-27 Thread Tim Dunphy
r right next to the field in error,
> which is usually a better UX.
>
> >   $tmp[] = " > value='$num_forms' />";
> >   $tmp[] = " name='requestor_email'
> > value='$requestor_email' />";
> >   $tmp[] = "";
> >   $tmp[] = "";
> >
> > ?>
> > 
> >
> > 
> > 
> > LDAP Form
> > 
> > 
> > 
> > 
> >
> > 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 
> 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:
> >> >
> >> > 
> >> > 
> >> > LDAP Form
> >> > 
> >> >>> >
> >> >if (isset($_POST['submit'])) {
> >> > $requestor_email = $_POST['requestor_email'];
> >> > $num_forms  = $_POST['num_forms'];
> >> > }
> >> >
> >> > echo "You will be creating $num_forms accounts
> >> > today.";
> >> > for($counter = 1;$counter<=$num_forms;$counter++) {
> >> > echo ' >> > action="sendemail.php" onsubmit="return validateForm()">';
> >> > echo '';
> >> > echo "Enter user: $counter";
> >> > echo "First
> >> > Name: >> > />";
> >> > echo " >> > name=\"first_name_.$counter.\" />";
> >> > echo "Last
> Name: >> > />";
> >> > echo " >> > name=\"last_name_.$counter.\" />";
> >> > echo " >> > for=\"department_.$counter.\">Department: >> > />";
> >> > echo " >> > name=\"department_.$counter.\" />";
> >> > echo "Title:";
> >> > echo " >> > name=\"title_.$counter.\" />";
> >> > echo "Email:";
> >> > echo " >> > name=\"email_.$counter.\" />";
> >> > echo "Phone:";
> >> > echo " >> > name=\"phone_.$counter.\" />";
> >> >   ?>
> >> >
> >> > 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;
> >> > }
> >> >   }
> >> >  
> >> >   >> >   }
> >> >
> >> >   echo " >> > value=\"$num_forms\" />";
> >> >   echo " >> > name=\"requestor_email\" value=\"$requestor_email\" />";
> >> >   echo " >> > />";
> >> >   echo "";
> >> >
> >> >?>
> >> > 
> >> > 
> >> >
> >> > 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
>
>


-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B


Re: [PHP] iterate javascript verification

2013-05-27 Thread Tim Dunphy
Sounds good! Thanks Ken. Very clear now.

Tim

Sent from my iPhone

On May 27, 2013, at 1:57 PM, Ken Robinson  wrote:

> When you do validation of the form in the same script that shows the form, 
> the normal way to do this is
> 
>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:
>> 
>> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
>> 
>>  
>>  LDAP Request Form
>> 
>> 
>>  LDAP Request Form
>>   > onsubmit="return validateForm()">
>>Your Email Address:
>>> />
>>How Many Forms Do You Need:
>>> name="num_forms" />
>>
>>  
>> 
>> 
>> 
>> And here is ldap.php as was suggested:
>> 
>> 
>> 
>>  > 
>>   if (isset($_POST['submit'])) {
>>$requestor_email = $_POST['requestor_email'];
>>$num_forms  = $_POST['num_forms'];
>>}
>> 
>> 
>>echo "You will be creating $num_forms accounts
>> today.";
>>for($counter = 1;$counter<=$num_forms;$counter++) {
>>echo '> action="sendemail.php" onsubmit="return validateForm()">';
>>echo '';
>>echo "Enter user: $counter";
>>echo "First Name:> />";
>>echo "> name=\"first_name_.$counter.\" />";
>>echo "Last Name:";
>>echo "> name=\"last_name_.$counter.\" />";
>>echo "Department:> />";
>>echo "> name=\"department_.$counter.\" />";
>>echo "Title:";
>>echo "> name=\"title_.$counter.\" />";
>>echo "Email:";
>>echo "> name=\"email_.$counter.\" />";
>>echo "Phone:";
>>echo "> name=\"phone_.$counter.\" />";
>>  }
>> 
>>  echo "> value=\"$num_forms\" />";
>>  echo "> name=\"requestor_email\" value=\"$requestor_email\" />";
>>  echo "";
>>  echo "";
>> 
>> 
>> 
>> 
>>   ?>
>> 
>> 
>> 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  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:
>> > >
>> > >   > > >   $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 <= $n

[PHP] limit access to php page

2013-05-29 Thread Tim Dunphy
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


[PHP] mongo usage

2013-07-06 Thread Tim Dunphy
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:


 
  Mongo Test
 
 

 Mongo Test Page
 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 '';

   $addresses->insert($address);

 ?>
 



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

2013-07-06 Thread Tim Dunphy
| 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 wrote:

> 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:
> >
> > 
> > 
> > Mongo Test
> > 
> > 
> >
> > Mongo Test Page
> >  >
> >
> >
> > $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 '';
> >
> > $addresses->insert($address);
> >
> > ?>
> > 
> > 
> >
> >
> > 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

2013-07-06 Thread Tim Dunphy
| 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 wrote:

> You commented out the setting of yhe addresses variable
> On Jul 6, 2013 1:42 PM, "Tim Dunphy"  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:
>>
>> 
>>  
>>   Mongo Test
>>  
>>  
>>
>>  Mongo Test Page
>>  >
>>
>>
>> $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 '';
>>
>>$addresses->insert($address);
>>
>>  ?>
>>  
>> 
>>
>>
>> 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

2013-07-06 Thread Tim Dunphy
| 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  wrote:

>
>
>
> On Sat, Jul 6, 2013 at 9:16 PM, Tim Dunphy  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


Re: [PHP] Re: mongo usage

2013-07-06 Thread Tim Dunphy
Thanks. Sorry to bug you guys with this. That did it. sigh


On Sat, Jul 6, 2013 at 6:49 PM, Tim Streater  wrote:

> On 06 Jul 2013 at 23:27, Tim Dunphy  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] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Tim Dunphy
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

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

2013-09-29 Thread Tim Dunphy
Hey guys,

 Sorry about that i should have posted the full code to give you some idea
of context. Anyway, here it is:

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 'Deleted Bucket';
echo '';
echo 'List Buckets';
  } else {
echo (string) $response->body->Message;
  }
 //echo '';
}
?>

  Delete S3 Bucket
   
Bucket Name:
  *  *

  

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  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  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/awssd

Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Tim Dunphy
Hi Aziz,

 Thank you for getting back to me!

 I appreciate you spotting that error.

So I corrected that

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 'Deleted Bucket';
echo '';
echo 'List Buckets';
  } else {
echo (string) $response->body->Message;
  }
 //echo '';
}
?>

  Delete S3 Bucket
   
Bucket Name:
   * *

  

[PHP] learning resources for PHP

2012-04-03 Thread Tim Dunphy
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