php-general Digest 18 Jun 2003 07:36:47 -0000 Issue 2124

Topics (messages 151886 through 151931):

PHP.net Manual Magic?
        151886 by: Mark D Hiatt
        151889 by: CPT John W. Holmes

Re: Translate easy the language of the web site
        151887 by: Jacob Marble

Re: Password generator
        151888 by: Andrei BEJENARU

Re: Redirecting to index.php from index.html
        151890 by: Ralph
        151894 by: Michael
        151896 by: Jay Blanchard
        151898 by: Michael
        151909 by: Ralph
        151913 by: David Nicholson
        151914 by: Michael
        151916 by: Ralph
        151917 by: David Otton

refreshing fopen
        151891 by: Bryan Koschmann - GKT
        151893 by: Terje Torkelsen
        151902 by: Bryan Koschmann - GKT
        151908 by: Lars Torben Wilson

Re: Difference between $_POST[foo] and $_POST['foo']?
        151892 by: Ralph
        151907 by: Philip Olson

Re: error with null $HTTP_GET_VARS['field']
        151895 by: Lars Torben Wilson

Re: bcmod()
        151897 by: Lars Torben Wilson

Re: Problems passing variables from Javascript to PHP
        151899 by: Daniel

print_r recursion/depth problem
        151900 by: jef.eyeintegrated.com

Re: Ini_set with mutiple include directories
        151901 by: Jason Wong
        151906 by: Mike Morton
        151911 by: Lars Torben Wilson

Re: php editor?
        151903 by: o_j_p_p.icnet.com.ve
        151905 by: Chris Sherwood

Re: need help on coding
        151904 by: o_j_p_p.icnet.com.ve

Re: Form Elements - user adding dynamically
        151910 by: Nelson Goforth

Re: functions, opinion...
        151912 by: Hugh Bothwell

Re: max_execution_time
        151915 by: Yann Larrivee

MySQL Connection
        151918 by: moses.johnson.btopenworld.com
        151919 by: Lars Torben Wilson
        151921 by: moses.johnson.btopenworld.com
        151923 by: daniel.electroteque.org
        151927 by: Lars Torben Wilson

Quick SQL Question
        151920 by: Vernon
        151922 by: Greg Donald
        151924 by: Vernon
        151925 by: Greg Donald

Add new loadable module in php
        151926 by: Skon Lapamnuaypol

Debuging PHP script
        151928 by: Skon Lapamnuaypol

Re: Good Hosting company
        151929 by: Cornelius Engelbrecht

Re: REGEX Question
        151930 by: Don Read

Re: [PHP-WIN] Password generator
        151931 by: Svensson, B.A.T. (HKG)

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 ---
One of the coolest things I have seen online, and some of you may not even 
know this works, but if you type in the url: "http://www.php.net/foo"; 
you'll be taken straight to the foo page of the php manual, if one exists. 
If "foo" doesn't exist, you pull up a Google search-within-the-site page.
 
I haven't been messing with php for very long, but I haven't been able to 
put together all of the pieces for something like this. Is it hugely 
complicated? There's definitely a lot more here than a simple .htaccess 
rewrite. Has anyone thought of any other uses this kind of thing could be 
put to?
 
Mark D Hiatt
"Better Documentation Through Science"

--- End Message ---
--- Begin Message ---
> One of the coolest things I have seen online, and some of you may not even
> know this works, but if you type in the url: "http://www.php.net/foo";
> you'll be taken straight to the foo page of the php manual, if one exists.
> If "foo" doesn't exist, you pull up a Google search-within-the-site page.
>
> I haven't been messing with php for very long, but I haven't been able to
> put together all of the pieces for something like this. Is it hugely
> complicated? There's definitely a lot more here than a simple .htaccess
> rewrite. Has anyone thought of any other uses this kind of thing could be
> put to?

It's a custom 404 page, IIRC. Your 404 page simply looks at the URL, grabs
the last part and forwards (using header(), I imagine) to the appropriate
page.

Many other uses for it, too. One that's written about on PHP.net is using
this to make static HTML pages. You have a URL such as domain.com/1234.html,
where that page doesn't exist. Your 404 page looks up product 1234 from the
database, writes an HTML page to disk called 1234.html, then redirects back
to the page. Now subsequent requests for 1234.html pull up the page just
created and do not hit the database at all. To "clear" everything, simply
delete all of the .html files and they'll be regenerated as they're needed.

I'm sure there are other uses...

---John Holmes...


--- End Message ---
--- Begin Message ---
Exactly, thanks.  Have you guys tried those on-line translators like
Google's?  Another big problem is conjugated verbs in Spanish.  They remind
me of those wacky mad-libs books in elementary school...  :-)
"John Hicks" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Friday 13 June 2003 03:00 pm, you wrote:
> > On Saturday 14 June 2003 02:19, Jacob Marble wrote:
> > > Amen; machine-translators are no good for something
> > > that you don't want confused.
> > > ie- english "season" could be "sazon" or "estacion" in
> > > Spanish, which mean two different things.
> >
> > Never mind translation, "season" in English has more than
> > one meaning.
>
> I think that was his point. And the two meanings correspond to two
different words in Spanish.
>
> Most translation programs attempt to determine the intended meaning of
such a word from its context. But it's an imperfect science.
>
> -J



--- End Message ---
--- Begin Message ---
Here's a little function that could help you...
It uses the ASCII table to generate the characters and it still needs to be
customized for any length
and to deny the use of the special characters...
Don't forget to set the mt seed!

function generatePassword() {
 $passwd = "";
 while(strlen($passwd)<10) {
  switch(mt_rand(1,4)) {
   case 1:
    $tmp = chr(mt_rand(33,46));
    if ($tmp!="'" && $tmp!="\"") {
     $passwd .= $tmp;
    }
    break;
   case 2:
    $passwd .= chr(mt_rand(48,57));
    break;
   case 3:
    $passwd .= chr(mt_rand(65,90));
    break;
   case 4:
    $passwd .= chr(mt_rand(97,122));
    break;
  }
 }
 return $passwd;
}


"Davy Obdam" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi people,
>
> I have to make a password generator, but i have a little problem.
>
> - It needs to generate password 8 characters long, and including 1 or 2
> special characters(like #$%&*@).
> - Those special characters can never appear as the first or last
> character in the string... anywhere between is fine.
>
> I have a password generator script now that does the first thing... but
> the special character can be in front or back of the string wich it
> shouldnt.. i have been looking on the web for this but i havent found
> the answer. Below is my scripts so far..
>
> Any help is appreciated, thanks for your time,
>
> Best regards,
>
> Davy Obdam
>
> --------------------------------------------------------------------------
--------------------------------------
>
> <?php
> // A function to generate random alphanumeric passwords in PHP
> // It expects to be passed a desired password length, but it
> // none is passed the default is set to 8 (you can change this)
> function generate_password($length = 8) {
>
>     // This variable contains the list of allowable characters
>     // for the password.  Note that the number 0 and the letter
>     // 'O' have been removed to avoid confusion between the two.
>     // The same is true of 'I' and 1
>     $allowable_characters =
"abcdefghefghijklmnopqrstuvwxyz0123456789%#*&";
>
>     // We see how many characters are in the allowable list
>     $ps_len = strlen($allowable_characters);
>
>     // Seed the random number generator with the microtime stamp
>     // (current UNIX timestamp, but in microseconds)
>     mt_srand((double)microtime()*1000000);
>
>     // Declare the password as a blank string.
>     $pass = "";
>
>     // Loop the number of times specified by $length
>     for($i = 0; $i < $length; $i++) {
>
>         // Each iteration, pick a random character from the
>         // allowable string and append it to the password.
>         $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
>
>     }
>
>     // Retun the password we've selected
>     return $pass;
> }
>
> $password = generate_password();
> echo $password;
>
> ?>
>
> -- 
> -----------------------------------------------------------------------
> Davy Obdam
> Web application developer
>
> Networking4all
> email: [EMAIL PROTECTED]
> email: [EMAIL PROTECTED]
> internet: http://www.networking4all.com
> -----------------------------------------------------------------------
>
>
>



--- End Message ---
--- Begin Message ---
<?php

if(strstr = ($HTTP_USER_AGENT, "Mozilla/4")){
   header("Location: http://www.mydomain.com/moz4_page.php";)
} 

elseif(strstr = ($HTTP_USER_AGENT, "MSIE")){
   header("Location: http://www.mydomain.com/ie_page.php";)
}

etc...

?>

<HTML>
<HEAD>
<TITLE>My Page</TITLE>
</HEAD>

etc..


-----Original Message-----
From: Michael [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 17, 2003 11:42 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Redirecting to index.php from index.html

I'm a relative newbie to PHP coming from the Zope/Python/DTML world.
Does 
anyone know of a good way, short of a javascript, to redirect from
index.html 
to index.php.   Also, can I use PHP to test for browsers, then redirect
them 
to the appropriate page.  In DTML/Python it would be :

<dtml-if "_.string.find(HTTP_USER_AGENT, 'Mozilla/4') >= 0>
<dtml-call "RESPONSE.redirect('moz4_page.php')">
</dtml-if>

This can be called from anywhere in the page.  I know that PHP does not
work 
this way and that this would need to be done before <html>, but I'm even

having problems with that.  I guess I'm just having a hard time THINKING
like 
php.

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




--- End Message ---
--- Begin Message ---
If I use this on index.html, it does nothing.  If I use it on index.php I get:

Parse error: parse error, unexpected '=' in 
/path/to/file_named/main.php on line 3

What am I doing wrong


On Tuesday 17 June 2003 02:11 pm, Ralph wrote:
> <?php
>
> if(strstr = ($HTTP_USER_AGENT, "Mozilla/4")){
>    header("Location: http://www.mydomain.com/moz4_page.php";)
> }
>
> elseif(strstr = ($HTTP_USER_AGENT, "MSIE")){
>    header("Location: http://www.mydomain.com/ie_page.php";)
> }
>
> etc...
>
> ?>
>
> <HTML>
> <HEAD>
> <TITLE>My Page</TITLE>
> </HEAD>
>
> etc..
>
>
> -----Original Message-----
> From: Michael [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 17, 2003 11:42 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Redirecting to index.php from index.html
>
> I'm a relative newbie to PHP coming from the Zope/Python/DTML world.
> Does
> anyone know of a good way, short of a javascript, to redirect from
> index.html
> to index.php.   Also, can I use PHP to test for browsers, then redirect
> them
> to the appropriate page.  In DTML/Python it would be :
>
> <dtml-if "_.string.find(HTTP_USER_AGENT, 'Mozilla/4') >= 0>
> <dtml-call "RESPONSE.redirect('moz4_page.php')">
> </dtml-if>
>
> This can be called from anywhere in the page.  I know that PHP does not
> work
> this way and that this would need to be done before <html>, but I'm even
>
> having problems with that.  I guess I'm just having a hard time THINKING
> like
> php.

-- 
Exasource Inc.
Web: http://www.exasource.com
Email: [EMAIL PROTECTED]
Phone: 970-206-4556

"The Israelite army looked at Goliath and said,  he's so big we can't 
 possibly win.  David looked at Goliath and said, wait a minute, he's 
 so big I can't possibly miss"

--- End Message ---
--- Begin Message ---
[snip]
If I use this on index.html, it does nothing.  If I use it on index.php
I get:

Parse error: parse error, unexpected '=' in 
/path/to/file_named/main.php on line 3

What am I doing wrong


On Tuesday 17 June 2003 02:11 pm, Ralph wrote:
> <?php
>
> if(strstr = ($HTTP_USER_AGENT, "Mozilla/4")){
>    header("Location: http://www.mydomain.com/moz4_page.php";)
> }
>
> elseif(strstr = ($HTTP_USER_AGENT, "MSIE")){
>    header("Location: http://www.mydomain.com/ie_page.php";)
> }
>
[/snip]


Shouldn't it  be ....
> if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
>    header("Location: http://www.mydomain.com/moz4_page.php";)
> }
>
> elseif(strstr($HTTP_USER_AGENT, "MSIE")){
>    header("Location: http://www.mydomain.com/ie_page.php";)
> }

HTH

--- End Message ---
--- Begin Message ---
With that I get:

Parse error: parse error, unexpected T_STRING in /path/to/file_named/main.php 
on line 4

Michael


On Tuesday 17 June 2003 02:50 pm, Jay Blanchard wrote:
> [snip]
> If I use this on index.html, it does nothing.  If I use it on index.php
> I get:
>
> Parse error: parse error, unexpected '=' in
> /path/to/file_named/main.php on line 3
>
> What am I doing wrong
>
> On Tuesday 17 June 2003 02:11 pm, Ralph wrote:
> > <?php
> >
> > if(strstr = ($HTTP_USER_AGENT, "Mozilla/4")){
> >    header("Location: http://www.mydomain.com/moz4_page.php";)
> > }
> >
> > elseif(strstr = ($HTTP_USER_AGENT, "MSIE")){
> >    header("Location: http://www.mydomain.com/ie_page.php";)
> > }
>
> [/snip]
>
>
> Shouldn't it  be ....
>
> > if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
> >    header("Location: http://www.mydomain.com/moz4_page.php";)
> > }
> >
> > elseif(strstr($HTTP_USER_AGENT, "MSIE")){
> >    header("Location: http://www.mydomain.com/ie_page.php";)
> > }
>
> HTH

-- 
Exasource Inc.
Web: http://www.exasource.com
Email: [EMAIL PROTECTED]
Phone: 970-206-4556

"The Israelite army looked at Goliath and said,  he's so big we can't 
 possibly win.  David looked at Goliath and said, wait a minute, he's 
 so big I can't possibly miss"

--- End Message ---
--- Begin Message ---
Oops. Typos. Try this:

if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
    header("Location: http://www.mydomain.com/moz4_page.php";);
}

elseif(strstr($HTTP_USER_AGENT, "MSIE")){
   header("Location: http://www.mydomain.com/ie_page.php";);
}

-----Original Message-----
From: Michael [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 17, 2003 1:12 PM
To: Jay Blanchard; Ralph; [EMAIL PROTECTED]
Subject: Re: [PHP] Redirecting to index.php from index.html

With that I get:

Parse error: parse error, unexpected T_STRING in
/path/to/file_named/main.php 
on line 4

Michael


On Tuesday 17 June 2003 02:50 pm, Jay Blanchard wrote:
> [snip]
> If I use this on index.html, it does nothing.  If I use it on
index.php
> I get:
>
> Parse error: parse error, unexpected '=' in
> /path/to/file_named/main.php on line 3
>
> What am I doing wrong
>
> On Tuesday 17 June 2003 02:11 pm, Ralph wrote:
> > <?php
> >
> > if(strstr = ($HTTP_USER_AGENT, "Mozilla/4")){
> >    header("Location: http://www.mydomain.com/moz4_page.php";)
> > }
> >
> > elseif(strstr = ($HTTP_USER_AGENT, "MSIE")){
> >    header("Location: http://www.mydomain.com/ie_page.php";)
> > }
>
> [/snip]
>
>
> Shouldn't it  be ....
>
> > if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
> >    header("Location: http://www.mydomain.com/moz4_page.php";)
> > }
> >
> > elseif(strstr($HTTP_USER_AGENT, "MSIE")){
> >    header("Location: http://www.mydomain.com/ie_page.php";)
> > }
>
> HTH

-- 
Exasource Inc.
Web: http://www.exasource.com
Email: [EMAIL PROTECTED]
Phone: 970-206-4556

"The Israelite army looked at Goliath and said,  he's so big we can't 
 possibly win.  David looked at Goliath and said, wait a minute, he's 
 so big I can't possibly miss"



--- End Message ---
--- Begin Message ---
Hello,


This is a reply to an e-mail that you wrote on Tue, 17 Jun 2003 at 22:27,
lines prefixed by '>' were originally written by you.
> Oops. Typos. Try this:
> if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
>     header("Location: http://www.mydomain.com/moz4_page.php";);
> elseif(strstr($HTTP_USER_AGENT, "MSIE")){
>    header("Location: http://www.mydomain.com/ie_page.php";);

This doesn't really matter as in this case the performance difference
wouldn't be noticable but I thought I would point out anyway...

On the strstr manual page it states:
"Note:  If you only want to determine if a particular needle  occurs
within haystack, use the faster and less memory intensive function
strpos() instead."

All the best,

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

          Professional Web Development by David Nicholson
                    http://www.djnicholson.com/

    QuizSender.com - How well do your friends actually know you?
                     http://www.quizsender.com/
                    (developed entirely in PHP)

--- End Message ---
--- Begin Message ---
Parse error: parse error, unexpected T_STRING in /path/to/file_named/main.php 
on line 4

Here is my actual code so you can look at it and see what I am doing 
something wrong.  I know I must be, since I don't see how php could become so 
popular for site development when it appears to be so difficult to do a 
simple test and redirect.  

It works fine in forms such as:

<input type="text" name="phrase" size="
        <?php
                if (strstr(getenv("HTTP_USER_AGENT"), "MSIE")) {
                        echo "50";
          } else {
                echo "35";
          }
        ?>
        " maxlength="50">

But I have yet to be able to do a redirect after a test.

index.html is a dhtml splash screen to allow time for image preloading.  It 
does not work on Opera or Konqueror.

<?

if(strstr($HTTP_USER_AGENT, "Opera")){
    header("Location: http://www.servantsmc.com/main.php";);
}

elseif(strstr($HTTP_USER_AGENT, "Konqueror")){
   header("Location: http://www.servantsmc.com/main.php";);
}

?>
<html>
<head>
<title>Motorcycle Clubs. Servants For Christ - Northern Colorado</title>
<meta name="generator" content="NEdit 5.1">


On Tuesday 17 June 2003 03:26 pm, Ralph wrote:
>Oops. Typos. Try this:

> if(strstr($HTTP_USER_AGENT, "Mozilla/4")){
>     header("Location: http://www.mydomain.com/moz4_page.php";);
> }
>
> elseif(strstr($HTTP_USER_AGENT, "MSIE")){
>    header("Location: http://www.mydomain.com/ie_page.php";);
> }


--- End Message ---
--- Begin Message ---
Well it does appear to be working because according to this error, the
problem is with main.php on line 4.

-----Original Message-----
From: Michael [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 17, 2003 2:27 PM
To: Ralph; 'Jay Blanchard'; [EMAIL PROTECTED]
Subject: Re: [PHP] Redirecting to index.php from index.html


Parse error: parse error, unexpected T_STRING in
/path/to/file_named/main.php 
on line 4

Here is my actual code so you can look at it and see what I am doing 
something wrong.  I know I must be, since I don't see how php could
become so 
popular for site development when it appears to be so difficult to do a 
simple test and redirect.  

It works fine in forms such as:

<input type="text" name="phrase" size="
        <?php
                if (strstr(getenv("HTTP_USER_AGENT"), "MSIE")) {
                        echo "50";
          } else {
                echo "35";
          }
        ?>
        " maxlength="50">

But I have yet to be able to do a redirect after a test.

index.html is a dhtml splash screen to allow time for image preloading.
It 
does not work on Opera or Konqueror.

<?

if(strstr($HTTP_USER_AGENT, "Opera")){
    header("Location: http://www.servantsmc.com/main.php";);
}

elseif(strstr($HTTP_USER_AGENT, "Konqueror")){
   header("Location: http://www.servantsmc.com/main.php";);
}

?>
<html>
<head>
<title>Motorcycle Clubs. Servants For Christ - Northern Colorado</title>
<meta name="generator" content="NEdit 5.1">


On Tuesday 17 June 2003 03:26 pm, Ralph wrote:




--- End Message ---
--- Begin Message ---
On Tue, 17 Jun 2003 12:41:34 -0600, you wrote:

>I'm a relative newbie to PHP coming from the Zope/Python/DTML world.  Does 
>anyone know of a good way, short of a javascript, to redirect from index.html 
>to index.php.   Also, can I use PHP to test for browsers, then redirect them 
>to the appropriate page.  In DTML/Python it would be :
>
><dtml-if "_.string.find(HTTP_USER_AGENT, 'Mozilla/4') >= 0>
><dtml-call "RESPONSE.redirect('moz4_page.php')">
></dtml-if>
>
>This can be called from anywhere in the page.  I know that PHP does not work 
>this way and that this would need to be done before <html>, but I'm even 
>having problems with that.  I guess I'm just having a hard time THINKING like 
>php.

I can understand that, I kick and scream when forced to think in DTML ('-'
in variable names? Turning the stack inside out? Blah).

Anyway... I suspect, as you're going from index.html -> index.php, you
actually want to add index.php as a Directory Index. Try adding this to your
httpd.conf file:

<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>

and now, /my/path/index.php will be called when you run
http://myhost.com/my/path/

(If I answered the wrong question, I apologise; forcing a redirect from a
pure HTML page will probably need Javascript or meta refresh.)

As to your other question.... yes, it's possible to use PHP to test for
incoming browsers, but it's not exactly good practice. Check
$HTTP_USER_AGENT.


--- End Message ---
--- Begin Message ---
Hello,

I'm wondering what the best way to go about this would be. I will be
opening a URL that outputs a csv. This csv will change every few minutes,
and I would like it to be refreshed on my page. I know I can use a meta
refresh, but the time will vary from 1-5 minutes, so a meta refresh will
have a gap where it won't be update.

Is there someway to hold it open, and when it changes refresh itself? This
is all on a LAN, so the traffic isn't that big of a deal.


Thanks,

        Bryan


--- End Message ---
--- Begin Message ---
PHP is server-side language, so this would be possible. Would go for meta tag 
or a javascript.


On Tue, 17 Jun 2003 22:18:56 +0200, Bryan Koschmann - Gkt wrote
(in message <[EMAIL PROTECTED]>):

> Hello,
> 
> I'm wondering what the best way to go about this would be. I will be
> opening a URL that outputs a csv. This csv will change every few minutes,
> and I would like it to be refreshed on my page. I know I can use a meta
> refresh, but the time will vary from 1-5 minutes, so a meta refresh will
> have a gap where it won't be update.
> 
> Is there someway to hold it open, and when it changes refresh itself? This
> is all on a LAN, so the traffic isn't that big of a deal.
> 
> 
> Thanks,
> 
>       Bryan
> 



--- End Message ---
--- Begin Message ---
On Tue, 17 Jun 2003, Terje Torkelsen wrote:

>
> PHP is server-side language, so this would be possible. Would go for meta tag
> or a javascript.


I know, but I thought I saw somewhere there was a way to do this using
flush() and something else, maybe for use with a progress bar type thing?

I know http is not an always open type protocol, but I still thought there
was a way. Meta refresh just won't work correctly..

Thanks,

        Bryan


> > I'm wondering what the best way to go about this would be. I will be
> > opening a URL that outputs a csv. This csv will change every few minutes,
> > and I would like it to be refreshed on my page. I know I can use a meta
> > refresh, but the time will vary from 1-5 minutes, so a meta refresh will
> > have a gap where it won't be update.
> >
> > Is there someway to hold it open, and when it changes refresh itself? This
> > is all on a LAN, so the traffic isn't that big of a deal.


--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 14:10, Bryan Koschmann - GKT wrote:
> On Tue, 17 Jun 2003, Terje Torkelsen wrote:
> 
> >
> > PHP is server-side language, so this would be possible. Would go for meta tag
> > or a javascript.
> 
> 
> I know, but I thought I saw somewhere there was a way to do this using
> flush() and something else, maybe for use with a progress bar type thing?
> 
> I know http is not an always open type protocol, but I still thought there
> was a way. Meta refresh just won't work correctly..
> 
> Thanks,

I think you're talking about server push. In general you can only use 
this with Netscape and Mozilla, but the page I link to below intimates
that you might be able to tie in with some Java or somesuch to make IE
do it too. Myself, I've never tried it, so YMMV. Anyway, do some
googling on 'server push' and check this out for a ready-made script:

  http://web.they.org/software/php-push.html


Good luck,

Torben


-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
Alternative, using concatenation:

$sql = "SELECT * FROM db WHERE apple = '". $_POST['foo'] . "'";

-----Original Message-----
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 17, 2003 7:57 AM
To: [EMAIL PROTECTED]; Chris Hayes
Subject: Re: [PHP] Re: Difference between $_POST[foo] and $_POST['foo']?

> At 16:19 17-6-03, you wrote:
> >$sql = 'select * from db where apple = \'' . $_POST['foo'] . '\';';
> >Like that?
> you missed some quotes:
> $sql = 'select * from db where apple = \''' . $_POST['foo'] . '\'"';

Go back and count the quotes again. The original post is correct as far
as
quotes go. Yours is not, though, since you have three single quotes in a
row
and have thrown in a double quote by itself.

Without color coding, this is all very hard to tell. That's why I prefer
to
do it such as:

$sql = "SELECT * FROM db WHERE apple = '{$_POST['foo']}' ";

or, like someone else said, the following is perfectly valid:

$sql = "SELECT * FROM db WHERE apple = '$_POST[foo]' ";

There are way to many methods to do this, though, so just use the one
that
makes the most sense to you. I've changed my mind about this a few times
in
the past. :)

---John Holmes...


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




--- End Message ---
--- Begin Message ---
This is explained in the manual with tons of examples:

  http://www.php.net/types.string
  http://www.php.net/types.array
  http://www.php.net/types.array#language.types.array.foo-bar

Regards,
Philip


--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 11:55, Logan McKinley wrote:
> right now if a the 'field' key does not exist at all in the querystring it
> returns the following error:
> Notice: Undefined index: Register in c:\inetpub\wwwroot\PHP\Register.php on
> line 3
> I think i can use the empty function but i pass in 11 different variables
> and it seems like there must be a more eligant way to prevent the error then
> with 11 individual if statements.  Is there a way in which it will return a
> value even if the key does not exist in the querystring.
> Thanks in advance,
> ~Logan

What you are seeing is the correct behaviour: since the variable has 
not been initialized, attempting to access it without checking it is
not good. Usually it's not much of an issue in PHP, though.

Anyway, one of the better ways to deal with it is to loop over your
input arrays and checking the values, something like this:

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);

$_acceptable_input = array('username', 'password', 'action');
$CHECKED_INPUT = array();
foreach ($_acceptable_input as $input_name) {
    // Use isset() instead of empty() so you get the blank inputs too.
    // Also, this would be an excellent place to do any input validation
    // as a first line of defence against poisoning attacks.
    if (isset($_GET[$input_name])) {
        $CHECKED_INPUT[$input_name] = $_GET[$input_name];
    } else {
        $CHECKED_INPUT[$input_name] = false;
    }
}

// Now you can use the expected ones without any errors since you know
// it's been tested for:
switch ($CHECKED_INPUT['action']) {
 case 'Log in':
     echo "Logging in with
{$CHECKED_INPUT['username']}/{$CHECKED_INPUT['password']}.\n";
     break;
 default:
     echo "Unknown action.\n";
     break;
}

?>

You could also just turn down error_reporting to skip the NOTICE-level
errors, but that's only really recommendable on a production box (where
you should probably have display_errors off too)...but on a development
server, hiding the problem is not likely to help in the long run. :)


Hope this helps,

Torben


-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 11:42, Thomas Bolioli wrote:
> The docs (see below) for bcmod() are rather skimpy. Does anyone have a 
> clue as to how it works. Basically I want to do this (below code). PS: I 
> am new to PHP but not to programming in general.
> Tom

Unless you're using arbitrary-precision math, the overhead of using
bcmod() is probably not worth it. In general you would just use
the modulus operator '%':

  http://www.php.net/manual/en/language.operators.arithmetic.php

bcmod(a, b) is the arbitrary-precision version of a % b;

At any rate, what is the code doing that you're not expecting?



Torben

> $i = 1;
> while (something true){
>      $modulus = the_modulus_of($i / 4); // does php do % instead of /?
>      if($modulus == 0){
>           do_this_this_time();
>      }
> $i++;
> }
> 
> *bcmod*
> 
> (PHP 3, PHP 4 )
> bcmod --  Get modulus of an arbitrary precision number
> Description
> string bcmod ( string left_operand, string modulus)
> 
> Get the modulus of the left_operand using modulus.


-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
They're escaped with backslashes. Weird thing is, I did make a Javascript
functions that converts every character to Unicode hex values preceded by %,
but for some magical reason, when I use rawurldecode on the string, the
apostrophes are still escaped! At the moment, this is beyond my grasp, but
I'll have to look over my code tomorrow and see how that can be...

"David Otton" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Tue, 17 Jun 2003 17:00:26 +0200, you wrote:
>
> >I'm embedding an SQL query constructed in Javascript to an URL and
opening
> >it in PHP where I try to execute it.
>
> I can't believe anyone hasn't jumped on this yet :)
>
> Please be very, very careful. There's a big big hole there.
>
> >Problem is, the string arrives garbled, with all the apostrophes escaped.
>
> Escaped how, exactly? With backslashes? Doubled apostrophes?
>
> The obvious thing would be a
>
> $query = str_replace("''", "'", $query);
>
> But again, please reconsider what you're doing - it sounds like you're
> trusting the client way too much. If you go ahead, ask on a
> database-specific mailing list about the holes you need to plug.
>



--- End Message ---
--- Begin Message ---
We are developing a site with the binarycloud platform,
which is completely object oriented with (sometimes)
large (deep) trees of objects.

Sometimes in the place where we need it, deep down, we
try to use print_r on the object tree, or subtree, and
the machine load average goes to the moon, and before
Apache can kill the child, everything locks, and a hard
reset is necessary.

Has anybody on this list ever tried to impliment a print_r
with an argument that specifies maximum depth of array
recursion?  This would be very useful in normal debugging
in any case, as most data structures don't go as deep
as ones we are using.

Anybody interested in this besides me?

_justin
-- 
Justin Farnsworth - Technical Director
Eye Integrated Communications
321 South Evans - Suite 203
Greenville, NC 27858 | Tel: (252) 353-0722

--- End Message ---
--- Begin Message ---
On Wednesday 18 June 2003 03:08, Mike Morton wrote:
> I have an application that I set the include directory using the ini_set
> (the application assumes that the client does not have access to the
> php.ini files).
>
> I can set the first include path of course:
> ini_set("include_path","/Library/WebServer/Documents/includes");
>
> But how do I set additional paths like in the ini file?  If I try to do
> another ini set, then it replaces the initial one, and I cannot seem to
> find any way to set more than one path in the initial ini_set above....

Separate multiple directories with a semi-colon?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
The greatest productive force is human selfishness.
                -- Robert Heinlein
*/


--- End Message ---
--- Begin Message ---
Ah ha - the semi colon does not work - but colon does - thanks Jason!



On 6/17/03 5:04 PM, "Jason Wong" <[EMAIL PROTECTED]> wrote:

> On Wednesday 18 June 2003 03:08, Mike Morton wrote:
>> I have an application that I set the include directory using the ini_set
>> (the application assumes that the client does not have access to the
>> php.ini files).
>> 
>> I can set the first include path of course:
>> ini_set("include_path","/Library/WebServer/Documents/includes");
>> 
>> But how do I set additional paths like in the ini file?  If I try to do
>> another ini set, then it replaces the initial one, and I cannot seem to
>> find any way to set more than one path in the initial ini_set above....
> 
> Separate multiple directories with a semi-colon?

--
Cheers

Mike Morton

****************************************************
*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*
****************************************************

"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine

Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey 


--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 12:08, Mike Morton wrote:
> I have an application that I set the include directory using the ini_set
> (the application assumes that the client does not have access to the php.ini
> files).
> 
> I can set the first include path of course:
> ini_set("include_path","/Library/WebServer/Documents/includes");
> 
> But how do I set additional paths like in the ini file?  If I try to do
> another ini set, then it replaces the initial one, and I cannot seem to find
> any way to set more than one path in the initial ini_set above....
> 
> Does anyone know how this can be done?  Thanks :)

Separate the paths with semicolons or colons depending on your OS. You
can also check existing values using ini_get() and modify based on
that. I like to use something like the following:

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);

function add_to_include_path($path) {
    $path = (string) $path;
    $existing_path = ini_get('include_path');
    if (false !== strpos($existing_path, $path)) {
        // Already in the path; exit.
        return true;
    }
    ini_set('include_path', $existing_path . ':' . $path);
    return true;
}

echo ini_get('include_path') . "\n";
add_to_include_path('/home/torben/bin');
echo ini_get('include_path') . "\n";
?>


Hope this helps,

Torben

-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
Try to these PHP development environment:

* Nusphere Studio
* Zend Studio
* Maguma Studio

hello all people in the PHP mailing list, bye. 




--- End Message ---
--- Begin Message ---
PHPCoder Pro is a very nice development enviroment as well
----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 11, 2003 8:22 PM
Subject: Fw: [PHP] php editor?


> Try to these PHP development environment:
> 
> * Nusphere Studio
> * Zend Studio
> * Maguma Studio
> 
> hello all people in the PHP mailing list, bye. 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


--- End Message ---
--- Begin Message ---
Hello friend, the problem is the "escape sequence",  tray this escape
sequence:  \"

Solution of the problem:

<?
 $data = "\"message\"";
 echo $data;
?>

bye, Orlando.


--- End Message ---
--- Begin Message --- Thank you for the responses re adding form elements. I will explore Javascript solutions. I've been working on a pure PHP solution - to avoid problems with older browsers - but kept running into roadblocks and wasn't sure I'd get through them. In any case most browsers no support Javascript! - Nelson


--- End Message ---
--- Begin Message ---
"Dvdmandt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Now, where did those two paragraphs come from? A bit of experience with
all
> those langs and the BASIC school... I'm at the age of 14 and don't even
know
> math yet so (I mean, I know +, -, / and *, but not advanced stuff)...


"functional programming" is based around the idea
that subroutines should have no side effects - all
the information a subroutine needs should be passed
as parameters, and its results should be returned.
Further, a function called with the same set of parameters
should always return the same result.

The original basis for this was that it made
program analysis much simpler; however, it
was found to be useful in practice as well for
a number of reasons:

- it was a means of enforcing variable scope
  (essentially, all variables are local),

- it promotes much simpler functions and
  more reuse.

- it can allow much more extreme compiler
  optimizations


While the functional programming philosophy
can be applied in most programming languages,
some of the languages I mentioned do a better
job of making its usefulness obvious.

For more info, see some of the links at
http://directory.google.com/Top/Computers/Programming/Languages/Functional/


--
Hugh Bothwell     [EMAIL PROTECTED]     Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b++++ DI+++ D-(++) G+ e(++) h-- r- y+




--- End Message ---
--- Begin Message ---
But i think that it should stop after 30 secondes no ?

Yann

On Tue, 2003-06-17 at 22:35, R'twick Niceorgaw wrote:
> doesn't sound like a bug to me ... after all there's something called
> recursive functions ?
> 
> ----- Original Message ----- 
> From: "Yann Larrivee" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 17, 2003 6:18 AM
> Subject: [PHP] max_execution_time
> 
> 
> > Hi, i made a major programing mistake this mornning. It probably helped
> > me to figure out a bug in PHP 5. But i would like to confirme with more
> > people...
> >
> > class MyClass{
> > public MylClass(){
> > $this->MyFunc();
> > }
> >
> > private MyFunc(){
> > $this->MyFunc();
> > }
> > }
> >
> > Avisously this loops indefinitly :)
> >
> > But the script never ended will i this it should have been right ?
> >
> > I haven't seen any bug reports for PHP5 but anybody have experienced
> > this issu befor ?
> >
> > Thanks
> >
> >
> >
> >
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 



--- End Message ---
--- Begin Message ---
Hello,

Would be grateful if someone couldkindly point me in the right direction.

Whenever I try to connect to mysql server, I get these messsage back

1.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>

2.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>

what could be wrong. Help please .

Regards

Moses


--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 17:13, [EMAIL PROTECTED] wrote:
> Hello,
> 
> Would be grateful if someone couldkindly point me in the right direction.

Check the MySQL documentation. You also might want to ask on the MySQL
mailing list.

  http://www.mysql.com/doc/en/Default_privileges.html
  http://www.mysql.com/doc/en/Access_denied.html

It appears, however, that mysqld is not recognizing the authority of
whoever you're connected as to modify the grant tables. Try connecting
as the admin user.


Good luck,

Torben

> Whenever I try to connect to mysql server, I get these messsage back
> 
> 1.
> mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
> 
> 2.
> mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
> 
> what could be wrong. Help please .
> 
> Regards
> 
> Moses
-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
Hello, This seems not to be working, I am using win2000 and a newbie. please simplify 
this process.

ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql> GRANT ALL PRIVILEGES ON *.* TO [EMAIL PROTECTED]
    -> IDENTIFIED BY 'cludiana' WITH GRANT OPTION;
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>

Regards




>  from:    Lars Torben Wilson <[EMAIL PROTECTED]>
>  date:    Wed, 18 Jun 2003 01:17:15
>  to:      [EMAIL PROTECTED]
>  cc:      [EMAIL PROTECTED]
>  subject: Re: [PHP] MySQL Connection
> 
> On Tue, 2003-06-17 at 17:13, [EMAIL PROTECTED] wrote:
> > Hello,
> > 
> > Would be grateful if someone couldkindly point me in the right direction.
> 
> Check the MySQL documentation. You also might want to ask on the MySQL
> mailing list.
> 
>   http://www.mysql.com/doc/en/Default_privileges.html
>   http://www.mysql.com/doc/en/Access_denied.html
> 
> It appears, however, that mysqld is not recognizing the authority of
> whoever you're connected as to modify the grant tables. Try connecting
> as the admin user.
> 
> 
> Good luck,
> 
> Torben
> 
> > Whenever I try to connect to mysql server, I get these messsage back
> > 
> > 1.
> > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> > mysql>
> > 
> > 2.
> > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> > mysql>
> > 
> > what could be wrong. Help please .
> > 
> > Regards
> > 
> > Moses
> -- 
>  Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
>  http://www.thebuttlesschaps.com          http://www.inflatableeye.com
>  http://www.hybrid17.com                  http://www.themainonmain.com
>  -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----
> 
> 
> 


--- End Message ---
--- Begin Message ---
this is a mysql specific question

i think u have to go flush privileges;

after you do that
> Hello, This seems not to be working, I am using win2000 and a newbie.
> please simplify this process.
>
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql> GRANT ALL PRIVILEGES ON *.* TO [EMAIL PROTECTED]
>    -> IDENTIFIED BY 'cludiana' WITH GRANT OPTION;
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
>
> Regards
>
>
>
>
>>  from:    Lars Torben Wilson <[EMAIL PROTECTED]>
>>  date:    Wed, 18 Jun 2003 01:17:15
>>  to:      [EMAIL PROTECTED]
>>  cc:      [EMAIL PROTECTED]
>>  subject: Re: [PHP] MySQL Connection
>>
>> On Tue, 2003-06-17 at 17:13, [EMAIL PROTECTED] wrote:
>> > Hello,
>> >
>> > Would be grateful if someone couldkindly point me in the right
>> > direction.
>>
>> Check the MySQL documentation. You also might want to ask on the MySQL
>> mailing list.
>>
>>   http://www.mysql.com/doc/en/Default_privileges.html
>>   http://www.mysql.com/doc/en/Access_denied.html
>>
>> It appears, however, that mysqld is not recognizing the authority of
>> whoever you're connected as to modify the grant tables. Try connecting
>> as the admin user.
>>
>>
>> Good luck,
>>
>> Torben
>>
>> > Whenever I try to connect to mysql server, I get these messsage back
>> >
>> > 1.
>> > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY
>> > "cludiana"; ERROR 1045: Access denied for user: '@127.0.0.1' (Using
>> > password: NO) mysql>
>> >
>> > 2.
>> > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY
>> > "cludiana"; ERROR 1045: Access denied for user: '@127.0.0.1' (Using
>> > password: NO) mysql>
>> >
>> > what could be wrong. Help please .
>> >
>> > Regards
>> >
>> > Moses
>> --
>>  Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
>>  http://www.thebuttlesschaps.com          http://www.inflatableeye.com
>>  http://www.hybrid17.com                  http://www.themainonmain.com
>>  -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----
>>
>>
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
On Tue, 2003-06-17 at 18:19, [EMAIL PROTECTED] wrote:
> Hello, This seems not to be working, I am using win2000 and a newbie. please 
> simplify this process.
> 
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql> GRANT ALL PRIVILEGES ON *.* TO [EMAIL PROTECTED]
>     -> IDENTIFIED BY 'cludiana' WITH GRANT OPTION;
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
> 
> Regards

You've read the MySQL documentation, right? If not, do so. Trust me.
You'll need it. Right now it looks like you need this section:

  http://www.mysql.com/doc/en/General_security.html

Also, I was serious when I suggested asking on the MySQL mailing list.
This list is for PHP.

Finally, when you do ask, be sure to provide some more information. You
need to tell them what you've done so far, where on the network the
database server is, and your username when logged in.


Good luck,

Torben

-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +1.604.709.0506
 http://www.thebuttlesschaps.com          http://www.inflatableeye.com
 http://www.hybrid17.com                  http://www.themainonmain.com
 -----==== Boycott Starbucks!  http://www.haidabuckscafe.com ====-----




--- End Message ---
--- Begin Message ---
I'm using the "ORDER BY RAND() LIMIT 0,1" to give be a random record from a
recordset but it seems like it puts a real heavy load on the server. Is
there a better way to pull a random record from a database?

Thanks



--- End Message ---
--- Begin Message ---
> I'm using the "ORDER BY RAND() LIMIT 0,1" to give be a random record from a
> recordset but it seems like it puts a real heavy load on the server. Is
> there a better way to pull a random record from a database?

I used order by rand() with MySQL quite often and do not notice any load issues 
with it.  What's your whole query look like?


-- 
Greg Donald
http://destiney.com/



--- End Message ---
--- Begin Message ---
Here it is:

SELECT penpals.username, penpals.zoneid, penpals_photos.album,
penpals_photos.rating, zones.zone_id, zones.zone_code,
penpals_photos.filename, penpals.city
FROM penpals, penpals_photos, zones
WHERE penpals.username = penpals_photos.album AND penpals_photos.rating !=
'X' AND penpals.zoneid = zones.zone_id
ORDER BY RAND() LIMIT 0,1



--- End Message ---
--- Begin Message ---
> Here it is:
> 
> SELECT penpals.username, penpals.zoneid, penpals_photos.album,
> penpals_photos.rating, zones.zone_id, zones.zone_code,
> penpals_photos.filename, penpals.city
> FROM penpals, penpals_photos, zones
> WHERE penpals.username = penpals_photos.album AND penpals_photos.rating !=
> 'X' AND penpals.zoneid = zones.zone_id
> ORDER BY RAND() LIMIT 0,1

If it's the username that is to be random, I'd grab it first then go get all 
the other data with a second query.  If that is undesirable for whatever reason 
then I'd use left joins so as to select much less data.

As an aside, limit 0,1 is the same as limit 1.


-- 
Greg Donald
http://destiney.com/



--- End Message ---
--- Begin Message ---
Hi,
I'm newbie in PHP and tried to install webmail appliction on PHP engine.
That webmail require a module IMAP,but my engine haven't have it yet. I
tried to put a "extenstion = imap.so" in php.ini. But, the application still
can't detect this module. Can I add php module without recompile PHP source.

Thanks in advance,
Skon L.





--- End Message ---
--- Begin Message ---
Hi,
I installed v-webmail on the PHP engine to enable web mail client access.
Every installation step was going well. But, I found a problem when the
application was using for awhile. My webmail can display the login page, but
when I entered login/password and press submit. I got an error display that
'can't find server' and there was no PHP error displaying. But, there was a
'Exit segmentation fault (11)" error in httpd log file, everytime I press
submit button in login page.  I tried to put a debug line to determine the
statement that cause the error, but very difficult to do.

Does PHP has any directive or command to debug a code or print all
success/unsuccess line execution. I can't modify php.ini or httpd.conf,
because that server is not mine (I use a hosting service from ISP).

Thanks in advance,
Skon L.




--- End Message ---
--- Begin Message ---
I have been very happy with Zentrifugal. com.  They let you host multiple
domains for $99 per year.  You can have up to 10 sub-domains, 10 parked
domains and 10 add-on domains.  All these additional domains share the same
account resources.  My problem with other hosting companies has always been
the very limited number of MySQL databases.  With Zentrifugal, I get 20
databases - which is plenty for "play" and "real" sites.  Support has been
pretty good too.  I had problems with the webmail configuration, but they
were answered pretty quickly.

C O R N E L I U S   E N G E L B R E C H T
Webmaster for HomeCatalyst.com
"Making Home Ownership Affordable"
Forums Devoted to Housing Mortgage & Insurance
[EMAIL PROTECTED]
http://www.homecatalyst.com


----- Original Message -----
From: Awlad Hussain <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 5:10 AM
Subject: [PHP] Good Hosting company


anyone knows any good cheap hosting company in UK/US?? with good support.

Many thanks

awlad



--- End Message ---
--- Begin Message ---
On 17-Jun-2003 Ron Dyck wrote:
> I need to match text between two html comment tags.
> 
> I'm using: preg_match("/<!--start_tag-->(.*)<!--end_tag-->/", $data,
> $Match)
> 
> Which work fine until I have carriage returns. The following doesn't
> match:
> 

Use the m (multiline) modifier:

preg_match("/<!--start_tag-->(.*)<!--end_tag-->/m", ...

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
                           

--- End Message ---
--- Begin Message ---
Create a string which is six char long,
(for instance shop the head and tail
of the first string if you are not able
to generate a six char string)

If you chop an 8 char string and MUST have
the special chars in the string then check
that the chopped char's is not a memember of
the special char's- If they are, regenerate a
new string an loop until they are not

Finally randomize the head and the tail with
you "custom" algorithm. E.g. an algoritm that
does not contain your 


Med vanliga halsningar fran Amsterdam. =) ;)


-----Original Message-----
From: Davy Obdam
To: PHP; PHP-WIN; PHP-DB
Sent: 2003-06-17 11:45
Subject: [PHP-WIN] Password generator

Hi people,

I have to make a password generator, but i have a little problem.

- It needs to generate password 8 characters long, and including 1 or 2 
special characters(like #$%&*@).
- Those special characters can never appear as the first or last 
character in the string... anywhere between is fine.

I have a password generator script now that does the first thing... but 
the special character can be in front or back of the string wich it 
shouldnt.. i have been looking on the web for this but i havent found 
the answer. Below is my scripts so far.. 

Any help is appreciated, thanks for your time,

Best regards,

Davy Obdam

------------------------------------------------------------------------
----------------------------------------

<?php
// A function to generate random alphanumeric passwords in PHP
// It expects to be passed a desired password length, but it
// none is passed the default is set to 8 (you can change this)
function generate_password($length = 8) {

    // This variable contains the list of allowable characters
    // for the password.  Note that the number 0 and the letter
    // 'O' have been removed to avoid confusion between the two.
    // The same is true of 'I' and 1
    $allowable_characters =
"abcdefghefghijklmnopqrstuvwxyz0123456789%#*&";
   
    // We see how many characters are in the allowable list
    $ps_len = strlen($allowable_characters);

    // Seed the random number generator with the microtime stamp
    // (current UNIX timestamp, but in microseconds)
    mt_srand((double)microtime()*1000000);

    // Declare the password as a blank string.
    $pass = "";

    // Loop the number of times specified by $length
    for($i = 0; $i < $length; $i++) {
   
        // Each iteration, pick a random character from the
        // allowable string and append it to the password.
        $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
   
    }

    // Retun the password we've selected
    return $pass;
}

$password = generate_password();
echo $password;

?>

-- 
-----------------------------------------------------------------------
Davy Obdam 
Web application developer

Networking4all
email: [EMAIL PROTECTED]
email: [EMAIL PROTECTED]
internet: http://www.networking4all.com
-----------------------------------------------------------------------




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

--- End Message ---

Reply via email to