php-general Digest 22 Feb 2006 14:00:18 -0000 Issue 3978

Topics (messages 230867 through 230892):

Re: Script updating secondary server
        230867 by: Chris
        230869 by: Curt Zirzow

Re: CLI utility
        230868 by: Curt Zirzow

Re: How do I output error messages
        230870 by: Paul Goepfert

Special Chars on Form to Image (GD), not displaying properly.
        230871 by: Louie Miranda
        230872 by: Curt Zirzow
        230873 by: Louie Miranda
        230879 by: Curt Zirzow

array variables with or without quotes
        230874 by: 2dogs
        230876 by: Chris

"Nested Set Model" or "modified preorder tree traversal"
        230875 by: Daevid Vincent
        230878 by: Chris
        230883 by: Curt Zirzow
        230890 by: Jared Williams

Why does it stop working?
        230877 by: pine oil
        230880 by: Chris
        230881 by: pine oil
        230882 by: Chris
        230884 by: Curt Zirzow
        230886 by: Sameer N Ingole

Re: CLASS/Object lifetime - > more info
        230885 by: Roger Helgesen

Problem with mail() on Debian
        230887 by: George Pitcher

Re: CLASS/Object lifetime - > Solution
        230888 by: Roger Helgesen

Re: Request for views on ASP/PHP/ASP.NET - please!
        230889 by: Wely E.R.

php 4 v php 5
        230891 by: tedd

Re: Session problems [SOLVED]
        230892 by: Dan Parry

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

I have one server in USA and one server in Thailand. The server in USA is
the one containing the updated information. The Thai server will be a copy
of the USA server.

I want to write a PHP script that does this for me:
1. Once a day copies the files on the USA server to the Thai server and put
them in the web folder
2. Once a day copy the database in USA (dump) and then empty the Thai
database and insert the USA content (inserts)

Maybe PHP is not the right way? Do you know any code that already do this
(PHP)? I would like to do this in PHP, because I am in the learning process
of this great language.

To be honest you're better off using tools other than php.

rsync will copy files quite efficiently (http://rsync.samba.org) and will only copy *changed files* - so a copy each day won't take much time at all.

On the US server, make sure you place a database dump before the sync starts.

From the Thai server, initiate the sync.

When the copy is finished, import the database dump.

--- End Message ---
--- Begin Message ---
On Wed, Feb 22, 2006 at 01:02:29PM +1100, Chris wrote:
> 
> >
> >I want to write a PHP script that does this for me:
> >1. Once a day copies the files on the USA server to the Thai server and put
> >them in the web folder
> >2. Once a day copy the database in USA (dump) and then empty the Thai
> >database and insert the USA content (inserts)
> >
> >Maybe PHP is not the right way? Do you know any code that already do this
> >(PHP)? I would like to do this in PHP, because I am in the learning process
> >of this great language.
> 
> To be honest you're better off using tools other than php.
> 
> rsync will copy files quite efficiently (http://rsync.samba.org) and 
> will only copy *changed files* - so a copy each day won't take much time 
> at all.

Not to mention they'd be copy securely and may be sent compressed
as well.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
 
Just a raw (manual) way to talk to a server.  You just need to
understand the way a HTTP request is sent to a server
(http://w3c.org/). Or if you know how to comminicate with what ever
protocol you use manually.

The reason to really do it with db-server  would be to test
to see if is actually running, for example for mysql:

  telnet localhost 3306
  5.0.15-standard�q9i$t=tR,|;P_l%lu']~&^CConnection closed by foreign host.

or  smtp
  telnet localhost 25
  220 bagend.shire ESMTP Exim 4.54 Tue, 21 Feb 2006 20:01:16 -0800
  helo localhost
  250 bagend.shire Hello localhost.shire [::1]
  ...

or  pop3
  telnet localhost 110
  Trying 127.0.0.1...
  telnet: connect to address 127.0.0.1: Connection refused
  telnet: Unable to connect to remote host

oh yeah, i dont run a pop server :)

> 
> woh-woh-woh... what is this? never ever thought of such a method...
> where can i get
> more info about such stuff ? maybe apache-docs, but where? does it even
> work with other
> protocols/servers, maybe something like 'rtsp' or a db-server :) ?
> 
> >telnet localhost 80 | less
> >GET / HTTP/1.0
> >Host: localhost
> 

I usually use google's 'define:YMMV'


> Oh...  errr...  sorry... but, those abbrivations... can't get used to
> them... is there a glosary or such
> alike to find somewhere?
> >YMMV


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
$submit is soppose to be set when the user submits the web form for
validation.  I am not sure but is there soppose to be a $submit =
<input type="submit" name="submit" value="submit"> statement?

Paul

On 2/21/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [snip]
> if (isset($submit))
> {
>   //vaildation code
> }
> else
> {
> //webpage
> }
> [/snip]
>
> What is $submit? Is it set ever? The problem probably lies in the fact that
> $submit, whatever it is, never gets set.
>

--- End Message ---
--- Begin Message ---
Im having a trouble displaying special characters like #, + on GD (Jpeg) -
Image. When i typed in on the form +88 it only shows 88 and the + sign is
missing.

My code:
 <?php
..
$line_1_1 = urldecode($_GET["line_1_1"]);
..
// display my text from $line_1_1
imagettftext($background, 13, 0, $new, 65, $black,
"includes/resources/$fonts", "$line_1_1");
..
?>

I made a couple of tests and found this variables.

 The data that will be pass: +88and#
Data from the url (address box): &line_1_1=%2B88and%23
Image displayed: 88and - only missing + and #

What could i be missing?

--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

//JSM-W

--- End Message ---
--- Begin Message ---
On Wed, Feb 22, 2006 at 12:38:19PM +0800, Louie Miranda wrote:
> Im having a trouble displaying special characters like #, + on GD (Jpeg) -
> Image. When i typed in on the form +88 it only shows 88 and the + sign is
> missing.
> 
> My code:
>  <?php
> ..
> $line_1_1 = urldecode($_GET["line_1_1"]);

You dont want to urldecode() the $_GET vars. PHP already does this
step.

See what happens with:

  var_dump(urldecode($_GET['line_1_1']));
  var_dump($_GET['line_1_1']);

> ...
> I made a couple of tests and found this variables.
> 
>  The data that will be pass: +88and#
> Data from the url (address box): &line_1_1=%2B88and%23
> Image displayed: 88and - only missing + and #
> 
> What could i be missing?

Well if you dont use the urldecode() as mentioned above, the only
reasons i can think of (assuming + will display properly now):

  - The font doesn't have a definition for #
  - The area isn't big enough so # is getting truncated.

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Please read below..

> Im having a trouble displaying special characters like #, + on GD (Jpeg) -
> > Image. When i typed in on the form +88 it only shows 88 and the + sign
> is
> > missing.
> >
> > My code:
> >  <?php
> > ..
> > $line_1_1 = urldecode($_GET["line_1_1"]);
>
> You dont want to urldecode() the $_GET vars. PHP already does this
> step.
>
> See what happens with:
>
>   var_dump(urldecode($_GET['line_1_1']));
>   var_dump($_GET['line_1_1']);
>

I tested this not on a GD/Image, but on a plain form and plain var_dump.
The results:

string(1) " "
string(1) "+"

 So, now if i even make a urldecode it also disappers. I think the problem
is when i typed in + on the user input via form. The url converts it
to %2B which
i think is a space. Because as for my example (seen thru the url):

+88and#
When displayed on an image becomes..
 88and

Now, if i made this

+88+and#
It displays..
 88 and#

It converts + to space. Now, how could i filter this properly?

> ...
> > I made a couple of tests and found this variables.
> >
> >  The data that will be pass: +88and#
> > Data from the url (address box): &line_1_1=%2B88and%23
> > Image displayed: 88and - only missing + and #
> >
> > What could i be missing?
>
> Well if you dont use the urldecode() as mentioned above, the only
> reasons i can think of (assuming + will display properly now):
>
>   - The font doesn't have a definition for #
>   - The area isn't big enough so # is getting truncated.


The font is verdana and the image is just normal for its size.

Now, i did this test.

imagettftextalign($background, 8, 0, 385, 120, $black,
"includes/resources/$fonts", "+88+and#$line_1_1", $alignment='R');

This one displays +88+and# properly on the GD image. I only get problems
when displaying it from form to php gd.

What could i be missing? :(

--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

//JSM-W

--- End Message ---
--- Begin Message ---
On Wed, Feb 22, 2006 at 01:12:00PM +0800, Louie Miranda wrote:
> Please read below..
> 
> > Im having a trouble displaying special characters like #, + on GD (Jpeg) -
> > > Image. When i typed in on the form +88 it only shows 88 and the + sign
> > is
> > > missing.
> > >
> > > My code:
> > >  <?php
> > > ..
> > > $line_1_1 = urldecode($_GET["line_1_1"]);
> >
> > You dont want to urldecode() the $_GET vars. PHP already does this
> > step.
> >
> > See what happens with:
> >
> >   var_dump(urldecode($_GET['line_1_1']));
> >   var_dump($_GET['line_1_1']);
> >
> 
> I tested this not on a GD/Image, but on a plain form and plain var_dump.
> The results:
> 
> string(1) " "
> string(1) "+"
> 
>  So, now if i even make a urldecode it also disappers. I think the problem
> is when i typed in + on the user input via form. The url converts it
> to %2B which
> i think is a space. Because as for my example (seen thru the url):
> 
> +88and#
> When displayed on an image becomes..
>  88and
> 
> Now, if i made this
> 
> +88+and#
> It displays..
>  88 and#

this is where i think your confused, the problem with your original
code is you are ending up urldecoding things twice thus thinking
that %2B == a space.

consider:
  echo urlencode(' '); # '+'
  echo urlencode('+'); # '%2B'

  echo urldecode(' ');   # ' '
  echo urldecode('+');   # ' '
  echo urldecode('%2B'); # '+'

if your url is:
  http://server.com/?foo=%2B88an%23

then in php if you do:
  echo $_GET['foo'];

you will get '+88and#'

if your url is:
  http://server.com/?foo=+88and#

then in php if you do:
  echo $_GET['foo'];

you will get: ' 88and'

> 
> It converts + to space. Now, how could i filter this properly?

Now given what I said and you have a form defined as:
<form method="GET">
  <input name="foo">
</form>

And you type in the box '+88and#' the url that is submited should
be:
  http://server.com/?foo=%2B88and%23

Then:
  echo $_GET['foo']; # '+88and#'
 
Or if you type: ' 88and#' the url should be:

  http://server.com/?foo=+88and%23

  or possibly (not to confuse things more)

  http://server.com/?foo=%2088and%23

Then:
  echo $_GET['foo']; # ' 88and#'


Now, the only way that # could seem to disappear is if you have your
form setup like:
<form method="GET" action="#">
  <input name="foo">
</form>

And you type: '+88and',  The url will look like:
  http://server.com/?foo=%2B88and#

thus:
  echo $_GET['foo']; # '+88and'

or if you type ' 88and', the url will look like:
  http://server.com/?foo=+88and#

thus:
  echo $_GET['foo']; # ' 88and'


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
I recently encountered a situation where I had to retrieve data from a MYSQL 
database table with a field named "include". My code looked like this:

$content_result = mysql_query('SELECT * FROM calander') or 
die(mysql_error());
$content_row = mysql_fetch_array($content_result);
if ($content_row[include])
    {go do something;}

When I tried to run this, PHP treated the word  -include- as a control 
structure rather than an index name. Understandable. So, I put it in single 
quotes  ('include') to see what would happen and it works fine. But I don't 
understand why!

What is the difference between $content_row [include] and 
$content_row['include']? I have been unable to resolve this question in the 
php manual, I need enlightenment.

2dogs 

--- End Message ---
--- Begin Message ---
When I tried to run this, PHP treated the word -include- as a control structure rather than an index name. Understandable. So, I put it in single quotes ('include') to see what would happen and it works fine. But I don't understand why!

What is the difference between $content_row [include] and $content_row['include']? I have been unable to resolve this question in the php manual, I need enlightenment.

Without quotes it could be constant or defined variable:

define('variable', 'blah blah blah');

so then I can just use:

<?php
define('variable', 'blah blah blah');
echo variable;
?>

will print out:

blah blah blah

So in your case, it's checking for a defined variable called 'include' which doesn't exist (and prints out a warning/notice).
--- End Message ---
--- Begin Message ---
I've been searching the web for the past few hours trying to find a simple
drop-in class or functions to implement "Nested Set Model" or "modified
preorder tree traversal".

I've found several tutorials and related links:

  http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
  http://www.sitepoint.com/article/hierarchical-data-database
 
http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tutorial-ferrara2
&id=3453&open=1&anc=0&view=1
  http://simon.incutio.com/archive/2003/06/19/storingTrees
  http://istherelifeafter.com/joecelko.html
  http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp

I even found some outdated PEAR DB_NestedSet class from 2003 that seemed way
to overly complicated. And some other PHP4_Mysql3MPTTA class on PHP Classes
that was equally complicated and written for ancient PHP4 and mySQL 3!!

Hasn't anyone else done this before (recently)? 
Did everyone just write their own code every time?
Anyone have some easy to use code that allows for:
Add, delete, update/rename, select, show tree, bread crumb display, etc.

I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
the optimizations and bells & whistles of those more modern versions.

TIA.

D.Vin

--- End Message ---
--- Begin Message ---
Hasn't anyone else done this before (recently)? Did everyone just write their own code every time?
Anyone have some easy to use code that allows for:
Add, delete, update/rename, select, show tree, bread crumb display, etc.

I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
the optimizations and bells & whistles of those more modern versions.

The php or mysql version doesn't matter, it's more to do with how you structure your database.

Instead of your id/parentid relationship the way I did it was you create a 'node' with this information in it.

So:

select categoryid, node, categoryname from all_categories;
 categoryid |   node   | categoryname
------------+----------+--------------
          9 | 0009     | Parent
         10 | 0010     | Another Parent
         11 | 00090011 | Sub Cat
         13 | 00100013 | Sub Cat 2
         12 | 00100012 | Sub Cat 3

catid '11' is a subcategory of '9'.
catid '13' is a subcat of '10'.

You'll need to pad each node out to a certain length so you don't get overlaps (in my case I used 4 giving me 9999 categories at each level). The longer each node is the more categories you can have at each level but the smaller number of categories you have altogether.

Don't forget mysql & other databases only let you index up to 255 characters of a text field (in my case I used a varchar(200) for the node field), so while you could in theory have infinite levels it's not really practical (unless you use full text indexing).


Inserting is easy - you get the parent that you're inserting under and add your padded node on the end of it giving you the full path.


Deleting is easy as well - to delete a category and all subcategories:

delete from all_categories where node like '0009%';


Moving things around is harder..


If you need more info let me know.

--- End Message ---
--- Begin Message ---
On Tue, Feb 21, 2006 at 09:38:53PM -0800, Daevid Vincent wrote:
> I've been searching the web for the past few hours trying to find a simple
> drop-in class or functions to implement "Nested Set Model" or "modified
> preorder tree traversal".

I actually fell in love of this method of doing trees when I
discovered it about a year ago, when researching a fast way to do
a parent child retrieval.

> 
> I've found several tutorials and related links:
> 
>   http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
>   http://www.sitepoint.com/article/hierarchical-data-database
>  
> http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tutorial-ferrara2
> &id=3453&open=1&anc=0&view=1
>   http://simon.incutio.com/archive/2003/06/19/storingTrees
>   http://istherelifeafter.com/joecelko.html
>   http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp

oh i have to add some of these to my list, i didn't have a couple
of them.

> 
> I even found some outdated PEAR DB_NestedSet class from 2003 that seemed way
> to overly complicated. And some other PHP4_Mysql3MPTTA class on PHP Classes
> that was equally complicated and written for ancient PHP4 and mySQL 3!!

yeah, i kind of got that feeling with the PEAR class as well, i
think it was designed that way to be as flexible as possible. I'm
not familiar with the other class, i tend to avoid anything from
PHP Classes.

> 
> Hasn't anyone else done this before (recently)? 
> Did everyone just write their own code every time?
> Anyone have some easy to use code that allows for:
> Add, delete, update/rename, select, show tree, bread crumb display, etc.

It would be nice to have a tool to manage the functionality. There
will always be the issue with any common tool that is built for
this purpose is how do you relate the table that defines the nested
with the table that actually holds the data.

I believe that why the PEAR and other classes you came across
seemed to be overly complicated.  I have found that it is easier to
write my own management (as awful as that sounds) for the job at
hand.

> 
> I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
> the optimizations and bells & whistles of those more modern versions.

5.0.5? you mentioned that php4 is ancient, 5.0.5 is more ancient
than php4.. infact 5.0.x is rather dead.

PHP 4.4.2 - Released Jan 13 2006
php 5.1.2 - Released Jan 12 2006
PHP 5.0.5 - Released Sept 6 2005

I wouldn't expect any more releases of 5.0.x version.


Curt.
-- 
cat .signature: No such file or directory

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

Hi,
        As your using MySQL5, I'd recommend putting all the Nested Set code in 
stored procedures, that way the client doesn't need
to know about anything about the method, and the left, right columns never need 
to be retrieved.



Jared
 
> I've been searching the web for the past few hours trying to 
> find a simple drop-in class or functions to implement "Nested 
> Set Model" or "modified preorder tree traversal".
> 
> I've found several tutorials and related links:
> 
>   http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
>   http://www.sitepoint.com/article/hierarchical-data-database
>  
> http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tut
> orial-ferrara2
> &id=3453&open=1&anc=0&view=1
>   http://simon.incutio.com/archive/2003/06/19/storingTrees
>   http://istherelifeafter.com/joecelko.html
>   http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp
> 
> I even found some outdated PEAR DB_NestedSet class from 2003 
> that seemed way to overly complicated. And some other 
> PHP4_Mysql3MPTTA class on PHP Classes that was equally 
> complicated and written for ancient PHP4 and mySQL 3!!
> 
> Hasn't anyone else done this before (recently)? 
> Did everyone just write their own code every time?
> Anyone have some easy to use code that allows for:
> Add, delete, update/rename, select, show tree, bread crumb 
> display, etc.
> 
> I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take 
> advantage of all the optimizations and bells & whistles of 
> those more modern versions.
> 
> TIA.
> 
> D.Vin
> 
> --
> PHP General Mailing List (http://www.php.net/) To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?

---------------------------------- index.php
--------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The Counter</title>
</head>
<body>
<p>
<strong><font size="2" face="Arial, Helvetica, sans-serif"
color="#CC0000">Page visits:</font></strong><br />
<img src="counter.php" /> </p>
</body>
</html>
---------------------------------- counter.php
-------------------------------------------
<?
include("counter_config.php");
$cn = implode("",file("counter.txt"));
$cn++;
$fp = fopen("counter.txt","w+");
fwrite($fp,$cn);
fclose($fp);

$des = imagecreatetruecolor($counter_width,$counter_font_size);

$bgcol = HEX2RGB($counter_background);
$tcol = HEX2RGB($counter_color);
$bg = imagecolorallocate($des,$bgcol[0],$bgcol[1],$bgcol[2]);
$fc = imagecolorallocate($des,$tcol[0],$tcol[1],$tcol[2]);
imagecolortransparent($des,$bg);
$font = "fonts/$counter_font.ttf";
$tt = $counter_numbers  - strlen($cn)-1;
$ts = 0;
while($ts <= $tt)
{
        $cn = '0'.$cn;
        $ts++;
}
imagettftext($des, $counter_font_size, 0, 0, $counter_font_size, $fc,
$font, $cn);

header("Content-type: image/gif");
imagegif($des);

function HEX2RGB($color){
$color = str_replace("#","",$color);
 $color_array = array();
 $hex_color = strtoupper($color);
 for($i = 0; $i < 6; $i++){
  $hex = substr($hex_color,$i,1);
  switch($hex){
   case "A": $num = 10; break;
   case "B": $num = 11; break;
   case "C": $num = 12; break;
   case "D": $num = 13; break;
   case "E": $num = 14; break;
   case "F": $num = 15; break;
   default: $num = $hex; break;
  }
  array_push($color_array,$num);
 }
 $R = (($color_array[0] * 16) + $color_array[1]);
 $G = (($color_array[2] * 16) + $color_array[3]);
 $B = (($color_array[4] * 16) + $color_array[5]);
 return array($R,$G,$B);
 unset($color_array,$hex,$R,$G,$B);
}
?>
------------------------------- counter_config.php
-------------------------------
<?
//counter_config.php > Source
// Width in pixels of your counter
$counter_width = "100";
// Number of digits you want to display in the counter. Zeros will be
automaticly included
$counter_numbers = 6;
// Font size in pixels
$counter_font_size = 13;
// Font of your digits
$counter_font = 'arial';
// Color of your counter
$counter_color = '#FF6600';
// Color of the background. Usualy it should be the same with the
color  of the place where will be placed
$counter_background = '#FFFFFF';
// Trasparent bacground counter true = yes false = no
$counter_transparent = true;
?>
-------------------------------- counter.txt ---------------------------
572

--- End Message ---
--- Begin Message ---
pine oil wrote:
I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?

It could be a permissions thing (it can't read/write the counter.txt file).

If you could narrow down what's going wrong a bit it'd help.

View the counter only in your browser - does that give an error?

--- End Message ---
--- Begin Message ---
On 2/22/06, Chris <[EMAIL PROTECTED]> wrote:
> pine oil wrote:
> > I've used the following counter for some time, but I don't seem to
> > have it work now after I have moved the directory of the files.
> >
> > They used to be in /var/www/html, but moved to /home/webroot/test.
> >
> > Do you think the relocation of the files has something to do with my 
> > problem?
>
> It could be a permissions thing (it can't read/write the counter.txt file).
>
> If you could narrow down what's going wrong a bit it'd help.
>
> View the counter only in your browser - does that give an error?
>
I changed the permission to read/write for the owner and group. That
did not help.

I am sorry I don't know how to view the counter in my browswer. The
counter did not show if I open the index.php when I access the page
through the apache server.

--- End Message ---
--- Begin Message ---
pine oil wrote:
On 2/22/06, Chris <[EMAIL PROTECTED]> wrote:

pine oil wrote:

I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?

It could be a permissions thing (it can't read/write the counter.txt file).

If you could narrow down what's going wrong a bit it'd help.

View the counter only in your browser - does that give an error?


I changed the permission to read/write for the owner and group. That
did not help.

I am sorry I don't know how to view the counter in my browswer. The
counter did not show if I open the index.php when I access the page
through the apache server.

<img src="counter.php" />

Instead of going to index.php, go to counter.php

That will run just the counter script and (hopefully) show an error.

--- End Message ---
--- Begin Message ---
On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:
> I've used the following counter for some time, but I don't seem to
> have it work now after I have moved the directory of the files.
>
>... 
> $cn = implode("",file("counter.txt"));
> $cn++;
> $fp = fopen("counter.txt","w+");
> fwrite($fp,$cn);
> fclose($fp);

hmm.. i didn't think these raw counter like things were used
anymore.

Have you considered not even worrying about showing how many people
have viewed the page?

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Curt Zirzow wrote:
On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:
I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.
This seems to be Apache problem than PHP problem. Are you sure your Apache can process PHP pages in your home directory? Check that first.

May be you should see if page with just phpinfo() function executes properly if kept in your home directory.

Regards,

--
Sameer N. Ingole
Blog: http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--- End Message ---
--- Begin Message ---
ain't that the other way around ?

$var1=$var2 ($var1 is a copy of $var2)
$var1=& $var2 ($var1 is a reference to $var2)
$var1='Test'
echo $var2  (outputs Test)

roger
Jochem Maas wrote:
REFERENCES.

the object you get back is a copy (foreach has the same
effect as creating a new variable as in the example below).

... see below ...

notice the use of the & symbol (and the 'refcount' values).
(there is loads of info out there on references/php4/objects
out there that explain it better than me.) - see what happens
when you start removing '&'s.

or you could try php5 and forget about 'object hell'. :-)

roger helgesen wrote:
The function that gives me trouble
---------
function fyll_sub_konto($pv){
                foreach($this->subposter AS $konto){
                        $konto->fyll_fra_post($pv);
                }

class Test
{
var $number;
var $subposter;

function Test($n = 0) { $this->number = $n; }

function sqar() { if (is_numeric($this->number)) { $this->number *= $this->number; } return $this; }
function doit() { echo strval($this->number),"\n"; }
function make() { static $c = 1; $t = new Test($c++); $s =& $t; // watch what happens when you remove the '&' (php4 only)
    $s->sqar();
    $this->subposter[] = $t->sqar();
}
function goan() { $cnt = count($this->subposter);
    $this->doit();
    for($i=0;$i<$cnt;$i++) {
        // watch what happens when you remove the '&' (php4 only)
        $tmp =& $this->subposter[$i];
        $tmp->sqar();
        $this->subposter[$i]->doit();
    }
}
}

$t = new Test("infinity"); $i = 0;
while($i++ < 5) $t->make();
$t->goan();


}
-------------

$this->subposter is the array of CLASS2

function fyll_fra_post($post_vars){
    echo "(gruppe)class = ".get_class($this) ."<br>\n";
    $teller=0;
    foreach($this->poster AS $post=>$verd){
        $best="bestilt_".$post;
        $avik="avvik_".$post;
        $fakt="faktura_".$post;
    $this->poster[$post]["bestilt"]=$post_vars[$best];
    $this->poster[$post]["avvik"]=$post_vars[$avik];
    $this->poster[$post]["faktura"]=$post_vars[$fakt];
    }
    $this->endret='ja';
    $this->sett_sum();
}

If I print the data (after setting the new data) inside 'fyll_fra_post' it puts out the new data. If I do the same from 'fyll_sub_konto' (after foreach) it gives me the old data.



--
mvh
Roger Helgesen
Helgesen Tekniske-bygg AS
56193410
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Hi,

I am in the process of moving from Windows (NT/XP) to Linux. I'm starting
with a new small application which I have working on my Windows XP laptop.

On my Linux box, I have php.ini saying:

sendmail_path /usr/sbin/sendmail

That 'sendmail' is a symbolic link to exim4 in the same directory. I can
send mail using exim4 from the command line, but not using PHP. I couldn't
find anything in the manual or on Google that helps me solve the problem.

Can anyone give me a clue where to look to solve this problem?

Cheers

George, in Oxford

--- End Message ---
--- Begin Message ---
 function fyll_sub_konto($pv){
                foreach($this->subposter AS $konto=>$kt){
                        $kontoen=& $this->subposter[$konto];
                        $kontoen->fyll_fra_post($pv);
                        $kontoen->endre();
                }
}
the line
$kontoen=& $this->subposter[$konto];
solved all

roger
roger helgesen wrote:
The function that gives me trouble
---------
function fyll_sub_konto($pv){
                foreach($this->subposter AS $konto){
                        $konto->fyll_fra_post($pv);
                }
}
-------------

$this->subposter is the array of CLASS2

function fyll_fra_post($post_vars){
    echo "(gruppe)class = ".get_class($this) ."<br>\n";
    $teller=0;
    foreach($this->poster AS $post=>$verd){
        $best="bestilt_".$post;
        $avik="avvik_".$post;
        $fakt="faktura_".$post;
    $this->poster[$post]["bestilt"]=$post_vars[$best];
    $this->poster[$post]["avvik"]=$post_vars[$avik];
    $this->poster[$post]["faktura"]=$post_vars[$fakt];
    }
    $this->endret='ja';
    $this->sett_sum();
}

If I print the data (after setting the new data) inside 'fyll_fra_post' it puts out the new data. If I do the same from 'fyll_sub_konto' (after foreach) it gives me the old data.

--- End Message ---
--- Begin Message ---
I'm waiting for the result.
It would be nice of you when you post it in this list.

Thanx.

From: "Simon O'Beirne"
On  Monday, February 20, 2006 11:58 PM
Wrote:

Hi guys,

A bit of an odd request. I'm in my third and final year at university, and
part of an assignment requires obtaining developers' perspective on web
languages.

If anyone has done at least one of the languages in the subject title
(ASP/ASP.NET/PHP), I would be eternally grateful if you could pop to (and
also send any other web developers you know to)

http://www.coralsystemsolutions.co.uk/uni

Theres a maximum of 14 short questions (depending on answers to the other
questions), all optional, just fill out as much as you can be bothered with,
then click submit a few times until its saved.

Thank you very much in advance!

Simon

--- End Message ---
--- Begin Message ---
Hi:

Curt. said:

PHP 4.4.2 - Released Jan 13 2006
php 5.1.2 - Released Jan 12 2006
PHP 5.0.5 - Released Sept 6 2005

I wouldn't expect any more releases of 5.0.x version.

Pardon my ignorance -- I have enough problems pounding out code to spend time following what's happening at the higher levels. But, considering the above statement, are there continuing development paths for both php 4 and 5 independently?

If so, what's the distinction between the two, oop? And if so, what about non-oop stuff -- do they share common libraries, or what? Generally, how does all of this fit together?

Thanks.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com

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

I didn't get that many replies (thanks to those who did reply :) ) for this,
so now I've figured out the problem I thought I'd share the solution just in
case anyone else has the same issue:

<solution>
The problem stemmed from the way the return from UPDATE is handled and the
scripts reliance on the mysql_affected_rows() command

If the UPDATE command is executed on a record and no values are altered the
command exits with a value of 0 meaning that the result of
mysql_affected_rows() is false

This occurs on redirects and fast refreshes because the time value hasn't
changed so no values are altered in the row, mysql_affected_rows() is false
and the function continues as no condition is met to return a value... the
following INSERT then causes the problem

The solution was do execute a simple SELECT to get the number of rows for
the session ID and if mysql_affected_rows() evaluated to false but the
number of records is 1 return true
</solution>

And there we have it... nearly drove me nuts but I got there in the end

Cheers

Dan
-----------------------------------------------------
Dan Parry
Senior Developer
Virtua Webtech Ltd
http://www.virtuawebtech.co.uk

-----Original Message-----
From: Dan Parry [mailto:[EMAIL PROTECTED] 
Sent: 16 February 2006 09:51
To: php-general@lists.php.net
Subject: [PHP] Session problems

Hi all

 

I've been getting an error while using a custom session handler utilising a
MySQL database

 

The error I receive is:

 

Duplicate entry '<<PHPSESSID_REMOVED>>' for key 1
Warning: Unknown(): A session is active. You cannot change the session
module's ini settings at this time. in Unknown on line 0

 

I've contacted my hosting company regarding this but currently they don't
seem to know the cause

 

I've Googled but I can't find anything I can use

 

Thanks in advance :-)

 

Dan

 

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

Dan Parry

Senior Developer

Virtua Webtech Ltd

http://www.virtuawebtech.co.uk

 

--- End Message ---

Reply via email to