|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 8 Aug 2005 02:12:11 -0000 Issue 3612
php-general-digest-help
lists.php.net
Date: Sun Aug 07 2005 - 21:12:11 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 8 Aug 2005 02:12:11 -0000 Issue 3612
Topics (messages 220170 through 220189):
Re: Fast count of recordset in php...
220170 by: Marcus Bointon
220172 by: Satyam
Re: sorry for asking here,a small apache query
220171 by: mviron.findaschool.net
PHP error tracking on new server
220173 by: Terry Romine
220176 by: Marco Tabini
Creaing a foldout menu from an array.
220174 by: Gregory Machin
220175 by: Marco Tabini
Re: Regex help
220177 by: Dotan Cohen
Re: Average time spent on a page
220178 by: virtualsoftware.gmail.com
220180 by: M Saleh EG
A question on the term CFG.
220179 by: wayne
220182 by: Chris
220183 by: Jasper Bryant-Greene
220185 by: Marco Tabini
220187 by: Jochem Maas
220189 by: wayne
writing to file
220181 by: Sebastian
220188 by: Jochem Maas
Re: Java - toString() <-> php - ?
220184 by: Jasper Bryant-Greene
Re: mkdir, Shared Hosting?
220186 by: Esteamedpw.aol.com
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
On 7 Aug 2005, at 05:04, TalkativeDoggy wrote:
> be coz this way is slow and costs more overload.
>
> $sql = "SELECT COUNT(IDVara) cn FROM tbvara WHERE Varunamn LIKE
> '$checkLev%'";
> $querys = mysql_query($sql);
>
> //Count products in db
> //
> $dbArray = mysql_fetch_row($querys);
> $nrOfProducts = $dbArray[0];
According to the docs, MySQL has a particular optimisation that means
that it should be:
$sql = "SELECT COUNT(*) FROM tbvara WHERE Varunamn LIKE '$checkLev%'";
Also if you want the full count value when you've done a query that
uses a LIMIT clause, instead of doing a separate full count query,
you can get it by using the SQL_CALC_FOUND_ROWS keyword, e.g.
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM tbvara WHERE Varunamn LIKE
'$checkLev%' LIMIT 10";
Of course count(*) could only ever return up to 10 in this query -
you can find out how many it would have found by then asking:
$sql = "SELECT FOUND_ROWS()";
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus
synchromedia.co.uk | http://www.synchromedia.co.uk
attached mail follows:
"Marcus Bointon" <marcus
synchromedia.co.uk> wrote in message
news:D0420FA1-C5CC-42DB-ADCD-EBA24769B7AF
synchromedia.co.uk...
> According to the docs, MySQL has a particular optimisation that means
> that it should be:
>
> $sql = "SELECT COUNT(*) FROM tbvara WHERE Varunamn LIKE '$checkLev%'";
>
It is not just a MySql optimization but this holds true for every database.
When you specify a field in the count() function, you are telling SQL to
count the number of occurences of that field which does not include those
records in which the field is set tu null. Thus, to do such count, SQL has
to access each record to check whether the field is null or not. For a
table where a certain field allows nulls, asking for a count of that field
will give a lower row count than asking for count(*).
On the other hand, if you say count(*) SQL knows that you mean a plain
recordcount, regardless of whether any particular field is null or not. To
do that, SQL does not need to access the actual data in each record, it just
needs to travel the primary key tree, never getting to the actual records.
Some database engine might be smart enough to figure that if the particular
field you asked for does not allow nulls, a count of that field is the same
as a count(*) and us a better strategy but you are better off not relying on
that.
By the way, I wouldn't count on mysql_num_rows() being as fast as doing a
count(*). The SQL engine can play a lot of tricks knowing for certain that
you just mean a count(*) which cannot do if you do a plain query which you
don't actually mean to use but for counting. I would assume that depending
on the engine, a whole batch of records would be read into memory to have
them ready for the fetches that never come.
It is safer to explicitly tell the SQL engine what you actually mean than to
rely on smart optimizations that might or might not be there.
Satyam
attached mail follows:
There are two ways to accomplish what you are asking. The quickest way,
without any modfication to httpd.conf, is to place an empty index.html or
other default index page into that directory. This will prevent the
directory listing from showing up. The other method, is to change
httpd.conf to disallow indexing on all directories for the docroot on down.
To do this, "-Indexes" needs to be added to the <directory></directory>
directives for the docroot, although this may be one of the many
configuration directives which have changed between v1.3, v2.0, and v2.1 --
see http://httpd.apache.org/docs-project/ for more specific information on
guidance on how to accomplish this.
--
Michael Viron
President & CEO
General Education Online
-----Original Message-----
From: babu [mailto:garavindbabu
yahoo.co.uk]
Sent: Saturday, August 06, 2005 2:38 PM
To: php-general
lists.php.net
Subject: [PHP] sorry for asking here,a small apache query
Hi all,
I am sorry for asking in php forum.i am subscribed to php and not to
apache.but i hope many people in this group also the solution to this query.
how can i configure apache so that users are forbidden to see my docroot
file structure.
for example i have a file at http://localhost/dir1/xyz.html , if the user
try to access http://localhost, or http://localhost/dir1 he shud get a
message forbidden.
Thanks
babu.
---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo!
Security Centre.
attached mail follows:
My hosting service recently switched to a newer server and in
transporting the websites (many) over, they set up php different
(vers 4.3.10). I know it's not "nice" to show errors on a published
website, but I don't have a testing server, and I need to debug
scripts once in a while. The problem is that when an error occurs,
the page just comes up blank, and I have to practically pick it apart
one line at a time to track down the problem.
I tried
ini_set('display_errors',TRUE);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
but that doesn't seem to matter either.
From phpinfo() it says display_errors is set off and error_reporting
is 7.
Any ideas on what flag may need to be set and how to do it on a file-
by-file basis so I am only tweaking it when testing?
Terry
attached mail follows:
Hey Terry--
On 8/7/05 11:03 AM, "Terry Romine" <eatrom
blazing-trails.com> wrote:
>
> Any ideas on what flag may need to be set and how to do it on a file-
> by-file basis so I am only tweaking it when testing?
>
> Terry
Does your hosting provider support .htaccess? If so, you may be able to
change the error reporting settings by providing your own .htaccess file
which contains something like:
php_flag display_errors on
HTH,
Marco
--
BeebleX - The PHP Search Engine
http://beeblex.com
attached mail follows:
Hi
Please advise.
I need to create menu that has the following html
<body>
<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul>
<li><a href="#">History</a></li>
<li><a href="#">Team</a></li>
<li><a href="#">Offices</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Web Design</a></li>
<li><a href="#">Internet
Marketing</a></li>
<li><a href="#">Hosting</a></li>
<li><a href="#">Domain Names</a></li>
<li><a href="#">Broadband</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a>
<ul>
<li><a href="#">United Kingdom</a></li>
<li><a href="#">France</a></li>
<li><a href="#">USA</a></li>
<li><a href="#">Australia</a></li>
</ul>
</li>
</ul>
</body>
The menu is structured with an array where each field holds an ID a
PerantID the name and the link .
the PeratID refers to the ID of the item in the array wich it is attached to..
My problem is I cant figure out the correct loop / logic to put the
<ul> tags in the rite places etc..
Many thanks
--
Gregory Machin
greg
linuxpro.co.za
gregory.machin
gmail.com
www.linuxpro.co.za
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info (support and admin)
www.goeducation (support and admin)
+27 72 524 8096
attached mail follows:
Hey Gregory--
On 8/7/05 12:05 PM, "Gregory Machin" <gregory.machin
gmail.com> wrote:
> Hi
> Please advise.
>
There was a thread on our forums a while back and one of my colleagues
posted a variant of the code we use for our menus, so maybe this will help
you:
http://www.phparch.com/discuss/index.php/m/3901/2
Cheers!
Marco
--
BeebleX - The PHP Search Engine
http://beeblex.com
attached mail follows:
On 8/4/05, Lizet Pena de Sola <mailinglist
theniceweb.com> wrote:
> Ok, it's not the regexp for detecting email addresses what I need,
> that's widely published, thanks. I'm using ereg to match this regular
> expression:
>
> (On)[\s\w\d\W\S\D\n]*(wr[i|o]te[s]?:)
>
> That will match phrases like
> "On 8/3/05, Carol Swinehart <cshart
greenapple.edu> wrote:"
> the type "On date, name <email> wrote or writes:"
>
> The thing is I tried this regexp with Regex Coach and it matches fine,
> but ereg returns no match
>
> ereg($regexpstr, $str, $regs)
>
> I know there are some comments at php.net about how ereg has some bugs,
> any idea if this could be one?
>
> Tia,
> Lizet
You're not going to get far with that. Lots of people make 'funny' You
Wrote lines, and not all of them start with 'On' or contain the word
'wr[o|i]te'. You might be better off just searching for any sentance
that contains an
sign, because they are very seldom used outside of
email addresses nowadays. And that doesn't make any promises, either,
because sometimes the whole email address isn't in the line, just the
person's name.
Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/286/judas_priest.php
Judas Priest Song Lyrics
attached mail follows:
Yes, I'm looking for the algorithm.
----- Original Message -----
From: M Saleh EG
To: virtualsoftware
gmail.com
Cc: php-general
lists.php.net ; Frank de Bot
Sent: Sunday, August 07, 2005 6:36 AM
Subject: Re: [PHP] Average time spent on a page
Try using one of the log reader/analysis packages available for Apache or
try doing it urself.
Are you looking for the algorithm? let me know.
On 8/6/05, virtualsoftware
gmail.com <virtualsoftware
gmail.com > wrote:
LOL. This got nothing to do with my question . LOL again
----- Original Message -----
From: "Frank de Bot" < php
searchy.nl>
Cc: <php-general
lists.php.net>
Sent: Saturday, August 06, 2005 10:20 PM
Subject: Re: [PHP] Average time spent on a page
> virtualsoftware
gmail.com wrote:
>
>>Hi,
>>
>>How can i found out the average time users spent on a page. Anyone know a
>>tutorial?
>>
>>Thanks in advance for your help !!!
>>
>
> A hello world page will take me around 15 secs I guess...
> A full blown website with everything you can imagine a few months orso.
>
> --
> 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
--
M.Saleh.E.G
97150-4779817
attached mail follows:
My Algorithm would look something close to this,
ForEach Session
ForEach Page_Visit
Record Page_Load
Record Page_Unload (could be clicking on a link on a page or just leaving
the whole domain which might end the session as well)
This would be the simplest form I coult put a rough algorithm for that.
The actual solution would be a mixture of PHP, JS, SQL, and Apache Log
reading.
Wow!!! I'm starting to visualize an application full of graphs and analysys
for usabilty analysys and results. I'm so excited. I'm going to research
more on this subject.
On 8/7/05, virtualsoftware
gmail.com <virtualsoftware
gmail.com> wrote:
>
> Yes, I'm looking for the algorithm.
>
> ----- Original Message -----
> *From:* M Saleh EG <m.saleh.eg
gmail.com>
> *To:* virtualsoftware
gmail.com
> *Cc:* php-general
lists.php.net ; Frank de Bot <php
searchy.nl>
> *Sent:* Sunday, August 07, 2005 6:36 AM
> *Subject:* Re: [PHP] Average time spent on a page
>
> Try using one of the log reader/analysis packages available for Apache or
> try doing it urself.
> Are you looking for the algorithm? let me know.
>
> On 8/6/05, virtualsoftware
gmail.com <virtualsoftware
gmail.com > wrote:
> >
> > LOL. This got nothing to do with my question . LOL again
> >
> > ----- Original Message -----
> > From: "Frank de Bot" < php
searchy.nl>
> > Cc: <php-general
lists.php.net>
> > Sent: Saturday, August 06, 2005 10:20 PM
> > Subject: Re: [PHP] Average time spent on a page
> >
> >
> > > virtualsoftware
gmail.com wrote:
> > >
> > >>Hi,
> > >>
> > >>How can i found out the average time users spent on a page. Anyone
> > know a
> > >>tutorial?
> > >>
> > >>Thanks in advance for your help !!!
> > >>
> > >
> > > A hello world page will take me around 15 secs I guess...
> > > A full blown website with everything you can imagine a few months
> > orso.
> > >
> > > --
> > > 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
> >
> >
>
>
> --
> M.Saleh.E.G
> 97150-4779817
>
>
--
M.Saleh.E.G
97150-4779817
attached mail follows:
First, I'm new to PHP. I have a script that
has a piece of code that looks like this -
require_once($CFG->wwwroot . '/lib/mylib.php');
My question is this, I'm trying to find out
how the class $CGF was initiated.There are no
include or require statement before the statement.
Is $CFG a global variable? If how does it get
initiated?
Tnaks.
attached mail follows:
That isn't created by PHP, it must be declared in the code somewhere.
Maybe there is an auto_prepend_file set?
http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
Chris
wayne wrote:
>First, I'm new to PHP. I have a script that
>has a piece of code that looks like this -
>require_once($CFG->wwwroot . '/lib/mylib.php');
>My question is this, I'm trying to find out
>how the class $CGF was initiated.There are no
>include or require statement before the statement.
>Is $CFG a global variable? If how does it get
>initiated?
>Tnaks.
>
>
>
attached mail follows:
Or if it's PHP 5 they might be using an __autoload() magic function
which gets called whenever a class that isn't declared is instantiated.
That function could be require()ing another file.
Jasper
Chris wrote:
> That isn't created by PHP, it must be declared in the code somewhere.
>
> Maybe there is an auto_prepend_file set?
>
> http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
>
> Chris
>
> wayne wrote:
>
>> First, I'm new to PHP. I have a script that
>> has a piece of code that looks like this -
>> require_once($CFG->wwwroot . '/lib/mylib.php');
>> My question is this, I'm trying to find out
>> how the class $CGF was initiated.There are no
>> include or require statement before the statement.
>> Is $CFG a global variable? If how does it get
>> initiated?
>> Tnaks.
>>
>>
>>
>
attached mail follows:
On 8/7/05 4:24 PM, "Jasper Bryant-Greene" <jasper
bryant-greene.name> wrote:
> Or if it's PHP 5 they might be using an __autoload() magic function
> which gets called whenever a class that isn't declared is instantiated.
> That function could be require()ing another file.
Well, if it is PHP 5, then you can use introspection to find out where that
class is declared:
$className = get_class ($CFG);
$cls = new ReflectionClass ($className);
Echo "Class " . $className . " is defined in " .
$cls->getFileName() . " between lines " . $cls->getStartLine() . " and " .
$cls->getEndLine();
Marco
>
> Jasper
>
>
> Chris wrote:
>> That isn't created by PHP, it must be declared in the code somewhere.
>>
>> Maybe there is an auto_prepend_file set?
>>
>> http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
>>
>> Chris
>>
>> wayne wrote:
>>
>>> First, I'm new to PHP. I have a script that
>>> has a piece of code that looks like this -
>>> require_once($CFG->wwwroot . '/lib/mylib.php');
>>> My question is this, I'm trying to find out
>>> how the class $CGF was initiated.There are no
>>> include or require statement before the statement.
>>> Is $CFG a global variable? If how does it get
>>> initiated?
>>> Tnaks.
>>>
>>>
>>>
>>
--
Marco Tabini
President & CEO
Marco Tabini & Associates, Inc.
28 Bombay Ave.
Toronto, ON M3H 1B7
Canada
Phone: +1 (416) 630-6202
Fax: +1 (416) 630-5057
attached mail follows:
wayne wrote:
> First, I'm new to PHP. I have a script that
> has a piece of code that looks like this -
> require_once($CFG->wwwroot . '/lib/mylib.php');
> My question is this, I'm trying to find out
> how the class $CGF was initiated.There are no
> include or require statement before the statement.
> Is $CFG a global variable? If how does it get
> initiated?
> Tnaks.
>
you already had a couple of really good tips on finding
the relevanty class - regarding 'CFG' Ill bet the guy
that wrote it meant 'config', thats often shorten to 'cfg'
or 'conf' - programmers like to type a little as possible :-)
attached mail follows:
Hi Marco,
The version of php I have is 4.3.10. Is there something
similar to the below example in the version I have?
Thanks.
On Sun, 2005-08-07 at 16:39 -0400, Marco Tabini wrote:
> On 8/7/05 4:24 PM, "Jasper Bryant-Greene" <jasper
bryant-greene.name> wrote:
>
> > Or if it's PHP 5 they might be using an __autoload() magic function
> > which gets called whenever a class that isn't declared is instantiated.
> > That function could be require()ing another file.
>
> Well, if it is PHP 5, then you can use introspection to find out where that
> class is declared:
>
> $className = get_class ($CFG);
> $cls = new ReflectionClass ($className);
>
> Echo "Class " . $className . " is defined in " .
> $cls->getFileName() . " between lines " . $cls->getStartLine() . " and " .
> $cls->getEndLine();
>
>
> Marco
>
> >
> > Jasper
> >
> >
> > Chris wrote:
> >> That isn't created by PHP, it must be declared in the code somewhere.
> >>
> >> Maybe there is an auto_prepend_file set?
> >>
> >> http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
> >>
> >> Chris
> >>
> >> wayne wrote:
> >>
> >>> First, I'm new to PHP. I have a script that
> >>> has a piece of code that looks like this -
> >>> require_once($CFG->wwwroot . '/lib/mylib.php');
> >>> My question is this, I'm trying to find out
> >>> how the class $CGF was initiated.There are no
> >>> include or require statement before the statement.
> >>> Is $CFG a global variable? If how does it get
> >>> initiated?
> >>> Tnaks.
> >>>
> >>>
> >>>
> >>
>
> --
> Marco Tabini
> President & CEO
>
> Marco Tabini & Associates, Inc.
> 28 Bombay Ave.
> Toronto, ON M3H 1B7
> Canada
>
> Phone: +1 (416) 630-6202
> Fax: +1 (416) 630-5057
>
attached mail follows:
i have this app where a user fills out a form and after submit it
displays the values they entered. i want to save this info to a file
after they submit, then allow them to download the file. some other user
does the same, fills in the form and allow that person to download the
file... and so on.
i don't know how i should go about doing this.. rather than keep
creating files i would like to recycle the file each time someone uses
the system, but that can lead to other problems.. like several users
using the app at once..
any suggestion/ideas/tips how i should do this? basically, just write
the info from POST to a file and allow them to download the file.
obviously i am worried how secure i will be able to make this.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.2/65 - Release Date: 8/7/2005
attached mail follows:
Sebastian wrote:
> i have this app where a user fills out a form and after submit it
> displays the values they entered. i want to save this info to a file
> after they submit, then allow them to download the file. some other user
> does the same, fills in the form and allow that person to download the
> file... and so on.
>
> i don't know how i should go about doing this.. rather than keep
> creating files i would like to recycle the file each time someone uses
> the system, but that can lead to other problems.. like several users
> using the app at once..
>
> any suggestion/ideas/tips how i should do this? basically, just write
> the info from POST to a file and allow them to download the file.
> obviously i am worried how secure i will be able to make this.
alot depends on whether the user will be allowed to download the file
only in the current session or at any time in the future.
also security has 2 sides - protection on the server (from other
people hosting on the same machine, and protection on the 'outside'
from unauthorized users trying to download other peoples files
(which would require some kind of login mechanism)
note that in order to give a user a file to download when he/she
clicks something does not require an actual file to exist ...
you could store the data ('file contents') in a DB and have a script
which when requested with the correct parameters (GET args) will
extract the data from the DB (or whereever) and output it with the
correct headers (to force a download)
there is lots of info out there on how to create/output headers to
tell a browser that it should download whatever is returned from a
request. have a search - chances are you'll find something
chances are also that you'll get stuck because of the way certain
browsers f*** up when given 'download' headers - I've found it as much
art as science in the past ;-) any way if this turns out to be the case
we'll be seeing you :-)
>
>
attached mail follows:
If you use PHP 5 just use the __toString() magic method which does
exactly that.
http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
Jasper
Rory Browne wrote:
> Um - did you read my last email regarding var_dump var_export and print_r
>
> Did you try them?
>
> Do they do what you want?
>
> On 8/2/05, Adi Zebic <adi
beeznest.net> wrote:
>
>>Rory Browne a écrit :
>>
>>>I haven't a monkies what that code(your java) does, and I don't have
>>>time to analyse it(in expensive cybercafe), but you may want to
>>>consider www.php.net/print-r www.php.net/var-dump and
>>>www.php.net/var-export
>>>
>>>I think they may do what you want without using the toString method,
>>>which for what you're describing is basicly an ugly hack.
>>>
>>>One more thing: Enlighten me: What exactly do you mean by "live
>>>evolution" in your php/java context.
>>
>>If in php context you have class, say, A:
>>
>>class A
>>{
>>
>> var $t1;
>> var $t2;
>> var $t3;
>>
>>//After, you have object contructor of type A
>>//we have something like this
>>
>>function A ($var1, $var2, $var3)
>>{
>> $this -> t1 = $var1;
>> $this -> t2 = $var2;
>> $this -> t3 = $var3;
>>}
>>
>>....some other code
>>}
>>
>>//than in some other class we have something like this:
>>
>>class someOtherClass
>>{
>> $aConstructor = new A(1,2,3);
>> //values of t1, t2 and t3 are 1,2 and 3 now
>> }
>>
>>Right? yes.
>>
>>How you can you do something like this inside of "someOtherClass"
>>
>>print ($aConstructor);
>>
>>to finally have some nice output like
>>Value of t1 is 1;
>>Value of t2 is 2;
>>Value of T3 is 3;
>>
>>or just:
>>
>>1
>>2
>>3
>>
>>Without creating functions like getValues()
>>
>>function getValues()
>>{
>> print ($this -> t1);
>> print ($this -> t2);
>> print ($this -> t3);
>>}
>>
>>and after explicit invoke function:
>>
>> $aConstructor -> getValues();
>>
>>So, what I want is
>>this: print ($aConstructor);
>>
>>and not this:
>>
>>$aContructor -> getValues();
>>
>>Am I clear :-)
>>
>>
>>ADI
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
attached mail follows:
Thanks, but I've tried that when I first got the Error message, it still
gave me the error. Thanks though!
In a message dated 8/7/2005 1:29:26 A.M. Central Standard Time,
phplist
meidomus.com writes:
>Open up your FTP client and log into your website, then change the
>permissions on your folder so that the apache process has write access
>to it. Its really hit and miss depending on your setup.
>The sure fire way (but highly insecure) way is to change the permissions
>to the directory in question to 777.
>A better solution would be 755, but it may not work.
>Try it, and see what you get.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]