|
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 26 Jan 2005 17:28:19 -0000 Issue 3250
php-general-digest-help
lists.php.net
Date: Wed Jan 26 2005 - 11:28:19 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 26 Jan 2005 17:28:19 -0000 Issue 3250
Topics (messages 207351 through 207396):
Optimize code?
207351 by: Wiberg
207358 by: Jochem Maas
207391 by: The Disguised Jedi
Re: Help with file not writing
207352 by: Bret Hughes
207353 by: Joey
Multi by Multi level system
207354 by: Marek
Working with Multi by Multi levels menu
207355 by: Marek
207362 by: Marek Kilimajer
207379 by: Marek
207384 by: Marek Kilimajer
207386 by: Marek
Re: Understanding intval() and types conversion
207356 by: Jochem Maas
207374 by: Jordi Canals
Re: PHP Application server / Expression of Interest
207357 by: Jochem Maas
Re: Log-in script help
207359 by: Tom
207388 by: Joe Harman
Re: Magic quotes question (still driving me mad)
207360 by: Ben Edwards
207375 by: Ford, Mike
Apache: Request exceeded the limit of 10 internal redirects
207361 by: James Guarriman
207363 by: Tom
207366 by: Marek Kilimajer
Getting two queries into one result set
207364 by: Shaun
207365 by: M. Sokolewicz
207367 by: Marek Kilimajer
207368 by: Jochem Maas
round
207369 by: blackwater dev
207371 by: M. Sokolewicz
207372 by: Gerard Petersen
207373 by: Sergio Gorelyshev
Mail Delivery (failure php-general
lists.php.net)
207370 by: ilia.prohost.org
Re: [NEWBIE GUIDE] For the benefit of new members
207376 by: Rolf Østvik
207377 by: Jay Blanchard
207378 by: Jay Blanchard
207380 by: Jay Blanchard
207382 by: Jochem Maas
207385 by: Jochem Maas
207387 by: Jay Blanchard
207389 by: Jochem Maas
Re: Image manipulation without GD library
207381 by: Jason Barnett
207383 by: Marek Kilimajer
mssql and paging
207390 by: Zouari Fourat
LIMIT with MSSQL
207392 by: Zouari Fourat
pcntl_fork doesn't work
207393 by: John Davin
207394 by: Ben Ramsey
207396 by: John Davin
Isolated Execution Environment in PHP? (a la Safe module in Perl)
207395 by: Eric Dorland
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:
Hi!
I wonder if I can optimize following code (or do something better) below?
It works fine when about 3.000 rows exists in the textfile, but when it gets
to 10.000 rows then it will get a session timeout. (or internal server
error)
<?php
function checkSaldo($url, $articleNrFieldNr, $saldoFieldNr, $separator,
$startLine, $prefix) {
require ("phpfunctions/opendb.php");
//Read in specified file into array
//
$fileArray = file($url);
//Go through array
//
for ($i=$startLine;$i<count($fileArray);$i++) {
//Get line of file (through array)
//
$lineRead = $fileArray[$i];
//Make array of all "elements" in this line
//
$lineArray = explode("$separator",$lineRead);
//Get manufacturers articlenumber
//
if (isset($lineArray[$articleNrFieldNr])) {
$articleNumberManufacturer = $lineArray[$articleNrFieldNr];
}
else {
$articleNumberManufacturer = 0;
}
//Get saldo for this product
//
if (isset($lineArray[$articleNrFieldNr])) {
$saldo = $lineArray[$saldoFieldNr];
}
else {
$saldo = 0;
}
//There is no data on this row
//set saldo and articlenr to zero, so nothing happens
//
if (strlen($lineRead)==0) {
$saldo = 0;
$articleNumberManufacturer = 0;
}
//echo "<br>ARTICLENR: $articleNumberManufacturer<br>";
//echo "SALDO: $saldo<br>";
//Articlenr exists in line
//
if (intval($articleNumberManufacturer)>0) {
//Get ID of product (if there is any in varupiratens db)
//skip the product if the saldo is the same as in
//the textfile
//
$sql = "SELECT IDVara FROM tbvara WHERE Varunamn =
'$prefix$articleNumberManufacturer' LIMIT 1;";
$querys = mysql_query($sql);
$dbArray = mysql_fetch_array($querys);
$IDVara = $dbArray["IDVara"];
if ($IDVara == Null) {$IDVara = 0;}
//If product is found, then update saldo
//
if (intval($IDVara)>0) {
$sql = "UPDATE tbvara SET Saldo=$saldo WHERE IDVara=$IDVara LIMIT 1;";
$querys = mysql_query($sql);
echo "QUERY DB -> $sql<br>";
}
//END Articlenr exists in line
}
}
mysql_close();
}
?>
/G
varupiraten.se
--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 2005-01-19
attached mail follows:
Wiberg wrote:
> Hi!
>
> I wonder if I can optimize following code (or do something better) below?
> It works fine when about 3.000 rows exists in the textfile, but when it gets
> to 10.000 rows then it will get a session timeout. (or internal server
> error)
I assume the func gets called for every row in the textfile.
If you are not worried about exactly how long it takes then unset
the timeout on the script, e.g.:
set_time_limit(0);
and checkout this function also:
http://nl2.php.net/manual/en/function.ignore-user-abort.php
>
>
> <?php
>
> function checkSaldo($url, $articleNrFieldNr, $saldoFieldNr, $separator,
> $startLine, $prefix) {
>
> require ("phpfunctions/opendb.php");
this require() can live outside the function, that saves 3000+ calls to it.
>
> //Read in specified file into array
> //
> $fileArray = file($url);
oops! I wasn't reading properly,
obviously the function is called once and the iteration happens inside it...
you grab the whole contents of the file at once - potentially storing a 10000
item array in memory, why not check out some of the other 'file' functions
(like fgets(), which allows you to grab 1 line at a time)
>
> //Go through array
> //
> for ($i=$startLine;$i<count($fileArray);$i++) {
ARGH!!! at the very least change this line to:
$cFA = count($fileArray);
for ($i=$startLine;$i<$cFA;$i++) {
that will save 3000+ calls to count().
>
> //Get line of file (through array)
> //
> $lineRead = $fileArray[$i];
>
>
> //Make array of all "elements" in this line
> //
> $lineArray = explode("$separator",$lineRead);
>
>
> //Get manufacturers articlenumber
> //
> if (isset($lineArray[$articleNrFieldNr])) {
>
> $articleNumberManufacturer = $lineArray[$articleNrFieldNr];
>
> }
>
> else {
>
> $articleNumberManufacturer = 0;
>
> }
>
>
> //Get saldo for this product
> //
> if (isset($lineArray[$articleNrFieldNr])) {
>
> $saldo = $lineArray[$saldoFieldNr];
>
> }
>
> else {
>
> $saldo = 0;
>
> }
>
> //There is no data on this row
> //set saldo and articlenr to zero, so nothing happens
> //
> if (strlen($lineRead)==0) {
>
> $saldo = 0;
> $articleNumberManufacturer = 0;
>
> }
>
>
> //echo "<br>ARTICLENR: $articleNumberManufacturer<br>";
> //echo "SALDO: $saldo<br>";
>
>
>
> //Articlenr exists in line
> //
> if (intval($articleNumberManufacturer)>0) {
>
>
> //Get ID of product (if there is any in varupiratens db)
> //skip the product if the saldo is the same as in
> //the textfile
> //
> $sql = "SELECT IDVara FROM tbvara WHERE Varunamn =
> '$prefix$articleNumberManufacturer' LIMIT 1;";
> $querys = mysql_query($sql);
> $dbArray = mysql_fetch_array($querys);
> $IDVara = $dbArray["IDVara"];
> if ($IDVara == Null) {$IDVara = 0;}
maybe cache this result of this query, assuming it returns repetetive values?
although if the cache (array?) grows too large then that might slow it down again...
double edged sword.
>
>
> //If product is found, then update saldo
> //
> if (intval($IDVara)>0) {
considering the UPDATE query, you can probably drop the call to intval():
if ($IDVara > 0) {
>
> $sql = "UPDATE tbvara SET Saldo=$saldo WHERE IDVara=$IDVara LIMIT 1;";
I don't think the semicolon in the sql statement should be passed according to official
docs, although I guess it works anyway :-)
> $querys = mysql_query($sql);
> echo "QUERY DB -> $sql<br>";
also if you are using a very new version of MySQL _I_think_ you have the ability to
use prepared queries - i.e. a query where the statement, with some placeholders is
compiled once and then you execute the prepared query x number of times each time
passing the 'execute()' func the relevant vars. this is as opposed to what you are doing
now which is having the query compiled for every line you parse.
prepared queries may not be an option.
>
> }
>
> //END Articlenr exists in line
> }
>
> }
> mysql_close();
> }
>
> ?>
>
> /G
>
varupiraten.se
>
> --
> Internal Virus Database is out-of-date.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 2005-01-19
>
attached mail follows:
yes, i recommend reading the file into a buffer and saving out the
part you actually need. that way the buffer can only be so big, and
you only keep what you really need...
On Wed, 26 Jan 2005 10:27:35 +0100, Jochem Maas <jochem
iamjochem.com> wrote:
> Wiberg wrote:
> > Hi!
> >
> > I wonder if I can optimize following code (or do something better) below?
> > It works fine when about 3.000 rows exists in the textfile, but when it gets
> > to 10.000 rows then it will get a session timeout. (or internal server
> > error)
>
> I assume the func gets called for every row in the textfile.
> If you are not worried about exactly how long it takes then unset
> the timeout on the script, e.g.:
>
> set_time_limit(0);
>
> and checkout this function also:
> http://nl2.php.net/manual/en/function.ignore-user-abort.php
>
> >
> >
> > <?php
> >
> > function checkSaldo($url, $articleNrFieldNr, $saldoFieldNr, $separator,
> > $startLine, $prefix) {
> >
> > require ("phpfunctions/opendb.php");
>
> this require() can live outside the function, that saves 3000+ calls to it.
>
> >
> > //Read in specified file into array
> > //
> > $fileArray = file($url);
>
> oops! I wasn't reading properly,
> obviously the function is called once and the iteration happens inside it...
>
> you grab the whole contents of the file at once - potentially storing a 10000
> item array in memory, why not check out some of the other 'file' functions
> (like fgets(), which allows you to grab 1 line at a time)
>
> >
> > //Go through array
> > //
> > for ($i=$startLine;$i<count($fileArray);$i++) {
>
> ARGH!!! at the very least change this line to:
>
> $cFA = count($fileArray);
> for ($i=$startLine;$i<$cFA;$i++) {
>
> that will save 3000+ calls to count().
>
> >
> > //Get line of file (through array)
> > //
> > $lineRead = $fileArray[$i];
> >
> >
> > //Make array of all "elements" in this line
> > //
> > $lineArray = explode("$separator",$lineRead);
> >
> >
> > //Get manufacturers articlenumber
> > //
> > if (isset($lineArray[$articleNrFieldNr])) {
> >
> > $articleNumberManufacturer = $lineArray[$articleNrFieldNr];
> >
> > }
> >
> > else {
> >
> > $articleNumberManufacturer = 0;
> >
> > }
> >
> >
> > //Get saldo for this product
> > //
> > if (isset($lineArray[$articleNrFieldNr])) {
> >
> > $saldo = $lineArray[$saldoFieldNr];
> >
> > }
> >
> > else {
> >
> > $saldo = 0;
> >
> > }
> >
> > //There is no data on this row
> > //set saldo and articlenr to zero, so nothing happens
> > //
> > if (strlen($lineRead)==0) {
> >
> > $saldo = 0;
> > $articleNumberManufacturer = 0;
> >
> > }
> >
> >
> > //echo "<br>ARTICLENR: $articleNumberManufacturer<br>";
> > //echo "SALDO: $saldo<br>";
> >
> >
> >
> > //Articlenr exists in line
> > //
> > if (intval($articleNumberManufacturer)>0) {
> >
> >
> > //Get ID of product (if there is any in varupiratens db)
> > //skip the product if the saldo is the same as in
> > //the textfile
> > //
> > $sql = "SELECT IDVara FROM tbvara WHERE Varunamn =
> > '$prefix$articleNumberManufacturer' LIMIT 1;";
> > $querys = mysql_query($sql);
> > $dbArray = mysql_fetch_array($querys);
> > $IDVara = $dbArray["IDVara"];
> > if ($IDVara == Null) {$IDVara = 0;}
>
> maybe cache this result of this query, assuming it returns repetetive values?
> although if the cache (array?) grows too large then that might slow it down again...
> double edged sword.
>
> >
> >
> > //If product is found, then update saldo
> > //
> > if (intval($IDVara)>0) {
>
> considering the UPDATE query, you can probably drop the call to intval():
>
> if ($IDVara > 0) {
>
> >
> > $sql = "UPDATE tbvara SET Saldo=$saldo WHERE IDVara=$IDVara LIMIT 1;";
>
> I don't think the semicolon in the sql statement should be passed according to official
> docs, although I guess it works anyway :-)
>
> > $querys = mysql_query($sql);
> > echo "QUERY DB -> $sql<br>";
>
> also if you are using a very new version of MySQL _I_think_ you have the ability to
> use prepared queries - i.e. a query where the statement, with some placeholders is
> compiled once and then you execute the prepared query x number of times each time
> passing the 'execute()' func the relevant vars. this is as opposed to what you are doing
> now which is having the query compiled for every line you parse.
>
> prepared queries may not be an option.
>
> >
> > }
> >
> > //END Articlenr exists in line
> > }
> >
> > }
> > mysql_close();
> > }
> >
> > ?>
> >
> > /G
> >
varupiraten.se
> >
> > --
> > Internal Virus Database is out-of-date.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 2005-01-19
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
The Disguised Jedi
disguised.jedi
gmail.com
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"
Disclaimer: Any disclaimer attached to this message may be ignored.
This message is Certified Virus Free
attached mail follows:
On Tue, 2005-01-25 at 07:53, Joey wrote:
> I'm not too good with classes, in the below class I can get the hit counter
> to write to the hit counter file, but I can't get it to write the log file,
> I know security is done correctly on the file because it's the same as the
> counter log file, but I can't figure out why the other file isn't being
> written to.
> Also while the IP address works within the code prior to calling the class
>
> function writeLog()
> {
> $ip_address=$REMOTE_ADDR;
> $date_stamp=date("F j, Y, g:i a");
> $log_entry=$date_stamp . " : " . $ip_address . "\n" ;
> echo "TEST-> " . $log_entry ;
> $log = fopen($this->log_file,"w+");
> fputs($log,$this->$log_entry );
> fclose($log);
>
you set $log_entry but write $this->log_entry which does not exist.
try fputs($log,$log_entry );
HTH
Bret
attached mail follows:
That was it Bret, thanks for pointing out my blindess...
Joey
-----Original Message-----
From: Bret Hughes [mailto:bhughes
elevating.com]
Sent: Wednesday, January 26, 2005 12:34 AM
To: php general list
Subject: Re: [PHP] Help with file not writing
On Tue, 2005-01-25 at 07:53, Joey wrote:
> I'm not too good with classes, in the below class I can get the hit
> counter to write to the hit counter file, but I can't get it to write
> the log file, I know security is done correctly on the file because
> it's the same as the counter log file, but I can't figure out why the
> other file isn't being written to.
> Also while the IP address works within the code prior to calling the
> class
>
> function writeLog()
> {
> $ip_address=$REMOTE_ADDR;
> $date_stamp=date("F j, Y, g:i a");
> $log_entry=$date_stamp . " : " . $ip_address . "\n" ;
> echo "TEST-> " . $log_entry ;
> $log = fopen($this->log_file,"w+");
> fputs($log,$this->$log_entry );
> fclose($log);
>
you set $log_entry but write $this->log_entry which does not exist.
try fputs($log,$log_entry );
HTH
Bret
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
attached mail follows:
Hello
Creating a three dimensional menu system is pretty easy with arrays, but when you want to create a menu system that is 10 or 15 levels deep using arrays the conventional method is not so simple.
I'm writing an application that shows a multi level (up to 30 levels) menu which is generated dynamically not in any particular order. There are three stages:
First stage, generates the levels of the menu and assigns titles,
Second stage needs to come the levels and change its properties, ie icon, font, colour, etc. This is a critical part of the process as the menus are not generated in any order and this stage also changes the properties of the level not in any particular order.
The third stage needs to display this menu.
My search on hotscripts and google didn't turn up anything that's relevant.
I know I can write a recursive function for each of these stages, but thats not the best method.
This is what I have so far:
for the purpose of this email all menu items are called elements and their property is an array:
element["parent"] = some other menu element (always an integer) assuming that 0 is the root
element["title"] = title
element["color"] = etc,etc.
For the first stage:
The first stage assigns the level and the title. A function like add_element( parentof, $element), function delete_element(parentof, $element) function move_elelement(newparentof, oldparentof, $element)
to maintain the tracking and consistency each element will be added to the $v_menu varible as follows:
$c is incremented for each function add_element where a new level exists
$c_child is just a counter of the current element
$v_menu[ $c ]["number of children"] = int
$v_menu[ $c ]["parentof"] = parent of this child, 0 is root.
$v_menu[ $c ][ $c_child ] = $element
second stage
function change_title(parentof, $element)
this is where I am conteplating ....
third stage
just a recursive function to show it all in order for proper html display. ?
the goal is something like this:
|
|---Menu 1
| |-------Child of 1
| |------------Child of (1, 1)
| | |-------------------Child of(1,1,1)
| |------------Child of (1,1)
| |--------------------Child of (1,1,2)
| |--------------------Child of (1,1,2)
| |----------------------Child of (1,1,2,2)
Perhaps my approach is wrong on this ? Is there a cleaner method ?
Thanks
Marek
attached mail follows:
Hello
Creating a three dimensional menu system is pretty easy with arrays, but
when you want to create a menu system that is 10 or 15 levels deep using
arrays the conventional method is not so simple.
I'm writing an application that shows a multi level (up to 30 levels) menu
which is generated dynamically not in any particular order. There are three
stages:
First stage, generates the levels of the menu and assigns titles,
Second stage needs to come the levels and change its properties, ie icon,
font, colour, etc. This is a critical part of the process as the menus are
not generated in any order and this stage also changes the properties of the
level not in any particular order.
The third stage needs to display this menu.
My search on hotscripts and google didn't turn up anything that's relevant.
I know I can write a recursive function for each of these stages, but thats
not the best method.
This is what I have so far:
for the purpose of this email all menu items are called elements and their
property is an array:
element["parent"] = some other menu element (always an integer) assuming
that 0 is the root
element["title"] = title
element["color"] = etc,etc.
For the first stage:
The first stage assigns the level and the title. A function like
add_element( parentof, $element), function delete_element(parentof,
$element) function move_elelement(newparentof, oldparentof, $element)
to maintain the tracking and consistency each element will be added to the
$v_menu varible as follows:
$c is incremented for each function add_element where a new level exists
$c_child is just a counter of the current element
$v_menu[ $c ]["number of children"] = int
$v_menu[ $c ]["parentof"] = parent of this child, 0 is root.
$v_menu[ $c ][ $c_child ] = $element
second stage
function change_title(parentof, $element)
this is where I am conteplating ....
third stage
just a recursive function to show it all in order for proper html display. ?
the goal is something like this:
|
|---Menu 1
| |-------Child of 1
| |------------Child of (1, 1)
| | |-------------------Child of(1,1,1)
| |------------Child of (1,1)
| |--------------------Child of (1,1,2)
| |--------------------Child of (1,1,2)
|
|----------------------Child of (1,1,2,2)
Perhaps my approach is wrong on this ? Is there a cleaner method ?
Thanks
Marek
attached mail follows:
Marek wrote:
> Hello
>
> Creating a three dimensional menu system is pretty easy with arrays, but
> when you want to create a menu system that is 10 or 15 levels deep using
> arrays the conventional method is not so simple.
>
> I'm writing an application that shows a multi level (up to 30 levels) menu
> which is generated dynamically not in any particular order. There are three
> stages:
>
> First stage, generates the levels of the menu and assigns titles,
> Second stage needs to come the levels and change its properties, ie icon,
> font, colour, etc. This is a critical part of the process as the menus are
> not generated in any order and this stage also changes the properties of the
> level not in any particular order.
> The third stage needs to display this menu.
>
> My search on hotscripts and google didn't turn up anything that's relevant.
> I know I can write a recursive function for each of these stages, but thats
> not the best method.
One recursive function that will take care of all stages.
I'm not sure what table design you desided use, at level this deep you
might use Flat Table or Modified Preorder Tree Traversal Algorithm:
http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/
attached mail follows:
Hiya Marek K,
Thanks for the link, however on that page the links regarding a "Modified
Preorder Tree Traversal Algorithm" come up as 404. I would prefer not to use
recursion until the third stage (display of menu). In fact I know, I will
not use recursion for the first or second, simply because for each
addition/change a recursion seems and is an overkill. The idea here is to
have very elegant and simple code that can also be used in other
classes/projects. I'm pretty much going to stick to what I have already
where the only recursion that occurs is in the third stage (display of
menu).
One thing I forgot to add to in my original email is that the $element
property also has an order id(int) for displaying the menus in particular
order.
My first and the second stage allow me to change/add elements directly
without searching for them. Whereas the display does a recursion that
displays in order. All of this done within php, so first and the second
stage in reality is like an indexed stack. The third stage might get a
little tricky due to the order property... if you have any ideas/tricks,
please let me know.
Thanks
Marek J
----- Original Message -----
From: "Marek Kilimajer" <lists
kilimajer.net>
To: "Marek" <marek
foundmoney.com>
Cc: <php-general
lists.php.net>
Sent: Wednesday, January 26, 2005 5:49 AM
Subject: Re: [PHP] Working with Multi by Multi levels menu
> Marek wrote:
> > Hello
> >
> > Creating a three dimensional menu system is pretty easy with arrays, but
> > when you want to create a menu system that is 10 or 15 levels deep using
> > arrays the conventional method is not so simple.
> >
> > I'm writing an application that shows a multi level (up to 30 levels)
menu
> > which is generated dynamically not in any particular order. There are
three
> > stages:
> >
> > First stage, generates the levels of the menu and assigns titles,
> > Second stage needs to come the levels and change its properties, ie
icon,
> > font, colour, etc. This is a critical part of the process as the menus
are
> > not generated in any order and this stage also changes the properties of
the
> > level not in any particular order.
> > The third stage needs to display this menu.
> >
> > My search on hotscripts and google didn't turn up anything that's
relevant.
> > I know I can write a recursive function for each of these stages, but
thats
> > not the best method.
>
> One recursive function that will take care of all stages.
>
> I'm not sure what table design you desided use, at level this deep you
> might use Flat Table or Modified Preorder Tree Traversal Algorithm:
>
http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/404
7/
>
>
attached mail follows:
Marek wrote:
> Hiya Marek K,
>
> Thanks for the link, however on that page the links regarding a "Modified
> Preorder Tree Traversal Algorithm" come up as 404.
Then see:
http://www.sitepoint.com/article/hierarchical-data-database/2
I would prefer not to use
> recursion until the third stage (display of menu). In fact I know, I will
> not use recursion for the first or second, simply because for each
> addition/change a recursion seems and is an overkill. The idea here is to
> have very elegant and simple code that can also be used in other
> classes/projects. I'm pretty much going to stick to what I have already
> where the only recursion that occurs is in the third stage (display of
> menu).
>
> One thing I forgot to add to in my original email is that the $element
> property also has an order id(int) for displaying the menus in particular
> order.
>
> My first and the second stage allow me to change/add elements directly
> without searching for them. Whereas the display does a recursion that
> displays in order. All of this done within php, so first and the second
> stage in reality is like an indexed stack. The third stage might get a
> little tricky due to the order property... if you have any ideas/tricks,
> please let me know.
I think flat table model is suited for you just right. Updating it is a
little ugly but it's not that big deal.
You can also think about caching the result.
attached mail follows:
> Marek wrote:
> > Hiya Marek K,
> >
> > Thanks for the link, however on that page the links regarding a
"Modified
> > Preorder Tree Traversal Algorithm" come up as 404.
>
> Then see:
> http://www.sitepoint.com/article/hierarchical-data-database/2
This article is specifically for a database driven hierarchical data. Mine
has to be memory based(as little as possible), a sort of flat based but yet
efficient and elegant. I think I have a solution.. working on it now
Thanks
>
> I would prefer not to use
> > recursion until the third stage (display of menu). In fact I know, I
will
> > not use recursion for the first or second, simply because for each
> > addition/change a recursion seems and is an overkill. The idea here is
to
> > have very elegant and simple code that can also be used in other
> > classes/projects. I'm pretty much going to stick to what I have already
> > where the only recursion that occurs is in the third stage (display of
> > menu).
> >
> > One thing I forgot to add to in my original email is that the $element
> > property also has an order id(int) for displaying the menus in
particular
> > order.
> >
> > My first and the second stage allow me to change/add elements directly
> > without searching for them. Whereas the display does a recursion that
> > displays in order. All of this done within php, so first and the second
> > stage in reality is like an indexed stack. The third stage might get a
> > little tricky due to the order property... if you have any ideas/tricks,
> > please let me know.
>
> I think flat table model is suited for you just right. Updating it is a
> little ugly but it's not that big deal.
>
> You can also think about caching the result.
>
>
attached mail follows:
Maybe its time to kill this thread?
I think Jason and Richard (others) have done a brilliant
job of explaining how AND why, many thanks to them.
Anyone not yet convinced should probably take a maths course ]
(i.e. pay someone for the teachings ;-)
rgds,
Jochem
Jason Barnett wrote:
> Bruce Douglas wrote:
>
>> no..
>>
>> he didn't.
>
>
...
attached mail follows:
Many thanks to all for clarifiying this. Finally I could remember some
things and understand why things go that way.
Thanks again.
Jordi.
attached mail follows:
Devraj Mukherjee wrote:
> Yes that is the sort of stuff we are looking at. Objects will be able to
> live endlessly, we are planning to address issues such as DB connection
> pooling, etc.
>
> For those who wish to learn more about app servers, I recommend you
> looking at some of the Java stuff
>
> http://java.sun.com/j2ee/
> http://jboss.org/
>
> We will be releasing the specs soon, so you guys can have a look at what
> we are upto.
I look forward to it. who knows what it might become!
>
> Are most guys here Unix users?
generally (from the impression I get, and taken from my own experience):
1. new phpers often run on windows, with an idea to moving to company/shared hosting
in *nix boxes (although the phper may have little experience of *nix)
2. more experienced users are familiar with *nix and most often develop on linux
(quite often I see people run dual-boot development machines)
3. the most advanced users generally make the most use of *nix variants, MacOSX, FreeBSD,
Solaris etc being more exotic (and less used).
in short, on the 'low' end there is lots of windows only uses on the 'higher' end alot of
*nix usage with a predominance of linux.
at the end of the day most production webservers running php sites/apps are LAMP based,
if only due to the economics. (free is hard to beat, especially when it class kit so to speak)
so I imagine the compentency of the 'group' would generally be be focused around
Linux, Apache based systems - if you can build a _transparent_ app server that plugs directly
into that setup you may very well have a winner (?)
maybe others see it differently?
>
> Devraj
>
> Jochem Maas wrote:
>
>>
>>
>> I'm assuming he means a process which contains/maintain 'space'
>> for long term classes/objects/vars/etc which instantly available
>> in every request space and sharable across requests (of different users)
>>
>> so you could do something like (just a thought):
>>
>> startMyApp('OfficeCalendar');
>>
>> and then you script could talk to objects that exist server wide
>> for everyone as if they were objects taken from the session or
>> created in that particular request.
>>
>> am I even close?
>>
>
>
attached mail follows:
Joe Harman wrote:
>Hey Andrew...
>
>IN MY OPINION... forget the cookies... only use php sessions... but
>like I said IMO.... you can never rely on the end user having them
>cookies enabled... same with things like javascript...
>
>let me outline some steps for you... everyone else... feel free to
>state pros and cons to theses.. cause i always make mistakes, or
>forget things :o)
>
>1. get the user's access info... ie username & password
>
>2. look for the user in the database that stores the access infro
>
>3. if access is granted, I usually set 2 session variables
> a. $_SESSION['auth'] = TRUE // They are authorized
> b. $_SESSION['user_id'] = {who} // Who is it
> a. $_SESSION['user_level'] = {level} // What level access do
>they have (optional)
>
>4. at the beginning of each restricted access page, verify that they
>are authorized to access that page... if they are not redirect them to
>a access denied page.
>
>
>that should get you started... maybe the second step would be to make
>this stuff into functions... ... also, IMO.. it's a good idea to make
>a logout script that will distroy that user's active session...
>
my turn for an IMO :) - my preference is to have a check on the function
that writes the $_SESSION vars or the cookie (I generally use encrypted
cookies which are in turn restricted to certain areas of the site). This
check is on the referer - if it's not from a foreign URL, then write
them new as if the user is non auth. This stops people on public
machines from hitting a back button and being authenticated as the
previous user.
Tom
> not
>sure what your PHP experience is... but hopefully the above steps will
>help you out some..
>
>Cheers!
>Joe
>
>
>
>
>
>On 25 Jan 2005 17:35:08 -0600, Bret Hughes <bhughes
elevating.com> wrote:
>
>
>>On Tue, 2005-01-25 at 16:45, AceZero2790
aol.com wrote:
>>
>>
>>>Hey,
>>> I need a particular type log in script. I'm not sure how to do it or
>>>where I could find a tutorial that would help me, so I'll describe what I need
>>>and then maybe someone could tell me what kind of script I need (sessions or
>>>whatever) and where I could get the script/learn how to make it.
>>> I need a pretty basic log in script. Something that people log in to,
>>>and the page and all linked/related pages cannot be accessed unless the person
>>>has logged in.
>>> So what do I need for this? Cookies, sessions both? And where can I
>>>learn how?
>>>
>>>-Andrew
>>>
>>>
>>I use the pear auth package and like it alot. I know I did some
>>modification for our purposes but I suspect it works out of the box.
>>
>>All you do is include auth.php on all pages you want to protect and it
>>will direct you to a login page if you have not logged in. Pretty cool
>>stuff.
>>
>>http://pear.php.net/package/Auth
>>HTH
>>
>>Bret
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>
>
attached mail follows:
Tom,
That's a great tip!
Joe
On Wed, 26 Jan 2005 10:03:31 +0000, Tom <tom
cumbriankitchen.co.uk> wrote:
> Joe Harman wrote:
>
> >Hey Andrew...
> >
> >IN MY OPINION... forget the cookies... only use php sessions... but
> >like I said IMO.... you can never rely on the end user having them
> >cookies enabled... same with things like javascript...
> >
> >let me outline some steps for you... everyone else... feel free to
> >state pros and cons to theses.. cause i always make mistakes, or
> >forget things :o)
> >
> >1. get the user's access info... ie username & password
> >
> >2. look for the user in the database that stores the access infro
> >
> >3. if access is granted, I usually set 2 session variables
> > a. $_SESSION['auth'] = TRUE // They are authorized
> > b. $_SESSION['user_id'] = {who} // Who is it
> > a. $_SESSION['user_level'] = {level} // What level access do
> >they have (optional)
> >
> >4. at the beginning of each restricted access page, verify that they
> >are authorized to access that page... if they are not redirect them to
> >a access denied page.
> >
> >
> >that should get you started... maybe the second step would be to make
> >this stuff into functions... ... also, IMO.. it's a good idea to make
> >a logout script that will distroy that user's active session...
> >
> my turn for an IMO :) - my preference is to have a check on the function
> that writes the $_SESSION vars or the cookie (I generally use encrypted
> cookies which are in turn restricted to certain areas of the site). This
> check is on the referer - if it's not from a foreign URL, then write
> them new as if the user is non auth. This stops people on public
> machines from hitting a back button and being authenticated as the
> previous user.
> Tom
>
> > not
> >sure what your PHP experience is... but hopefully the above steps will
> >help you out some..
> >
> >Cheers!
> >Joe
> >
> >
> >
> >
> >
> >On 25 Jan 2005 17:35:08 -0600, Bret Hughes <bhughes
elevating.com> wrote:
> >
> >
> >>On Tue, 2005-01-25 at 16:45, AceZero2790
aol.com wrote:
> >>
> >>
> >>>Hey,
> >>> I need a particular type log in script. I'm not sure how to do it or
> >>>where I could find a tutorial that would help me, so I'll describe what I need
> >>>and then maybe someone could tell me what kind of script I need (sessions or
> >>>whatever) and where I could get the script/learn how to make it.
> >>> I need a pretty basic log in script. Something that people log in to,
> >>>and the page and all linked/related pages cannot be accessed unless the person
> >>>has logged in.
> >>> So what do I need for this? Cookies, sessions both? And where can I
> >>>learn how?
> >>>
> >>>-Andrew
> >>>
> >>>
> >>I use the pear auth package and like it alot. I know I did some
> >>modification for our purposes but I suspect it works out of the box.
> >>
> >>All you do is include auth.php on all pages you want to protect and it
> >>will direct you to a login page if you have not logged in. Pretty cool
> >>stuff.
> >>
> >>http://pear.php.net/package/Auth
> >>HTH
> >>
> >>Bret
> >>
> >>--
> >>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
>
>
attached mail follows:
On Tue, 25 Jan 2005 17:02:21 -0800, Chris <listschris
leftbrained.org> wrote:
> You should probably use get_magic_quotes_runtime() , as _gpc only
> applies to GET/POST/COOKIE,
>
> htmlspecialchars is needed so the HTML can be parsed properly:
So this is this only done to stuff that is to be displayed on a web
page? What happens if it is done to stuff that is (possibly) also
passed through addslashes and written to the database. Also douse it
matter what order htmlspecialcharacters/addslashes???
However this is the least of my problems, I still dont have the main
magic quotes thing working. So I will detail what I am doing and c if
anyone can help.
Everything that comes from the database (regardless of what is done to
it next) is passed through the following function.
function unprep( $text ) {
// Take data coming from the database an get it ready to be presented
// to the user.
if ( get_magic_quotes_gpc() ){
$result = stripslashes($text);
} else{
$result = $text;
}
$result = htmlspecialchars( $result );
return $result;
}
This is done regardless of what is to be done to the data by using
foreach on the row that is returned.
foreach( $this->record as $index => $value ) {
$this->record[$index] = unprep( $value );
}
And before anything is written to the database it goes through the
following function.
function prep( &$text ) {
if ( get_magic_quotes_gpc() ) {
return $text;
} else {
return addslashes($text);
}
}
But I am still getting the \', \\' thing happening. One of my
problems is I am not sure at how to reliably look at the data at
various stages. If I do echo $value and it has \' in it is '\
displayed or or is ' displayed. I.e. is it only in the <input
type=text tag that the \' shows up.
Thanks for every body's help, hope I am nearly there;)
Ben
> if the value in the text box was something like:
>
> "> Hello World!
>
> when you go to put in the value attribute it would end up:
>
> <input type="text" value=""> Hello World!" />
>
> That would not parse correctly.
>
> but if you escaped it with htmlspecialchars or htmlentities you'd get:
>
> <input type="text" value=""> Hello World!" />
>
> And the box would contain the proper data
>
>
> Ben Edwards wrote:
>
> >PS. How does htmlspecialchars fit into this. The unprep function is
> >to prepare date coming from the database to be used in <input
> >type=text, douse the below function make sence?
> >
> >Ben
> >
> >function unprep( $text ) {
> > // Take data coming from the database an get it ready to be presented
> > // to the user.
> >
> > if (magic_quotes_gpc()){
> > $result = stripslashes($text);
> > }
> > else{
> > $result = $text;
> > }
> >
> > return htmlspecialchars( $result );
> >}
> >--
> >Ben Edwards - Poole, UK, England
> >WARNING:This email contained partisan views - dont ever accuse me of
> >using the veneer of objectivity
> >If you have a problem emailing me use
> >http://www.gurtlush.org.uk/profiles.php?uid=4
> >(email address this email is sent from may be defunct)
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)
attached mail follows:
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
> -----Original Message-----
> From: Ben Edwards [mailto:funkytwig
gmail.com]
> Sent: 26 January 2005 10:15
>
> On Tue, 25 Jan 2005 17:02:21 -0800, Chris
> <listschris
leftbrained.org> wrote:
> > You should probably use get_magic_quotes_runtime() , as _gpc only
> > applies to GET/POST/COOKIE,
> >
> > htmlspecialchars is needed so the HTML can be parsed properly:
>
> So this is this only done to stuff that is to be displayed on
> a web page? What happens if it is done to stuff that is
> (possibly) also passed through addslashes and written to the
> database.
You get HTML entities in your database. This may not matter if all you do
is use your database to make Web pages, but it's generally regarded as
better form to store the text in clear in the database and convert it to the
appropriate format for display at the time you want to display it.
> Also douse it matter what order
> htmlspecialcharacters/addslashes???
Yes.
htmlspecialchars(addslashes('"')) => \"
addslashes(htmlspecialchars('"')) => "
> Everything that comes from the database (regardless of what
> is done to it next) is passed through the following function.
>
> function unprep( $text ) {
> // Take data coming from the database an get it ready to
> be presented
> // to the user.
> if ( get_magic_quotes_gpc() ){
This should be magic_quotes_runtime(), since you are dealing with data
obtained from the database at run time, not data passed via Get, Post or
Cookie.
> $result = stripslashes($text);
> } else{
> $result = $text;
> }
> $result = htmlspecialchars( $result );
> return $result;
> }
> And before anything is written to the database it goes
> through the following function.
>
> function prep( &$text ) {
> if ( get_magic_quotes_gpc() ) {
> return $text;
> } else {
> return addslashes($text);
> }
> }
That one looks good to go, assuming your database uses \ as an escaping
character.
>
> But I am still getting the \', \\' thing happening. One of
> my problems is I am not sure at how to reliably look at the
> data at various stages. If I do echo $value and it has \' in
> it is '\ displayed or or is ' displayed.
If you echo a value that really does contain \', you will get \' displayed.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS,
LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
Hi
I've just installed Apache 2.0.52, with:
./configure --prefix=/usr/local/httpd --enable-so
--enable-modules=all
My httpd.conf includes:
-----------------------------------
<VirtualHost mydomain>
ServerAdmin f...
mydomain
DocumentRoot "/home/mydomain"
ServerName mydomain
ErrorLog logs/mydomain-error_log
CustomLog logs/mydomain-access_log common
DirectoryIndex index.php index.html index.html.var
<Directory "/home/mydomain">
php_flag allow_url_fopen 1
php_flag magic_quotes_gpc 0
RewriteEngine on
RewriteOptions MaxRedirects=15
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /$1.php
</Directory>
</VirtualHost>
---------------------------------
(I try to make Apache serve 'foo' as 'foo.php')
But when accessing 'http://mydomain/foo', I get no
webpage,
but this error log:
----------------------------------
[Mon Jan 24 10:47:59 2005] [debug]
mod_rewrite.c(1778): [client
192.168.2.101] mod_rewrite's internal redirect status:
10/15.
[Mon Jan 24 10:47:59 2005] [error] [client
192.168.2.101] Request
exceeded the limit of 10 internal redirects due to
probable
configuration error. Use 'LimitInternalRecursion' to
increase the limit
if necessary. Use 'LogLevel debug' to get a backtrace.
[Mon Jan 24 10:47:59 2005] [debug] core.c(2748):
[client 192.168.2.101]
r->uri =
/favicon.ico.php.php.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php
--------------------------------
If I remove the line 'RewriteOptions MaxRedirects=15',
I get
a very similar error:
----------------------------
[Wed Jan 24 10:31:29 2005] [debug]
mod_rewrite.c(1778): [client 192.168.2.101]
mod_rewrite's internal redirect status: 10/10.
[Wed Jan 24 10:31:29 2005] [error] [client
192.168.2.101] mod_rewrite: maximum number of internal
redirects reached. Assuming configuration error. Use
'RewriteOptions MaxRedirects' to increase the limit if
neccessary.
[Wed Jan 24 10:31:29 2005] [debug]
mod_rewrite.c(1778): [client 192.168.2.101]
mod_rewrite's internal redirect status: 0/10.
-------------------------------
What am I doing wrong? Thank you very much.
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
attached mail follows:
James Guarriman wrote:
>Hi
>
>I've just installed Apache 2.0.52, with:
>
>./configure --prefix=/usr/local/httpd --enable-so
>--enable-modules=all
>
>My httpd.conf includes:
>-----------------------------------
><VirtualHost mydomain>
>ServerAdmin f...
mydomain
>DocumentRoot "/home/mydomain"
>ServerName mydomain
>ErrorLog logs/mydomain-error_log
>CustomLog logs/mydomain-access_log common
>DirectoryIndex index.php index.html index.html.var
><Directory "/home/mydomain">
>php_flag allow_url_fopen 1
>php_flag magic_quotes_gpc 0
>RewriteEngine on
>RewriteOptions MaxRedirects=15
>RewriteCond %{REQUEST_FILENAME} !-d
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteRule ^(.*)$ /$1.php
></Directory>
></VirtualHost>
>---------------------------------
>(I try to make Apache serve 'foo' as 'foo.php')
>
>But when accessing 'http://mydomain/foo', I get no
>webpage,
>but this error log:
>----------------------------------
>[Mon Jan 24 10:47:59 2005] [debug]
>mod_rewrite.c(1778): [client
>192.168.2.101] mod_rewrite's internal redirect status:
>10/15.
>[Mon Jan 24 10:47:59 2005] [error] [client
>192.168.2.101] Request
>exceeded the limit of 10 internal redirects due to
>probable
>configuration error. Use 'LimitInternalRecursion' to
>increase the limit
>if necessary. Use 'LogLevel debug' to get a backtrace.
>[Mon Jan 24 10:47:59 2005] [debug] core.c(2748):
>[client 192.168.2.101]
>r->uri =
>/favicon.ico.php.php.php.php.php.php.php.php.php.php
>[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
>[client 192.168.2.101]
>redirected from r->uri =
>/favicon.ico.php.php.php.php.php.php.php.php.php
>[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
>[client 192.168.2.101]
>redirected from r->uri =
>/favicon.ico.php.php.php.php.php.php.php.php
>[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
>[client 192.168.2.101]
>redirected from r->uri =
>/favicon.ico.php.php.php.php.php.php.php
>--------------------------------
>
>If I remove the line 'RewriteOptions MaxRedirects=15',
>I get
>a very similar error:
>----------------------------
>[Wed Jan 24 10:31:29 2005] [debug]
>mod_rewrite.c(1778): [client 192.168.2.101]
>mod_rewrite's internal redirect status: 10/10.
>[Wed Jan 24 10:31:29 2005] [error] [client
>192.168.2.101] mod_rewrite: maximum number of internal
>redirects reached. Assuming configuration error. Use
>'RewriteOptions MaxRedirects' to increase the limit if
>neccessary.
>[Wed Jan 24 10:31:29 2005] [debug]
>mod_rewrite.c(1778): [client 192.168.2.101]
>mod_rewrite's internal redirect status: 0/10.
>-------------------------------
>
>What am I doing wrong? Thank you very much.
>
>
What you are doing wrong is trying to use mod_rewrite, the nightmare
extension from hell!
Seriously though, it is your rewrite rule that is wrong, you have
defined a recursion in there for any filename that do not already end
'.php' or have no .
RewriteRule ^(.*)$ /$1.php => add '.php' to the end of any filename that has a '.' in it somewhere (remember that you are in unix world, so the . does not signify a file extension in the same way as a domestos environment, it is just part of the filename).
eg1) blah => blah (no change as it doesn't match the regex)
eg2) favicon.ico => favicon.ico.php
when the rule next runs, it finds that favicon.ico.php does not match the exception of .php (the .ico gives the first match), so adds .php again, and again, and again, and again.....
Tom
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail - 250MB free storage. Do more. Manage less.
>http://info.mail.yahoo.com/mail_250
>
>
>
attached mail follows:
James Guarriman wrote:
> Hi
>
> I've just installed Apache 2.0.52, with:
>
> ./configure --prefix=/usr/local/httpd --enable-so
> --enable-modules=all
>
> My httpd.conf includes:
> -----------------------------------
> <VirtualHost mydomain>
> ServerAdmin f...
mydomain
> DocumentRoot "/home/mydomain"
> ServerName mydomain
> ErrorLog logs/mydomain-error_log
> CustomLog logs/mydomain-access_log common
> DirectoryIndex index.php index.html index.html.var
> <Directory "/home/mydomain">
> php_flag allow_url_fopen 1
> php_flag magic_quotes_gpc 0
> RewriteEngine on
> RewriteOptions MaxRedirects=15
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ /$1.php
The above condition matches favicon.ico because it's neither directory
or file, so it's rewritten to favicon.ico.php, that again matches the
above condition...etc. So you need to come up with regexp that does not
match if the file extension is .php
> </Directory>
> </VirtualHost>
> ---------------------------------
> (I try to make Apache serve 'foo' as 'foo.php')
attached mail follows:
Hi,
I have a query where I select all table names where the table name has PID_1
in i.e.
SHOW TABLES LIKE '%PID_1%';
However there may be cases where I need to search for tables where the table
name is PID_1 or PID_2. In MySQL this can't be done in one query, so how can
I do two queries and combine the result set so I can loop through it?
Thanks for your help
attached mail follows:
Shaun wrote:
> Hi,
>
> I have a query where I select all table names where the table name has PID_1
> in i.e.
>
> SHOW TABLES LIKE '%PID_1%';
>
> However there may be cases where I need to search for tables where the table
> name is PID_1 or PID_2. In MySQL this can't be done in one query, so how can
> I do two queries and combine the result set so I can loop through it?
>
> Thanks for your help
UNION
attached mail follows:
Shaun wrote:
> Hi,
>
> I have a query where I select all table names where the table name has PID_1
> in i.e.
>
> SHOW TABLES LIKE '%PID_1%';
>
> However there may be cases where I need to search for tables where the table
> name is PID_1 or PID_2. In MySQL this can't be done in one query, so how can
> I do two queries and combine the result set so I can loop through it?
>
> Thanks for your help
>
SHOW TABLES REGEXP 'PID_[0-9]+';
attached mail follows:
Marek Kilimajer wrote:
> Shaun wrote:
>
>> Hi,
>>
>> I have a query where I select all table names where the table name has
>> PID_1 in i.e.
>>
>> SHOW TABLES LIKE '%PID_1%';
>>
>> However there may be cases where I need to search for tables where the
>> table name is PID_1 or PID_2. In MySQL this can't be done in one
>> query, so how can I do two queries and combine the result set so I can
>> loop through it?
>>
>> Thanks for your help
>
>
> SHOW TABLES REGEXP 'PID_[0-9]+';
>
nice! :-)
attached mail follows:
Hello,
I have these values:
8.26456
9.7654
3.0000
5.2689
and I want them rounded to two decimal places so I use the round :
round($value,2) which gives me, for example:
8.26
But, it also gives me 3 instead of 3.00. How can I round but retain the 0's?
Thanks!
attached mail follows:
use number_format()
Blackwater Dev wrote:
> Hello,
>
> I have these values:
>
> 8.26456
> 9.7654
> 3.0000
> 5.2689
>
> and I want them rounded to two decimal places so I use the round :
> round($value,2) which gives me, for example:
> 8.26
>
> But, it also gives me 3 instead of 3.00. How can I round but retain the 0's?
>
> Thanks!
attached mail follows:
You can use the number_format($number, decimal_places) function.
-----Original Message-----
From: blackwater dev [mailto:blackwaterdev
gmail.com]
Sent: 26 January 2005 01:33 PM
To: php-general
lists.php.net
Subject: [PHP] round
Hello,
I have these values:
8.26456
9.7654
3.0000
5.2689
and I want them rounded to two decimal places so I use the round :
round($value,2) which gives me, for example:
8.26
But, it also gives me 3 instead of 3.00. How can I round but retain the
0's?
Thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On Wed, 26 Jan 2005 06:32:32 -0500
blackwater dev <blackwaterdev
gmail.com> wrote:
> Hello,
>
> I have these values:
>
> 8.26456
> 9.7654
> 3.0000
> 5.2689
>
> and I want them rounded to two decimal places so I use the round :
> round($value,2) which gives me, for example:
> 8.26
You can try the sprintf() function
> But, it also gives me 3 instead of 3.00. How can I round but retain the 0's?
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
RE5PECT
Sergio Gorelyshev
attached mail follows:
attached mail follows:
john
kegworks.com (John Nichel) wrote in
news:41F6684A.3090209
kegworks.com:
> Jay Blanchard wrote:
>> [snip]
>> CR> Just a thought, but would it be worth someone posting the list
>> CR> once a week to catch new users as they sign up?
>>
>> Isn't it posted once a month as it is?
>> [/snip]
>>
>> It used to be, but it seems that it hasn't been posted in a while. So
>> I retrieved it and posted it. I was thinking about setting up a cron
>> to post it every other day or so.
>
> Didn't it used to get sent out to people when they subscribed to the
> list too? Anyone know if that still happens?
Well, i only accesses this list on usenet. I haven't subscribed to
anything.
--
Rolf
attached mail follows:
[snip]
Now, perhaps, an INTERESTING project for some of us to work on would be
that system:
Spec:
Robot subscriber to PHP-General.
Reads all incoming messages.
Discards anything that looks like a 'Reply:' including:
Has 'Re: ' or 'Fwd: " in subject
Has Message ID in-reply-to header thingies
Concats Subject and body, with signatures removed.
Removes all common English words
Searches for remaining [key]words in php.net/faq.php
If any matches, deep-link (with #xyz) to the FAQ answers.
If number of remaining [key]words (above) is small, also compose a URL
link to http://php.net/remaining+keywords
Creates a reply email (to original poster only) suggesting that maybe
they
just need to check those links, but to REPLY to their post if they're
STILL lost after reading all that stuff.
That way, if any of us see a question that we KNOW is answered in FAQ or
php.net/xyz and that is not a Reply of some kind, we can let the robot
handle it.
What do you think?
Worth doing?
Waste of time?
You interested in implementing or testing it?
Got a server where you control smrsh and whatnot enough to handle it?
[/snip]
I like it a lot. And I would be glad to put in my 0.02. As we are
developing a knowledge base for our internal users and this falls along
the same lines I would have to say to count me in.
attached mail follows:
[snip]
I'm not going to promise any of this. If someone else is willing to
donate the hardware to make this happen then contact me / the list. Of
course anyone else that wants to donate coding time is more than welcome
to join project ParrotHeadPoster. :)
I can already imagine it now...
"I'm a talking phParrot and I think I can help you. Try reading what
you find at the following link(s):
[/snip]
Cool, a ParrotHead reference and name for the project in one post. WTG
Jason!
attached mail follows:
[snip]
...lots of really good stuff...
[/snip]
So, basically I saw 3 possible action items from this discussion...
1. phParrot development
2. Weekly CRON of NEWBIE GUIDE (once I get the e-mail portion figured
out)
3. OT posts should contain a TIP or TRICK? If we did this we could
harvest them once in a while for dissemination to the group. How you
say? You could contain the tip in a tag, example...
[tip type="query error checking" author="Jay Blanchard"]
When issueing a query to the database I always find it healthy to do
error checking in this form
if(!($resultOfQuery = mysql_query($query, $databaseConnection))){
echo "This gave me an error " . mysql_error() . "\n";
exit();
}
If an error is thrown the application exits immediately so that I can
correct and move on.
[/tip]
As you can see, using some reasonable regex would get the tip out. Also,
when phParrot is up and running a tip can be given with each reply if a
databse of these tips was gathered. Someone then could gather all of the
tips, publish a book and make us all famous.
I may have had too much caffeine this AM -- looks like my enthusiasm
level is set to 'HIGH'
attached mail follows:
Jay Blanchard wrote:
> [snip]
> Now, perhaps, an INTERESTING project for some of us to work on would be
> that system:
>
> Spec:
> Robot subscriber to PHP-General.
> Reads all incoming messages.
> Discards anything that looks like a 'Reply:' including:
> Has 'Re: ' or 'Fwd: " in subject
> Has Message ID in-reply-to header thingies
> Concats Subject and body, with signatures removed.
> Removes all common English words
> Searches for remaining [key]words in php.net/faq.php
> If any matches, deep-link (with #xyz) to the FAQ answers.
> If number of remaining [key]words (above) is small, also compose a URL
> link to http://php.net/remaining+keywords
> Creates a reply email (to original poster only) suggesting that maybe
> they
> just need to check those links, but to REPLY to their post if they're
> STILL lost after reading all that stuff.
>
> That way, if any of us see a question that we KNOW is answered in FAQ or
> php.net/xyz and that is not a Reply of some kind, we can let the robot
> handle it.
>
> What do you think?
>
> Worth doing?
>
> Waste of time?
>
> You interested in implementing or testing it?
>
> Got a server where you control smrsh and whatnot enough to handle it?
> [/snip]
>
> I like it a lot. And I would be glad to put in my 0.02. As we are
> developing a knowledge base for our internal users and this falls along
> the same lines I would have to say to count me in.
>
I like the sound of it too.
shall we crystalize what we want/decided into a new post?
1. what we want: i.e. repository of list tips/solutions etc
2. a parrot
3. where to host
4. who/where to run the parrot
5. any other business
Jay maybe your the man for that job? not trying to force anything on you
but I reckon we could do with a 'lead man' of some sorts to do a little coordinating
and possibly just make a decision (avoid endless discusion about minutae)
Also I may have a machine capable of running the parrot - its on the same subnet as nl2.php.net
so connection speed is no probs but I have no idea how process intensive the parrot would be
(if its too heavy I would have to decline cos there are commercial site running on the same box
which expect a certain level of performance :-) ...paying customers, you get the picture!).
BTW ParrotHeadPoster is a fitting name, lets keep it!
attached mail follows:
Jay Blanchard wrote:
> [snip]
> ...lots of really good stuff...
> [/snip]
>
> So, basically I saw 3 possible action items from this discussion...
>
> 1. phParrot development
> 2. Weekly CRON of NEWBIE GUIDE (once I get the e-mail portion figured
> out)
> 3. OT posts should contain a TIP or TRICK? If we did this we could
> harvest them once in a while for dissemination to the group. How you
> say? You could contain the tip in a tag, example...
>
> [tip type="query error checking" author="Jay Blanchard"]
> When issueing a query to the database I always find it healthy to do
> error checking in this form
> if(!($resultOfQuery = mysql_query($query, $databaseConnection))){
> echo "This gave me an error " . mysql_error() . "\n";
> exit();
> }
> If an error is thrown the application exits immediately so that I can
> correct and move on.
> [/tip]
4. a website/subsite & related DB to store data for phParrot, tips, etc.
phparrot.net is up for grabs - I'm happy to register it (can't grace the list with
ace mathematical explainations :-) but I'm happy to shell out a few bucks as a way
of giving back a little) - and I'd just as happily transfer the domain into the hands
of an 'official' php organisation if and when people think its required (at no charge).
or maybe someone else want to register it?
also nobody seems to dare speak up regarding a 'front man'?
>
> As you can see, using some reasonable regex would get the tip out. Also,
> when phParrot is up and running a tip can be given with each reply if a
> databse of these tips was gathered. Someone then could gather all of the
> tips, publish a book and make us all famous.
>
> I may have had too much caffeine this AM -- looks like my enthusiasm
> level is set to 'HIGH'
thats a good thing, everyone feeds of the energy, its how balls start to roll :-)
>
attached mail follows:
[snip]
4. a website/subsite & related DB to store data for phParrot, tips, etc.
phparrot.net is up for grabs - I'm happy to register it (can't grace the
list with
ace mathematical explainations :-) but I'm happy to shell out a few
bucks as a way
of giving back a little) - and I'd just as happily transfer the domain
into the hands
of an 'official' php organisation if and when people think its required
(at no charge).
or maybe someone else want to register it?
also nobody seems to dare speak up regarding a 'front man'?
[/snip]
I'll take the lead. And go ahead and register. Does anyone know, off
hand, if phpwebhosting.com will allow us to set up the server like we
would like it? If so, I'll set up an account and pay for the space...
attached mail follows:
Jay Blanchard wrote:
> [snip]
> 4. a website/subsite & related DB to store data for phParrot, tips, etc.
>
> phparrot.net is up for grabs - I'm happy to register it (can't grace the
> list with
> ace mathematical explainations :-) but I'm happy to shell out a few
> bucks as a way
> of giving back a little) - and I'd just as happily transfer the domain
> into the hands
> of an 'official' php organisation if and when people think its required
> (at no charge).
>
> or maybe someone else want to register it?
>
> also nobody seems to dare speak up regarding a 'front man'?
> [/snip]
>
> I'll take the lead. And go ahead and register. Does anyone know, off
> hand, if phpwebhosting.com will allow us to set up the server like we
> would like it? If so, I'll set up an account and pay for the space...
I think we have our frontman: every say hello to Jay :-)
phpwebhosting.com doesn't seem to run PHP5 yet - I would strongly suggest that whatever
[we do/is done] with PHP for this project should be in PHP5.
Also their servers run Redhat Linux Enterprise 3 edition. (which wouldn't be my first
choice of OS).
attached mail follows:
Tim Burgan wrote:
> Hello,
>
>
> Is there any way that I can do some image manipulation - resizing -
> without the GD libraries?
I've always used the GD library and it's the only way that I'm aware of
to do resizing. Unless of course you're willing to do all the resizing
manually and just upload the new picture to the server in which case you
have a lot of options. Heck I think even MS Paint can handle that :)
>
>
> Tim
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
attached mail follows:
Tim Burgan wrote:
> Hello,
>
>
> Is there any way that I can do some image manipulation - resizing -
> without the GD libraries?
Can you execute imagemagic's mogrify?
attached mail follows:
Hello
Is there anybody who succed in doing per/page listing from a MS SQL Server db.
knowing that mssql doesnt support LIMIT like mysql and it uses TOP.
i didnt find an optimized way to make a per/page script.
Here's what am doing know :
to replace a MySQL "SELECT FROM ........ LIMIT $x,$y"
i did this with MSSQL :
:1 $query = "SELECT FROM ........"; //Without limit
:2 $ligne = fetch_assoc(query_bd($query));
:3 $temp = Array();
:4 for ($i=$debut;$i<($x+$y);$i++) {
:5 if (isset($ligne[$i]))
:6 $temp[] = $ligne[$i];
:7 }
:8 $ligne = $temp;
am loosing time between lines 4 to 7 when i have a big big array :(
attached mail follows:
Hello
Is there anybody who succed in doing per/page listing from a MS SQL Server db.
knowing that mssql doesnt support LIMIT like mysql and it uses TOP.
i didnt find an optimized way to make a per/page script.
Here's what am doing know :
to replace a MySQL "SELECT FROM ........ LIMIT $x,$y"
i did this with MSSQL :
:1 $query = "SELECT FROM ........"; //Without limit
:2 $ligne = fetch_assoc(query_bd($query));
:3 $temp = Array();
:4 for ($i=$debut;$i<($x+$y);$i++) {
:5 if (isset($ligne[$i]))
:6 $temp[] = $ligne[$i];
:7 }
:8 $ligne = $temp;
am loosing time between lines 4 to 7 when i have a big big array :(
attached mail follows:
I'm trying to use pcntl_fork on php 4.3.10, but it says " Call to
undefined function: pcntl_fork() in test.php on line 3"".
The manual says pcntl is present in php >= 4.1.0. I have 4.3.10, just the
standard installation included on fedora core 3.
I've done all the standard stuff - google'd, searched mailing list
archive, looked through phpinfo() (didn't find anything relevant).
Why wouldn't pcntl be working? Is there any other way for me to fork a
process or thread?
-John
attached mail follows:
John Davin wrote:
> The manual says pcntl is present in php >= 4.1.0. I have 4.3.10, just
> the standard installation included on fedora core 3.
>
> Why wouldn't pcntl be working? Is there any other way for me to fork a
> process or thread?
Take a look at http://www.php.net/pcntl.
If you're using the standard installation of PHP on FC3, then it won't
have pcntl enabled with --enable-pcntl because it's not enabled by
default. You will have to recompiled PHP with this feature.
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
attached mail follows:
That's what I was afraid of.
My web host (totalchoicehosting) doesn't have pcntl compiled in either,
so I'm sort of stuck.
Isn't there any other way to fork a process? PHP
doesn't have thread support? Why isn't pcntl enabled by default?
Surely the Windows compatibility isn't an issue, because pcntl could
default to enabled in linux but disabled in windows.
I'll tell you what I'm trying to do, in case there's another way to do it:
I have a logging script which does a gethostbyaddr to obtain the hostname
of the visitor to my site. But gethostbyaddr can take long or time out on
some IP's, so I want to fork it so that the original script can terminate
and not prevent the webpage from loading.
I could run a background job which periodically does the gethostbyaddr on
the IP's stored on disk, but that's sort of a hack, and is more
complicated than if I could fork.
-John
On Wed, 26 Jan 2005, Ben Ramsey wrote:
> John Davin wrote:
>> The manual says pcntl is present in php >= 4.1.0. I have 4.3.10, just the
>> standard installation included on fedora core 3.
>>
>> Why wouldn't pcntl be working? Is there any other way for me to fork a
>> process or thread?
>
> Take a look at http://www.php.net/pcntl.
>
> If you're using the standard installation of PHP on FC3, then it won't have
> pcntl enabled with --enable-pcntl because it's not enabled by default. You
> will have to recompiled PHP with this feature.
>
> --
> Ben Ramsey
> Zend Certified Engineer
> http://benramsey.com
>
> -- PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
attached mail follows:
Hi,
We've created our own CMS in PHP and we'd like to allow our users to do
more sophisticated things, like embed there own PHP code in pages. We
already run in safe-mode with our code, but we would like to run their
code in an even more restricted environment than our own code (ie,
disable some more functions, etc). Something similar to Perl's Safe
module
(http://www.cs.usask.ca/resources/documentation/perl/Safe.pm.html). Is
this at all possible in PHP? Can you turn on more safe mode restrictions
on certain bits of code?
Thanks in advance.
--
Eric Dorland
eric.dorland
mcgill.ca
WCG
514.398-5023 ext. 09562
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]