php-general Digest 1 May 2004 10:14:04 -0000 Issue 2737

Topics (messages 185076 through 185090):

Re: https & sessions failing to persist
        185076 by: Michael R. Wayne
        185077 by: Curt Zirzow

initializing HTML form using PHP
        185078 by: Denis Kertz
        185079 by: Daniel Clark

Separating spaces from the rest
        185080 by: Anguz
        185081 by: Anguz
        185082 by: Curt Zirzow
        185083 by: Justin Patrin

dollar sign ASCII code
        185084 by: David T-G
        185085 by: John W. Holmes

Batch/Prepared statements for Mysql in PHP
        185086 by: electroteque

@session_start()?
        185087 by: Brandon Goodin
        185089 by: Torsten Roehr

Script never returns from funktion.
        185088 by: Lars.Pedersen.oz2lpr.dk
        185090 by: PHP Email List

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 ---
On Fri, Apr 30, 2004 at 08:52:37PM +0000, Curt Zirzow wrote:
> 
> session.cookie_path
> session.cookie_domain
> session.cookie_secure

session.cookie_path     /
session.cookie_secure   Off
session.cookie_domain   no value

But we never use cookies:
session.use_cookies     Off

/\/\ \/\/

--- End Message ---
--- Begin Message ---
* Thus wrote Michael R. Wayne ([EMAIL PROTECTED]):
> On Fri, Apr 30, 2004 at 08:52:37PM +0000, Curt Zirzow wrote:
> > 
> > session.cookie_path
> > session.cookie_domain
> > session.cookie_secure
> 
> session.cookie_path   /
> session.cookie_secure Off
> session.cookie_domain no value
> 
> But we never use cookies:
> session.use_cookies   Off

do'h.. i completly missed that.  



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
I have a large HTML form (~100 form elements) that I used a year ago to
conduct a survey.  Now I would like to use this same form but rather than
starting with an empty form I would like to populate the form with a user's
survey response from last year.  I have the survey data in a mysql db and I
know how to use PHP to retrieve a user's data.  However, the only way I know
to insert a user's data into a form is to embed value="<?php echo $var; >"
statements for each form element (text, checkbox, drop-down, etc).  This is
pretty messy, especially for drop-down lists.

Is there a cleaner, easier way to do this?

Denis

--- End Message ---
--- Begin Message ---
That is the way I've done it.

I hear that with PEAR, you can add elments to the HTML page.

> I have a large HTML form (~100 form elements) that I used a year ago to
> conduct a survey.  Now I would like to use this same form but rather than
> starting with an empty form I would like to populate the form with a
> user's
> survey response from last year.  I have the survey data in a mysql db and
> I
> know how to use PHP to retrieve a user's data.  However, the only way I
> know
> to insert a user's data into a form is to embed value="<?php echo $var; >"
> statements for each form element (text, checkbox, drop-down, etc).  This
> is
> pretty messy, especially for drop-down lists.
>
> Is there a cleaner, easier way to do this?
>
> Denis
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- I have an array with many strings, of which most have spaces or tabs at the beginning, but no fixed number of them. Example:

$arr[0] = ' Hello.';

How can I separate them into two strings? Like:

Array
(
    [0] => Array
        (
            [0] => "    "  //I added the quotes to notice the space.
            [1] => Hello.
        )
)

TIA!
Anguz

--- End Message ---
--- Begin Message --- Thanks! I was just reading that function in the manual when I got your reply. I tested it but I still have a couple of problems with it.

print_r(preg_split('(\s+)', " word1 word2 word3.", -1, PREG_SPLIT_DELIM_CAPTURE));

I get this:

Array
(
    [0] =>
    [1] => word1
    [2] => word2
    [3] => word3.
)

In [0] the spaces aren't there and it's splitting the other spaces too, where I need to only split the leading spaces. How should I write it?

TIA,
Anguz


Kemper, Helmut wrote: > Hi, > > See preg_explite and use "/(\s+)/" for explode string into array. > > Tanks, > Kemper > > > ------------------------------------------------------------------------ > ----------------------------------------------------------------- > Helmut Kemper > [EMAIL PROTECTED] > Celular (Mobile): 55 81 99268744 > > > On 30/04/2004, at 20:22, Anguz wrote: > >> I have an array with many strings, of which most have spaces or tabs >> at the beginning, but no fixed number of them. Example: >> >> $arr[0] = ' Hello.'; >> >> How can I separate them into two strings? Like: >> >> Array >> ( >> [0] => Array >> ( >> [0] => " " //I added the quotes to notice the space. >> [1] => Hello. >> ) >> ) >> >> TIA! >> Anguz >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > >

--- End Message ---
--- Begin Message ---
* Thus wrote Anguz ([EMAIL PROTECTED]):
> Thanks! I was just reading that function in the manual when I got your 
> reply. I tested it but I still have a couple of problems with it.
> 
> print_r(preg_split('(\s+)', "   word1 word2 word3.", -1, 
> PREG_SPLIT_DELIM_CAPTURE));

You forgot the pattern deliminator:
  
 print_r(preg_split('/(\s+)/', "   word1 word2 word3.", -1, PREG_SPLIT_DELIM_CAPTURE));

> 
> Kemper, Helmut wrote:
> > Hi,
> >
> > See preg_explite and use "/(\s+)/" for explode string into array.
> >


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- Anguz wrote:

Thanks! I was just reading that function in the manual when I got your reply. I tested it but I still have a couple of problems with it.

print_r(preg_split('(\s+)', " word1 word2 word3.", -1, PREG_SPLIT_DELIM_CAPTURE));

I get this:

Array
(
    [0] =>
    [1] => word1
    [2] => word2
    [3] => word3.
)

In [0] the spaces aren't there and it's splitting the other spaces too, where I need to only split the leading spaces. How should I write it?

TIA,
Anguz


Kemper, Helmut wrote: > Hi, > > See preg_explite and use "/(\s+)/" for explode string into array. > > Tanks, > Kemper > > > ------------------------------------------------------------------------ > ----------------------------------------------------------------- > Helmut Kemper > [EMAIL PROTECTED] > Celular (Mobile): 55 81 99268744 > > > On 30/04/2004, at 20:22, Anguz wrote: > >> I have an array with many strings, of which most have spaces or tabs >> at the beginning, but no fixed number of them. Example: >> >> $arr[0] = ' Hello.'; >> >> How can I separate them into two strings? Like: >> >> Array >> ( >> [0] => Array >> ( >> [0] => " " //I added the quotes to notice the space. >> [1] => Hello. >> ) >> ) >> >> TIA! >> Anguz >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > >

...I wonder why you're doing this, but here's an answer for you.

BTW, if you use var_dump or var_export, you can see the whitespace :-).

$arr = preg_split('/(^\s+)/', "   word1 word2 word3.", -1,
      PREG_SPLIT_DELIM_CAPTURE);

The ^ means beginning of string.

This will still give you an empty string in $arr[0], so do something like:

unset($arr[0]);
$arr = array_values($arr);

Or just write your code to expect the extra entry. ;-)

--
paperCrane <Justin Patrin>

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

I have a comment field where I allow users to enter the picture comments
and then I later display them.  I thought I was converting everything as
needed (I inherited the code), but using a dollar sign breaks things (I'm
sure PHP is trying to interpret it).

The proper fix, I know, is to go and properly convert that dollar sign,
too; we will, but of course we have to test the new code before we roll
it out -- and we have to pin down why it isn't doing it now in the first
place.  The quick fix, though, is to tell him to use the proper HTML
escape sequence for it, like &#039; for an apostrophe or &amp; for an
ampersand.

Does anyone have the code for a dollar sign?


TIA & HANN

:-D
-- 
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00000.pgp
Description: PGP signature


--- End Message ---
--- Begin Message --- David T-G wrote:

I have a comment field where I allow users to enter the picture comments
and then I later display them.  I thought I was converting everything as
needed (I inherited the code), but using a dollar sign breaks things (I'm
sure PHP is trying to interpret it).

The proper fix, I know, is to go and properly convert that dollar sign,
too; we will, but of course we have to test the new code before we roll
it out -- and we have to pin down why it isn't doing it now in the first
place.  The quick fix, though, is to tell him to use the proper HTML
escape sequence for it, like &#039; for an apostrophe or &amp; for an
ampersand.

Does anyone have the code for a dollar sign?

http://www.asciitable.com/

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I was wondering if there is any current API for creating match/prepare
statements, therefore say i have a script to insert, update and insert in
the same post, is there a way to reduce to many queries to the database to
do it all in one hit ? Although i usually return the last inc id then add it
to the second query ?

--- End Message ---
--- Begin Message ---
I noticed this notation in one of the PEAR packages @session_start()? What
is the purpose of the '@' sign?

 

Thanks

Brandon


--- End Message ---
--- Begin Message ---
"Brandon Goodin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I noticed this notation in one of the PEAR packages @session_start()? What
> is the purpose of the '@' sign?

It suppresses/ignores any error output for this function.

Regards, Torsten

>
>
>
> Thanks
>
> Brandon
>
>

--- End Message ---
--- Begin Message ---



Hi ,  i am having problems with a funktion call never returns from the
funktion.

The script is started from ldaptest.php with call the funktion
authenticate().
when inserting the real name and password the script stop's at the end and
dont return to ldaptest.php


system info:
linux Suse 9.0
php 4.3.5
http server is domino R 6.5.1.

//the code //

script ldaptest.php:

<?php
include "auth3.php";
if ($_COOKIE[auth] == "1") {
    $msg = "<p>You are an authorized user.</p>";
} else {
authenticate(); // the script never returns from this line
   }
echo "user = $username";
$ip = "localhost";
$dn="CN=klaus, O=oz2lpr";
$password = "fakeword";
if (!($ldap = ldap_connect($ip))) {
   die ("Could not connect to LDAP server");
}
print "connected to <b>$ip</b><br/>";
if (!($res = @ldap_bind($ldap, $dn, $password))) {
   die ("Could not bind to $dn");
}
print "user <b>$dn</b> authenticated.<br/>";
$sdn = "O=fakeword2";
$filter = "(objectclass=*)";
print "executing search...<b>DN: $sdn; Filter: $filter</b><br/>";
$sr=ldap_search($ldap, $sdn, $filter);
$info = ldap_get_entries($ldap, $sr);
print $info["count"]." entries returned<hr>";
print "<PRE>";
print_r($info);
print "</PRE>";
ldap_close($ldap);
die;
?>


script auth3.php:

<?php
function authenticate() {
if ((!$_POST[username]) || (!$_POST[password])) {
    header("Location: ask.php");
    }
$server="localhost";    //change to ip address of ldap server
$basedn="O=oz2lpr";     //change to reflect the ou and domain that your
users are in.
                  $username=$_POST['username'];
                  $password=$_POST['password'];
                  $filter = "(objectclass=*)";
                  $dn = "CN=$username,O=oz2lpr";
                        if (!($connect = ldap_connect($server))) {
                        header("Location: ask.php");
                        exit;
                        }
                        if (!($bind = @ldap_bind($connect, "$dn",
$password))) {
                        header("Location: ask.php");
                        exit;
                        } else {
                  ldap_close($connect);
setcookie("auth", "1", 0, "/", "fakeword2.dk", 0);
return $username;
}
}
?>


script ask.php:

<html>
<head>
<title>Auth User Login Form</title>
</head>
<body>
<H1>Login Form</H1>
<FORM METHOD="POST" ACTION="auth3.php">
<P><STRONG>Username:</STRONG><BR>
<INPUT TYPE="text" NAME="username"></p>
<P><STRONG>Password:</STRONG><BR>
<INPUT TYPE="password" NAME="password"></p>
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Login"></P>
</FORM>
</body>
</html>




--- End Message ---
--- Begin Message ---
> Subject: [PHP] Script never returns from funktion.

> Hi ,  i am having problems with a funktion call never returns from the
> funktion.


Now I'm still new to PHP so bare with me if this is wrong. But don't you
have to assign the "authenticate()" function to something as your returning
the $username? I believe you need to assign it to a variable name that of
which you are echo'ing on the very next line, as the function doesn't allow
for global scope of your "$username" variable.

[...]
> authenticate(); // the script never returns from this line

        $username = authenticate();

>  }
>echo "user = $username";
[/...]

The PHP Pros can correct me if I'm wrong now. I thought I'd take a shot at
this one though. Thanks and HTH.
Wolf

--- End Message ---

Reply via email to