php-general Digest 22 Aug 2007 09:36:42 -0000 Issue 4975

Topics (messages 261093 through 261103):

Re: php to generate java-script
        261093 by: brian
        261100 by: Nathan Nobbe

php/mysql - getting ID of query
        261094 by: John Pillion
        261095 by: mike
        261096 by: M. Sokolewicz
        261098 by: John Pillion

Re: keeping fields moving forward
        261097 by: Mike Ryan

Programmer in the US?
        261099 by: Jan Reiter

Re: About Session And Cookies
        261101 by: Kelvin Park

export data of html table
        261102 by: Vanessa Vega

Re: LDAP
        261103 by: Alain Roger

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Jas wrote:
Anyone have a good method of grabbing the current page and reading data
from it?

For example:
<?PHP
 // find all form fields for current page
 function FindFormFields( $page ) {
  if( empty( $page ) ) {
   $data = -1;
  } else {
   if( ( $fh = @fopen( $page, "r" ) ) === FALSE ) {
    $data = -1;
   } else {
    while( !feof( $fh ) ) {
     $line = fgets( $fh, 512 );
     if( eregi( "<input type=\"", $line ) ) {
      $data[] = $line;
     }
    }
    fclose( $fh );
   }
  }
  return $data;
 }

 echo FindFormFields( "http://php.net"; );
?>

The above code would output the following:
Array
(
    [0] =>    <input type="text" name="pattern" value="" size="30"
accesskey="s" />

    [1] =>    <input type="image"

)

Now for the problem I am having and a description of what I am trying to
accomplish:

I want to dynamically generate a form and in doing so I would like to
dynamically generate the following javascript features for said page
  - javascript form validation
  - javascript form field focus

The problem is if I call the current page that is being generated such as
<?PHP
echo FindFormFields( "http://"; . $_SERVER['SERVER_NAME'] .
$_SERVER['REQUEST_URI'] );
?>

Not only does it take a helluva long time to load the page but it also
creates a nested array with duplicate values.


I'm not surprised it's taking a while to load in your browser. I think you have a serious nested loop issue there. What you're doing is telling the PHP engine to load the same page again. When it does that it's going to call your function *again* on the same page. Rinse and repeat.

But i don't understand what putting those tags in an array is going to accomplish. Perhaps there's a lot more to this, but i'd be inclined to set up my validation in a more targetted manner.

brian

--- End Message ---
--- Begin Message ---
i agree with brian.
i still need to enhance my skills w/ javascirpt, but i think in the case of
validation, a simple
solution is to write generic validation components in javascript.  then
simply dynamically
include the ones you need for a particular form.
as far as the javascript knowing how to locate the form fields i think its a
matter of defining
a naming convention w/in your system.

-nathan

On 8/21/07, brian <[EMAIL PROTECTED]> wrote:
>
> Jas wrote:
> > Anyone have a good method of grabbing the current page and reading data
> > from it?
> >
> > For example:
> > <?PHP
> >  // find all form fields for current page
> >  function FindFormFields( $page ) {
> >   if( empty( $page ) ) {
> >    $data = -1;
> >   } else {
> >    if( ( $fh = @fopen( $page, "r" ) ) === FALSE ) {
> >     $data = -1;
> >    } else {
> >     while( !feof( $fh ) ) {
> >      $line = fgets( $fh, 512 );
> >      if( eregi( "<input type=\"", $line ) ) {
> >       $data[] = $line;
> >      }
> >     }
> >     fclose( $fh );
> >    }
> >   }
> >   return $data;
> >  }
> >
> >  echo FindFormFields( "http://php.net"; );
> > ?>
> >
> > The above code would output the following:
> > Array
> > (
> >     [0] =>    <input type="text" name="pattern" value="" size="30"
> > accesskey="s" />
> >
> >     [1] =>    <input type="image"
> >
> > )
> >
> > Now for the problem I am having and a description of what I am trying to
> > accomplish:
> >
> > I want to dynamically generate a form and in doing so I would like to
> > dynamically generate the following javascript features for said page
> >   - javascript form validation
> >   - javascript form field focus
> >
> > The problem is if I call the current page that is being generated such
> as
> > <?PHP
> > echo FindFormFields( "http://"; . $_SERVER['SERVER_NAME'] .
> > $_SERVER['REQUEST_URI'] );
> > ?>
> >
> > Not only does it take a helluva long time to load the page but it also
> > creates a nested array with duplicate values.
> >
>
> I'm not surprised it's taking a while to load in your browser. I think
> you have a serious nested loop issue there. What you're doing is telling
> the PHP engine to load the same page again. When it does that it's going
> to call your function *again* on the same page. Rinse and repeat.
>
> But i don't understand what putting those tags in an array is going to
> accomplish. Perhaps there's a lot more to this, but i'd be inclined to
> set up my validation in a more targetted manner.
>
> brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
This is as much a mysql question as it is php.

 

What is the most reliable way to retrieve an auto_increment key/id for a
query you just inserted?

 

In other words, I compile all my data, insert it into a new row, and now I
want to retrieve the ID it created for it in the ID/key field.  Without
turning around and searching for the values I just inserted, is there a way
to get the ID?  The ID is the only field that is guaranteed to be unique in
each data set, which makes it questionable to search for the data you just
inserted, unless you searched for the *whole* data set.

 

Thanks

 

John


--- End Message ---
--- Begin Message ---
mysql_insert_id()
mysqli_insert_id()

http://us.php.net/mysql is your friend :)
http://us.php.net/mysqli too!



On 8/21/07, John Pillion <[EMAIL PROTECTED]> wrote:
> This is as much a mysql question as it is php.
>
>
>
> What is the most reliable way to retrieve an auto_increment key/id for a
> query you just inserted?
>
>
>
> In other words, I compile all my data, insert it into a new row, and now I
> want to retrieve the ID it created for it in the ID/key field.  Without
> turning around and searching for the values I just inserted, is there a way
> to get the ID?  The ID is the only field that is guaranteed to be unique in
> each data set, which makes it questionable to search for the data you just
> inserted, unless you searched for the *whole* data set.
>
>
>
> Thanks
>
>
>
> John
>
>

--- End Message ---
--- Begin Message ---
John Pillion wrote:
This is as much a mysql question as it is php.

What is the most reliable way to retrieve an auto_increment key/id for a
query you just inserted?

In other words, I compile all my data, insert it into a new row, and now I
want to retrieve the ID it created for it in the ID/key field.  Without
turning around and searching for the values I just inserted, is there a way
to get the ID?  The ID is the only field that is guaranteed to be unique in
each data set, which makes it questionable to search for the data you just
inserted, unless you searched for the *whole* data set.

Thanks

John



mysql_insert_id()
mysqli::insert_id
PDO::lastInsertId()

depending on the way you access it.

--- End Message ---
--- Begin Message ---
Thanks guys, that's exactly what I was looking for

J

-----Original Message-----
From: M. Sokolewicz [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 21, 2007 4:51 PM
To: John Pillion
Cc: [EMAIL PROTECTED]
Subject: Re: php/mysql - getting ID of query

John Pillion wrote:
> This is as much a mysql question as it is php.
> 
>  
> 
> What is the most reliable way to retrieve an auto_increment key/id for a
> query you just inserted?
> 
>  
> 
> In other words, I compile all my data, insert it into a new row, and now I
> want to retrieve the ID it created for it in the ID/key field.  Without
> turning around and searching for the values I just inserted, is there a
way
> to get the ID?  The ID is the only field that is guaranteed to be unique
in
> each data set, which makes it questionable to search for the data you just
> inserted, unless you searched for the *whole* data set.
> 
>  
> 
> Thanks
> 
>  
> 
> John
> 
> 

mysql_insert_id()
mysqli::insert_id
PDO::lastInsertId()

depending on the way you access it.

--- End Message ---
--- Begin Message ---
I think I have it fixed  I had some code wrong in my <input hidden> variable
this worked and did the job for me

I am an old time type of programmer who is not very good with the object
oriented programming and have not taken the time to learn some new tricks.
one day I will.



""Mike Ryan"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am creating a series of forms that collect information this covers 3
> screens before I want to write it out to the database.  when I go from one
> screen to the next I have tried hidden and readonly input boxes but the
data
> in the hidden and readonly fields from screen one do not make it to the
> final page.
>
> Is there a way to get the data from page one without letting the users
> modify the information.  I guess I could write the data to the database
but
> how do I find the record number of the data I just wrote so that I can
> update the information, will php tell me the record number? I am using php
> 5.2.1 and mysql 5.x
>
> thanks for your help.
>

--- End Message ---
--- Begin Message ---
Hi there!

I spent the last 4 Years ('03-'07) as an Officer with the German Air Force
collecting massive experience with large university networks (programming,
maintenance) and on electronic warfare live training exercises (management,
IT Officer), but I studied Space and Aeronautics and did not finish. I have
programming experience in C/C++ since '99 and PHP/html/jscript since '01. I
do not have a diploma or degree or anything. Only a military record that
tells what I did, and that I did it good! ;-)

Sine I see from some of your signatures that some of you are working at US
based companies, do you have any tips or experiences how to start off as a
programmer or technical manager with such a bad starting position? 

Getting a greencard once I got a job shouldn't be a problem since I'm
cleared up to NATO-Secret. (if that helps)

Thank you very much for any help, tips, experiences ... 

Best Regards,
 Jan

--- End Message ---
--- Begin Message ---
Hello, thanks for all the replies.
However, since I'm not very familiar with trans_sid I'll do some research on
that.

Michelle Konzack, if hiding the id in hidden form field element or enabling
trans_sid could lead to security risks, what would you recommend as an
alternative method to safely transfer user information across different
pages in a website?

Thank you.

On 8/18/07, Michelle Konzack <[EMAIL PROTECTED]> wrote:
>
> Am 2007-08-17 22:07:47, schrieb Bastien Koert:
> >
> > If cookies are not available, you can either
> >
> > hide the id in the hidden form field element
> > or
> > enable trans_sid to automatically pass the session id in the url
>
> This will be a security risk since Session-Hijacker can grap the URL
>
> Greetings
>     Michelle Konzack
>     Systemadministrator
>     Tamay Dogan Network
>     Debian GNU/Linux Consultant
>
>
> --
> Linux-User #280138 with the Linux Counter, http://counter.li.org/
> ##################### Debian GNU/Linux Consultant #####################
> Michelle Konzack   Apt. 917                  ICQ #328449886
>                    50, rue de Soultz         MSN LinuxMichi
> 0033/6/61925193    67100 Strasbourg/France   IRC #Debian (irc.icq.com)
>
>

--- End Message ---
--- Begin Message ---
helloo..

i have a table generated using PHP & javascript...the data on that table 
came from a form where several
data was inputted... I want
to let them see a preview of the data they entered, so i put a link or 
button that when clicked, will display all the data in the table and  they 
will also have an option to
print them.

Is there a way to easily do this? does it really need exporting data to 
another
application like excel in order to print it?
 please give me some advice...thanks 

--- End Message ---
--- Begin Message ---
Hi,

Have you tried in the php.ini to setup error_reporting to E_ALL and display
error messages (display_errors = On) ?
I had a similar problem 2 days ago and it was due to another mistake in my
PHP code.

But i did not get any error message or more precisely, i did not get any
WARNING message.
since i did this i repaired my PHP mistake.

My code relative to LDAP was good and without any mistake.

Try this and let us know if you do not have such situation.

Alain

On 8/21/07, Dan Shirah <[EMAIL PROTECTED]> wrote:
>
> Nothing is being blocked since both servers are inside the DMZ.
>
> On 8/21/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
> >
> > On 8/21/07, Dan Shirah <[EMAIL PROTECTED]> wrote:
> > > Okay, hopefully someone can help me out here.  I've gone over ldap at
> > > php.net and multiple other sites but can't get it to work. Everytime I
> > run
> > > the query my results are "0 entries returned".
> > >
> > > My AD tree is: CN=Users,DC=domain,DC=us.  I have the AD Server set so
> > that
> > > anonymous access to retrieve information is enabled.
> > >
> > > Below is my code.  Any ideas?
> > >
> > >
> > > <?php
> > >     $ldap_host = "AD Server";
> > >     $ldap_port = "389";
> > >     $base_dn = "DC=domain,DC=us";
> > >     $filter = "(CN=users)";
> > >     $connect = ldap_connect( $ldap_host, $ldap_port);
> > >     ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
> > >
> > >     $bind = ldap_bind($connect);
> > >     $read = ldap_search($connect, $base_dn, $filter);
> > >
> > >     $info = ldap_get_entries($connect, $read);
> > >     echo $info["count"]." entries returned<BR><BR>";
> > >     for($row = 0; $row<$info["count"]; $row++)
> > >     {
> > >         for($column = 0; $column<$info[$row]["count"]; $column++)
> > >         {
> > >             $data = $info[$row][$column];
> > >             echo $data.":".$info[$row][$data][0]."<BR>";
> > >         }
> > >         echo "<BR>";
> > >     }
> > > ldap_close($connect);
> > > ?>
> > >
> >
> >    This may be kind of a dumb question....  but did you check your
> > firewall settings?
> >
> > --
> > Daniel P. Brown
> > [office] (570-) 587-7080 Ext. 272
> > [mobile] (570-) 766-8107
> >
> > Hey, PHP-General list....
> > 50% off for life on web hosting plans $10/mo. or more at
> > http://www.pilotpig.net/.
> > Use the coupon code phpgeneralaug07
> > Register domains for about $0.01 more than what it costs me at
> > http://domains.pilotpig.net/.
> >
>



-- 
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.3
Apache 2.2.4
PHP 5.2.3

--- End Message ---

Reply via email to