php-general Digest 16 Mar 2003 22:03:33 -0000 Issue 1942

Topics (messages 139834 through 139872):

FOPEN and EREG not working
        139834 by: Monil Chheda

passing values from one script to another script
        139835 by: Chinmoy Barua
        139837 by: Alan McFarlane
        139843 by: Marek Kilimajer

Re: Include() in included file
        139836 by: Veniamin Goldin

Re: Re Sessionid
        139838 by: Peter Goggin
        139839 by: Ernest E Vogelsinger

Re: replace string in array
        139840 by: Jan Grafström

permission problem - i guess
        139841 by: gamin
        139842 by: Marek Kilimajer
        139845 by: gamin
        139848 by: Marek Kilimajer
        139853 by: gamin

Re: Do query strings get spidered by Google?
        139844 by: -{ Rene Brehmer }-
        139849 by: Robert Cummings

simple arithmetic problem
        139846 by: pei_world
        139850 by: Marek Kilimajer

Re: group by get last record
        139847 by: Don Read

HTTP_REFERER reliability
        139851 by: rotsky
        139852 by: Dan Hardiker
        139854 by: Marek Kilimajer
        139863 by: Leif K-Brooks

building a large-scale application using oop
        139855 by: raulrod.gmx.de
        139857 by: Charles Kline
        139859 by: daniel

Scrolling through values sent from a form
        139856 by: shaun

mail(); works, but only for mails to my (mail)server
        139858 by: Manuel Glauser

Function/globalizing
        139860 by: Liam Gibbs
        139861 by: Joel Colombo

Arrays
        139862 by: John Taylor-Johnston

Re: List tables
        139864 by: daniel

OpenBSD 3.2 PHP 4.2.3 packages
        139865 by: Bob Eldred

Re: ignore html
        139866 by: daniel

writing to file count multiple impression..
        139867 by: WebDev

using strcmp()
        139868 by: Anthony Ritter
        139869 by: LinuxGeek
        139870 by: Justin Garrett
        139871 by: Leif K-Brooks

multi-d array frustration
        139872 by: Michael Geier

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 ---
Hi,

I need to get some details from a LOG file as to which
keywords are used...

I have attached the LOG file.

I heed the details of the following:-

1. Ip Address
2. Date
3. The page that was requested
4. KeyWords used by the Search Engine [ Google / Yahoo
seperated ]
(ordered BY DATE) in a tabular FORMAT

I am using the following CODE.. But , it doesnt work

<?php

$flag = "false";

if ($fp = fopen("web.log","r")) {

        while (!feof($fp)) {

                $line = fgets($fp,1024);

                if (ereg("\$",$line)) {
                           $flag="false";
                        }
                if ($flag=="true") {
                        $linearray = explode(" ",$line);
                        $ip = $linearray[0];
                        $date = $linearray[1];
                        $keywords = $linearray[2];
                        echo "$ip    $date      $keyowrds";
                        }
                if (ereg("\^",$line)) {
                          $flag = "true";
                                }

     } 
 } else {
     echo "Could not open file";
 }

?>


Could any one please help me 

Thanks...

-Monil Chheda
http://services.eliteral.com

=====
Best Regards,
Monil Chheda(INDIA)
http://domains.eliteral.com
===========================
===========================

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

Attachment: web.zip
Description: web.zip


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

I want to pass a value, which came from a HTML form, to another PHP script. How can i 
do this?

e.g.: $login - the value of this varriable is came from LOGIN.HTML to LOGIN.PHP. How 
can i pass the value of $login from LOGIN.PHP to PROCESS.PHP?

Thank you,

Chinmoy



---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online

--- End Message ---
--- Begin Message ---
Have a look at the $_POST super global variable documentation.



"Chinmoy Barua" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Hello everybody,
>
> I want to pass a value, which came from a HTML form, to another PHP
script. How can i do this?
>
> e.g.: $login - the value of this varriable is came from LOGIN.HTML to
LOGIN.PHP. How can i pass the value of $login from LOGIN.PHP to PROCESS.PHP?
>
> Thank you,
>
> Chinmoy
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online



--- End Message ---
--- Begin Message --- Either use session, cookies, or pass the value in URLs. Because it is login information, I would choose session or cookie

Chinmoy Barua wrote:

Hello everybody,

I want to pass a value, which came from a HTML form, to another PHP script. How can i do this?

e.g.: $login - the value of this varriable is came from LOGIN.HTML to LOGIN.PHP. How can i pass the value of $login from LOGIN.PHP to PROCESS.PHP?

Thank you,

Chinmoy



---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online




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

Check if there display_errors in your php.ini is set to Yes,
and also take a look at your apache error log when you execute this
page, probably you will see an error there.



Best regards,
Veniamin Goldin
Interlogics, Inc.

Вы писали 15 марта 2003 г., 12:34:35:

HK> Hello all!

HK> In index.php I include a file template.php using

HK> <?php
HK> // this is index.php file
HK> include('template.php');
?>>

HK> Works fine. In template.php I'm using include function too

HK> <?php
HK> // this is template.php file
HK> echo 'before include';
HK> include('header.php');
HK> echo 'after include';
?>>

HK> Works fine on all machines I installed it till now: Windows (NT, 98), Linux
HK> (some of them). But I installed it on FreeBSD and... surprise. When I call
HK> index.php, all I get is "before include". No header.php content, no "after
HK> include" phrase. And there is no warning or error message. Has anybody got
HK> an idea what is wrong? Cheers,

HK>     Hubi






-- 
С уважением,
 Veniamin 
 [EMAIL PROTECTED]



--- End Message ---
--- Begin Message ---
Is the value returned by session_id (), called after session_star() always a
unique string?
The results of several trials gave me:
6f88d2d3fd7d0d47aea1e45087368adc
3cc2c1b299fcaa6f4fd107683d78a00c
115e8da118af1c5d88d6db1c1481077a
26dda220f9d64de593ce2f2de6b4bb6e
26dda220f9d64de593ce2f2de6b4bb6e

i.e. every time i started a new session I got a unique string, while the
string remained the sme within the same session.

How is this string derived?

Regards

Peter Goggin


--- End Message ---
--- Begin Message ---
At 14:20 16.03.2003, Peter Goggin said:
--------------------[snip]--------------------
>Is the value returned by session_id (), called after session_star() always a
>unique string?
>The results of several trials gave me:
>6f88d2d3fd7d0d47aea1e45087368adc
>3cc2c1b299fcaa6f4fd107683d78a00c
>115e8da118af1c5d88d6db1c1481077a
>26dda220f9d64de593ce2f2de6b4bb6e
>26dda220f9d64de593ce2f2de6b4bb6e
>
>i.e. every time i started a new session I got a unique string, while the
>string remained the sme within the same session.
--------------------[snip]-------------------- 

That's exactly how it should be. The session ID is the unique key to the
session private data, and is passed between client and server either via
cookie, or via request parameter, whatever is necessary (PHP can determine
this automatically).

The key is supposed to be unique on a single server. It is derived by
calculating a random value, starting with the current systems sec/usec, and
a random number. If an external entropy source is available the resulting
ID is further randomized using this entropy. Finally it is converted to a
hex string. (If you're interested in the actual code to accomplish this,
you may find it in {php_source_directory}/ext/session.c, _php_create_id(),
and {php_source_directory}/ext/standard/lcg.c, php_combined_lcg()).


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



--- End Message ---
--- Begin Message ---
Chris,

you can splice an array
http://www.php.net/manual/sv/function.array-splice.php

Jan Grafstrom



"Chris Winters" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I'm having a bit of trouble...
>
> I have an array that consists of a string like this:
>
> string1\rstring2\rstring3\rstring4
>
> I want to REMOVE STRING3, and keep the rest of the array intact - but
cannot
> figure on how to do it. I tried using functions such as preg_replace,
strstr
> and so forth...
>
> In my code this is how I go thru the array...
>
> //snippet...
>
> //search for carriage return, split it...
>  $line = preg_split( "/[\r]+/" ,$line);
>  reset($line);
>
> //Line will consists of array...
>     while (list ($key, $val) = each ($line))
>      {
>        echo "<br>$key => $val";
>
>        if(strstr($val,$newmail))
>         {
>           echo "<br>Found! and trying to delete....<br>";
>          //What to do form this point, I have the slightest foggy...
>         }
>     }
>
> It finds it without ANY problems, but I cannot seem to "go" to the
position
> of found string, delete it, then keep the rest of the array.
> I did manage to find this on php.net, but it doesnt seem to work:
> function stri_replace2 ($search,$replace,$text)
> {
>    if (!is_array($search))
>     {
>       $search = array($search);
>       $replace = array($replace);
>     }
>      foreach($search AS $key => $val)
>       {
>         $search["$key"]  = '/'.quotemeta($val).'/i';
>       }
>         echo "$search $replace $text";
>
>    return preg_replace($search,$replace,$text);
> }
>
> Could anyone help me with this?
>
> Thanks in advanced!
>
> Chris
>
>
>



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

    I have PHP 4.3.0 installed on a Red Hat system. I have written a number
of command line scripts which run perfectly fine. For example

<u.php>
#! /usr/bin/php -q
<?
$conn = mysql_connect($host, $user, $pass)
    or die('cannot connect');

// do my stuff
?>
</u.php>

This script works perfectly fine, when started from the command line. Now i
intend to call this command line script from another another script (that is
called from the browser). for example -

< /var/www/html/test.php >
<?
$script = '/usr/local/bin/u.php';
$response = `{$script}`;
echo $response;
?>
</ /var/www/html/test.php >

This generates an error ' Fatal error : Call to undefined function:
mysql_connect() in /usr/local/bin/u.php on line 3'

phpinfo gives me the following cofigure command

'./configure' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin'
'--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share'
'--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec'
'--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc'
'--disable-debug' '--with-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-gd' '--with-gdbm' '--with-gettext'
'--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png'
'--with-regex=system' '--with-ttf' '--with-xml' '--with-expat-dir=/usr'
'--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-debugger'
'--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode'
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm'
'--enable-track-vars' '--enable-yp' '--enable-wddx' '--with-ldap=shared'
'--with-mysql=shared' '--with-apxs=/usr/sbin/apxs'

Thank you to all

With regrads

gamin






--- End Message ---
--- Begin Message --- Try executing phpinfo from u.php, run it once from the command line and once from the browser and check if they are nay different.

gamin wrote:

Hi,

   I have PHP 4.3.0 installed on a Red Hat system. I have written a number
of command line scripts which run perfectly fine. For example

<u.php>
#! /usr/bin/php -q
<?
$conn = mysql_connect($host, $user, $pass)
   or die('cannot connect');

// do my stuff
?>
</u.php>

This script works perfectly fine, when started from the command line. Now i
intend to call this command line script from another another script (that is
called from the browser). for example -

< /var/www/html/test.php >
<?
$script = '/usr/local/bin/u.php';
$response = `{$script}`;
echo $response;
?>
</ /var/www/html/test.php >

This generates an error ' Fatal error : Call to undefined function:
mysql_connect() in /usr/local/bin/u.php on line 3'

phpinfo gives me the following cofigure command

'./configure' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin'
'--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share'
'--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec'
'--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc'
'--disable-debug' '--with-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-gd' '--with-gdbm' '--with-gettext'
'--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png'
'--with-regex=system' '--with-ttf' '--with-xml' '--with-expat-dir=/usr'
'--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-debugger'
'--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode'
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm'
'--enable-track-vars' '--enable-yp' '--enable-wddx' '--with-ldap=shared'
'--with-mysql=shared' '--with-apxs=/usr/sbin/apxs'

Thank you to all

With regrads

gamin










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

> Try executing phpinfo from u.php, run it once from the command line and
> once from the browser and check if they are nay different.
>

I added the function phpinfo() to u.php and ran u.php from the commandline
and then backticked `` it in test.php and called test.php from the browser.

The configure commands (commandline u.php and browser test.php) for both are
identical. but the result in the browser (test.php that executes u.php
internally) there is no mention of the section on 'mysql'. The following
section is non existant in the browser. Im stumped !!


<--- this is from phpinfo() [u.php] executed from command line ---->
mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 3.23.49
MYSQL_MODULE_TYPE => builtin
MYSQL_SOCKET => /var/lib/mysql/mysql.sock
MYSQL_INCLUDE =>  MYSQL_LIBS =>
Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.connect_timeout => -1 => -1
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => no value => no value
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off

Thank you and regards

gamin.



--- End Message ---
--- Begin Message --- Weird, check if both versions use the same php.ini, it is mentioned in phpinfo output.

gamin wrote:

Hi Marek,



Try executing phpinfo from u.php, run it once from the command line and
once from the browser and check if they are nay different.




I added the function phpinfo() to u.php and ran u.php from the commandline and then backticked `` it in test.php and called test.php from the browser.

The configure commands (commandline u.php and browser test.php) for both are
identical. but the result in the browser (test.php that executes u.php
internally) there is no mention of the section on 'mysql'. The following
section is non existant in the browser. Im stumped !!


<--- this is from phpinfo() [u.php] executed from command line ----> mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 3.23.49
MYSQL_MODULE_TYPE => builtin
MYSQL_SOCKET => /var/lib/mysql/mysql.sock
MYSQL_INCLUDE =>  MYSQL_LIBS =>
Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.connect_timeout => -1 => -1
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => no value => no value
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off

Thank you and regards

gamin.







--- End Message ---
--- Begin Message ---
> Weird, check if both versions use the same php.ini, it is mentioned in
> phpinfo output.
>

Yes, they both point to /etc/php.ini

Do you want me to paste the contents of the 2 files here ? they are a little
long so i'm asking

gamin



--- End Message ---
--- Begin Message ---
Judging from how Google has indexed my site, it simply follows all links
it encounters on the site, since I atleast can find several of my pages
that are a bunch of links deep inside the site...

Rene

On Sat, 15 Mar 2003 10:26:05 -0700, Mike Hillyer wrote about "[PHP] Do
query strings get spidered by Google?" what the universal translator
turned into this:

>I am trying to decide how to lay out a site with a lot of articles, and I am
>wondering if query strings get spidered by Google. I was thinking it would
>make for an easy search engine if I could put the articles in fulltext
>searchable MySQL columns, but I do not want to lose the ability of search
>engines to spider them. Otherwise, I believe there is a way to convert the
>quert string to a trailing / so it looks like directory structure, does
>anyone have info on that?

-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

--- End Message ---
--- Begin Message ---
I don't think Google follows URLS to every variation based on a query string.
I know to have some of my pages indexed I had to rewrite the URL so the query
string looked like a directory path.

Cheers,
Rob.

-{ Rene Brehmer }- wrote:
> 
> Judging from how Google has indexed my site, it simply follows all links
> it encounters on the site, since I atleast can find several of my pages
> that are a bunch of links deep inside the site...
> 
> Rene
> 
> On Sat, 15 Mar 2003 10:26:05 -0700, Mike Hillyer wrote about "[PHP] Do
> query strings get spidered by Google?" what the universal translator
> turned into this:
> 
> >I am trying to decide how to lay out a site with a lot of articles, and I am
> >wondering if query strings get spidered by Google. I was thinking it would
> >make for an easy search engine if I could put the articles in fulltext
> >searchable MySQL columns, but I do not want to lose the ability of search
> >engines to spider them. Otherwise, I believe there is a way to convert the
> >quert string to a trailing / so it looks like directory structure, does
> >anyone have info on that?
> 
> --
> Rene Brehmer
> 
> This message was written on 100% recycled spam.
> 
> Come see! My brand new site is now online!
> http://www.metalbunny.net
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org   |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the  |
| stuff of nightmares grasp for your soul.    |
`---------------------------------------------'

--- End Message ---
--- Begin Message ---
 I have a problem in time substraction.
the number print out correct, but don't know
why i cann't do the substraction between them
=======================================
    echo (time()).">><br>";
    echo (fgets($fp))." = <br>";
    $new=time();
    $old=fgets($fp);
    echo ">>>".($new - $old)."<<<<br>";

ouput ======================================

1047832384>>
1047832349 =
>>>1047832384<<<


--
Sincerely your;

pei_world ( .::IT::. )






--- End Message ---
--- Begin Message --- fgets moves the position in the file pointer, you need

echo (time()).">><br>";
$old=fgets($fp);
echo $old." = <br>";
$new=time();
echo ">>>".($new - $old)."<<<<br>";



pei_world wrote:

I have a problem in time substraction.
the number print out correct, but don't know
why i cann't do the substraction between them
=======================================
   echo (time()).">><br>";
   echo (fgets($fp))." = <br>";
   $new=time();
   $old=fgets($fp);
   echo ">>>".($new - $old)."<<<<br>";

ouput ======================================

1047832384>>
1047832349 =


1047832384<<<




--
Sincerely your;

pei_world ( .::IT::. )










--- End Message ---
--- Begin Message ---
<db list removed>
On 16-Mar-2003 Daniel Harik wrote:
> Hello,
> 
> Guys i try to join to tables
> 
> slides:
> id
> userid
> file
> moment
> 
> users
> id
> username
> 
> As there few slids per user and i want to get only last one, i use
> following 
> sql query, but it fetches me first slide. How can i make it fetch last
> one 
> please?
> 
>  SELECT slides.file, slides.moment, users.id, users.username FROM slides,
> users where users.id=slides.userid GROUP BY users.id desc 
> 

Which record is 'last' ?
There is no order to the records without an 'ORDER BY' clause.

If you figure that out, you can use a temporary table with all the
desired fields and with the userid as primary key. 
Then do  'REPLACE INTO temptbl SELECT ... ORDER BY whatever'.
And finally do a 'SELECT * FROM temptbl'

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 ---
I have a small login form on the home page of my site. At the moment, when
people enter their user details and hit 'send', they go to another page
which check their details and, if they are successful, prints a welcome
message. The problem is, they are now on this page and have to work their
way back to the home page. I can provide a link for this, of course, but
that limits the number of pages that can have such a login panel, because I
have to hand-code the return link.

I've experimented using $_SERVER['HTTP_REFERER'] which seems to work here.
If the user enters valid login details, the session vars are set and they
are bounced automatically back to the original page - which is fab. But the
manual says that HTTP_REFERER is unreliable, so I'm intrigued to know
exactly what the problems are. Any ideas?



--- End Message ---
--- Begin Message ---
> But the manual says that HTTP_REFERER is unreliable, so I'm
> intrigued to know exactly what the problems are. Any ideas?

The HTTP_REFERER field is retrieved from the "HTTP Referer:" header as
used in the HTTP protocol. This field is set entirely by the client
browser / application retrieving the data. There is nothing to stop the
client from adding malformed, incorrect or spoof data into this field -
and thus possibly faking entry to the data you are protecting.

You cannot rely on this field to be accurate, correct or even populated.


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software & Systems Engineer
First Creative


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software & Systems Engineer
First Creative



--- End Message ---
--- Begin Message --- As you are already using sessions, you can store the original page in a session variable

rotsky wrote:

I have a small login form on the home page of my site. At the moment, when
people enter their user details and hit 'send', they go to another page
which check their details and, if they are successful, prints a welcome
message. The problem is, they are now on this page and have to work their
way back to the home page. I can provide a link for this, of course, but
that limits the number of pages that can have such a login panel, because I
have to hand-code the return link.

I've experimented using $_SERVER['HTTP_REFERER'] which seems to work here.
If the user enters valid login details, the session vars are set and they
are bounced automatically back to the original page - which is fab. But the
manual says that HTTP_REFERER is unreliable, so I'm intrigued to know
exactly what the problems are. Any ideas?







--- End Message ---
--- Begin Message --- Anyone can send any referer (sic) header to your script. It shouldn't be used for checking if someone is trying to hack the script, but it should be find in your case.

rotsky wrote:

I've experimented using $_SERVER['HTTP_REFERER'] which seems to work here.
If the user enters valid login details, the session vars are set and they
are bounced automatically back to the original page - which is fab. But the
manual says that HTTP_REFERER is unreliable, so I'm intrigued to know
exactly what the problems are. Any ideas?






-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




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

I am currently working on transforming a rather large software package to
oop. I do have a few years of experience with php, but just started to use oop.
One of the first question that arose was how to handle configuration vars.
These should ideally be stored in a file:

<?php

$db_user = "user";
$db_password ="secret";

etc.

?>

Now, I have to access these vars from a class.

class database {

var $db_user;
var $db_password;

function connect()
 {

}

}

What is the best way to access these variables? I want to avoid global vars.
I also don't like to set the vars using $object->db_user = $db_user; every
time I use it.

Also, is there any large open-source php - application which could serve as
an example of best practice?

best regards,

Raul

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!


--- End Message ---
--- Begin Message --- Not sure how to answer your question as I am real new to PHP, but you may want to look at PEAR if you have not done so. I know there are libraries that folks have been talking about recently that handle just these sorts of things. If you don't use them - you may find your answers by looking at the sources.

- Charles

On Sunday, March 16, 2003, at 12:57 PM, [EMAIL PROTECTED] wrote:

Hi,

I am currently working on transforming a rather large software package to
oop. I do have a few years of experience with php, but just started to use oop.
One of the first question that arose was how to handle configuration vars.
These should ideally be stored in a file:

<?php

$db_user = "user";
$db_password ="secret";

etc.

?>

Now, I have to access these vars from a class.

class database {

var $db_user;
var $db_password;

function connect()
 {

}

}

What is the best way to access these variables? I want to avoid global vars.
I also don't like to set the vars using $object->db_user = $db_user; every
time I use it.

Also, is there any large open-source php - application which could serve as
an example of best practice?

best regards,

Raul

--
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!


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



--- End Message ---
--- Begin Message ---
have a look at my class , i had to do it from scratch as pear db + mdb have
too much weight and needed a faster app, being that its going to be on a mysql
database only, i send my login variables to a connect function, and those
login variables i store in a file outside the web directory

http://electroteque.dyndns.org:1023/benchmark/DB.phps

and in connect, the file with the login info is a directory up from htdocs
>===== Original Message From Charles Kline <[EMAIL PROTECTED]> =====
>Not sure how to answer your question as I am real new to PHP, but you
>may want to look at PEAR if you have not done so. I know there are
>libraries that folks have been talking about recently that handle just
>these sorts of things. If you don't use them - you may find your
>answers by looking at the sources.
>
>- Charles
>
>On Sunday, March 16, 2003, at 12:57 PM, [EMAIL PROTECTED] wrote:
>
>> Hi,
>>
>> I am currently working on transforming a rather large software package
>> to
>> oop. I do have a few years of experience with php, but just started to
>> use oop.
>> One of the first question that arose was how to handle configuration
>> vars.
>> These should ideally be stored in a file:
>>
>> <?php
>>
>> $db_user = "user";
>> $db_password ="secret";
>>
>> etc.
>>
>> ?>
>>
>> Now, I have to access these vars from a class.
>>
>> class database {
>>
>> var $db_user;
>> var $db_password;
>>
>> function connect()
>>  {
>>
>> }
>>
>> }
>>
>> What is the best way to access these variables? I want to avoid global
>> vars.
>> I also don't like to set the vars using $object->db_user = $db_user;
>> every
>> time I use it.
>>
>> Also, is there any large open-source php - application which could
>> serve as
>> an example of best practice?
>>
>> best regards,
>>
>> Raul
>>
>> --
>> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
>> Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php



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

i have a form on a page which is built dynamically and consists of fields in
a certain table and checkboxes. The puropse of the form is to update the the
status of a table called CMS_FIELDS which stores data of all the fields for
all the tables in the database.

Using the following code i am attempting to update the table depending on
whether the boxes have been ticked or not, but the script only outputs
values of the boxes that have been ticked. (the data isn't being updated yet
i am just printing it to the screen for testing purposes).

      if(isset($update_fields)==true){
       $fields='';
       $values='';
       foreach ($_POST as $key => $val) {
         $fields[] = $key;
         $values[] = $val;
       }
       $i=0;
       foreach ($fields as $val){
        if ($values[$i] == "on"){
         $query = "UPDATE CMS_FIELDS SET cms_fields_is_editable = '1'
               WHERE cms_table_name = '$_GET[table_name]' AND cms_field_name
= '".$fields[$i]."'";
        }else {
         $query = "UPDATE CMS_FIELDS SET cms_fields_is_editable = '0'
               WHERE cms_table_name = '$_GET[table_name]' AND cms_field_name
= '".$fields[$i]."'";
        }
        echo "$query<br>";
        $i++;
       }
      }

How can i get the script to look at all of the values sent from the form
(ticked or unticked)?

thanks for your help



--- End Message ---
--- Begin Message ---
Hey you guys!

First, I have to say, that php.net gave me a lot of support in the last few weeks and 
months. It's been great to suck information from your guys' website! Thanx a lot!

This weekend, I've been fighting with some really weird problem though... I installed 
a few mail(); actions on my website plus in some projects I'm working on. I have one 
really big problem though... Everything works fine until I want to send a mail to 
another mailserver than mine. So, it only works for my own (mail)server - how the hell 
is that possible? And: can I fix that? Do I have to include special headers?

Thank you very much for yar answer!

Greetz

Manuel, Berne, Switzerland

--- End Message ---
--- Begin Message ---
I have a function, such as this:

function encryptPassword($password, $salt = $encryptiontechnique) {
}

$encryptiontechnique is defined, obviously outside the function. How is it possible to 
make $encryptiontechnique global so that this will work?

--- End Message ---
--- Begin Message ---
Try:

somewhere global define :
   $encryptiontechnique = 'ENCRYPT ALGORITHM';


function encryptPassword($password, $salt='') {
    global $encryptiontechnique; if ($salt === '') { $salt =
$encryptiontechnique; }
    // CODE......

}

Joel Colombo





"Liam Gibbs" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I have a function, such as this:

function encryptPassword($password, $salt = $encryptiontechnique) {
}

$encryptiontechnique is defined, obviously outside the function. How is it
possible to make $encryptiontechnique global so that this will work?



--- End Message ---
--- Begin Message ---
I thought I understood this example: http://www.php.net/manual/en/ref.array.php

<?php
$var = array(
'name' => array(
                'first' => 'Caleb',
                'last' => 'Maclennan'
                )
);
echo "My first name is {$var['name']['first']}!";
?>

I can do that. But, my array looks more like:

$var = array (
        'AN' => array (
                      'Description' => 'Accession Number: (AN)',
                      'ReferenceURL' => 'AN__Accession_Number.jsp',
          ),
         'AU' => array (
                      'Description' => 'Author(s): (AU)',
                      'ReferenceURL' => 'AU__Author(s).jsp',
          )
)

What I want to get is the keys 'AN' and 'AU' as values.

while (??){
echo "This key is $var[??]<br>";
}

This key is AN
This key is AU

How :) ?

Still learning :)
John



--- End Message ---
--- Begin Message ---
use mysql_list_tables ?
>===== Original Message From "shaun" <[EMAIL PROTECTED]> =====
>Hi,
>
>i would like to list all of the tables and field names in my database
>
>e.g.
>
>table 1
>  field 1
>  field 2
>  field 3
>table 2
>  field 1
>  field 2
>  field 3
>table 3
>  field 1
>  field 2
>  field 3
>etc
>
>is there a simple way to do this?
>
>thanks for your help
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
I'm hopeful that someone here has been in my situation and found a fix for
it.

I recently installed a clean OpenBSD 3.2 system, and added the
php4-core-4.2.3 and php4-gd-4.2.3 packages, along with a few other packages
from the php4 collection.  Most everything seems to be working fine.
However, php4-gd-4.2.3 doesn't appear to be working at all.  At least the
createimagefromjpeg function isn't returning the picture it's supposed to
return.  It's similar to what I had before the upgrade to 3.2 when I didn't
have PHP compiled with the --with-gd and --with-jpeg-dir config options.

A phpinfo() page shows that the gd module is activated, and that JPG Support
is enabled, but the function does not work at all.

Any ideas where I can look to solve this?

Bob


--- End Message ---
--- Begin Message ---
hi guys trikky question , i would like to ignore html in content that i am 
replacing news lines with page breaks , how is it possible ? at the moment and 
new line like so \r\n in content will be replaced with a <br> but happens to 
work on say tables tags within the content aswell and need to ignore this.



--- End Message ---
--- Begin Message ---
Hello all

A frind of mine likes to count the impressions on each of his photgraphy online
and as well he likes to display this number under each image

he dosn't wish to use for each image a new request to the different count script 
..all should be counted with one script and saved in one datafile 

//   Code start 

//  Image ID
$ImageNr=$HTTP_GET_VARS['n'];
if(!$ImageNr){$ImageNr=0;}

// Full sys path to count.txt 
$counter_file = "count2.txt"; 
 
// Puts the file lines into $counter_file_line array 
$counter_file_line = file($counter_file); 
 
// adds one to the number in the [0] array or the very first line 
$counter_file_line[0]++; 
 
//  I use a+ well I need each line representing an induvitual image ? ??
// opends the file and then writes the new number and then closes it 
$cf = fopen($counter_file, "a+"); 
fputs($cf, "$counter_file_line[0]");   
fclose($cf); 
 
// prints out the full count 

// ??
echo " Views $counter_file_line[0] "; 

//  Code end

--- End Message ---
--- Begin Message ---
The following test script for the function strcmp() is from page 114 -115 of
PHP (Hungry Minds).

I'm getting a parse error on line 6.

Using PHP 4.1.1 / MS Win 98 / Apache Server.

Many thanks...
Tony Ritter
..........................................

<?
// using strcmp()
$firstword="peach";
$secondword="mango";
$result=strcmp($firstword, $secondword)
if ($result>=1)
 {
  $statement="comes after";
 }
else if ($result<=-1)
 {
  $statement="comes before";
 }
else
 {
  $statement="is the same as";
 }
echo "The word <b>$firstword</b> $statement";
?>





--- End Message ---
--- Begin Message --- You need a semicolon after the strcmp() function

$result=strcmp($firstword, $secondword);

LinuxGeek


Anthony Ritter wrote:

The following test script for the function strcmp() is from page 114 -115 of
PHP (Hungry Minds).

I'm getting a parse error on line 6.

Using PHP 4.1.1 / MS Win 98 / Apache Server.

Many thanks...
Tony Ritter
..........................................

<?
// using strcmp()
$firstword="peach";
$secondword="mango";
$result=strcmp($firstword, $secondword)
if ($result>=1)
{
 $statement="comes after";
}
else if ($result<=-1)
{
 $statement="comes before";
}
else
{
 $statement="is the same as";
}
echo "The word <b>$firstword</b> $statement";
?>










--- End Message ---
--- Begin Message --- Anthony Ritter wrote:
The following test script for the function strcmp() is from page 114 -115 of
PHP (Hungry Minds).

I'm getting a parse error on line 6.

Using PHP 4.1.1 / MS Win 98 / Apache Server.

Many thanks...
Tony Ritter
..........................................

<?
// using strcmp()
$firstword="peach";
$secondword="mango";
$result=strcmp($firstword, $secondword)
if ($result>=1)
 {
  $statement="comes after";
 }
else if ($result<=-1)
 {
  $statement="comes before";
 }
else
 {
  $statement="is the same as";
 }
echo "The word <b>$firstword</b> $statement";
?>




You were missing a semicolon:

$result=strcmp($firstword, $secondword);

Justin Garrett


--- End Message ---
--- Begin Message --- You're missing the ; on this line:

$result=strcmp($firstword, $secondword)



Anthony Ritter wrote:

The following test script for the function strcmp() is from page 114 -115 of
PHP (Hungry Minds).

I'm getting a parse error on line 6.

Using PHP 4.1.1 / MS Win 98 / Apache Server.

Many thanks...
Tony Ritter
..........................................

<?
// using strcmp()
$firstword="peach";
$secondword="mango";
$result=strcmp($firstword, $secondword)
if ($result>=1)
{
 $statement="comes after";
}
else if ($result<=-1)
{
 $statement="comes before";
}
else
{
 $statement="is the same as";
}
echo "The word <b>$firstword</b> $statement";
?>








-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




--- End Message ---
--- Begin Message ---
having alot of difficulties wrapping my head around this and looking for 
ideas...

SQL TABLE:
   1...n fields
        auto, name, description, version, etc...

auto        = unique id
name        = possibly non-unique string, but with unique version
description = possibly non-unique string, based on name
version     = unique to name

ie.
   1   typeX    X brand    1
   2   typeX    x-brand    2
   3   typeY    y-brand    1
   4   typeZ    z-brand    1
   5   typeZ    Z brand    2

sql = select * from table where [ conditions ] order by auto

problem:
display unique name, and associated rows based on highest version
ie. (see above)
   typeX (version 2):   x-brand
   typeY (version 1):   y-brand
   typeZ (version 2):   Z brand

through a mixture of the original sql query, multisort_array and array_unique, 
I have been able to get the unique names (which I could do with one sql query), 
however, I have not been able to get: 
   select * from table where [conditions] and greatest version for unique name

any help appreciated
=======================================
Michael Geier
CDM Sports, Inc. Systems Administration
   email: [EMAIL PROTECTED]
   phone: 314.692.3540

-----------------------------------------------
 This email sent using CDM Sports Webmail v3.1
              [ http://webmail.cdmsports.com ]

--- End Message ---

Reply via email to