...

View Full Version : php



Aymen++
04-08-2003, 09:22 PM
when i put this code in my computer:


<?php
session_register("view1count");
session_register("view2count");
session_register("view3count");
session_register("view4count");
?>
<?php
//page_count.php
if (!$view1count) $view1count = 0;
if (!$view2count) $view2count = 0;
if (!$view3count) $view3count = 0;
if (!$view4count) $view4count = 0;
echo "<HTML><HEAD><TITLE>Web Page Hit Counter</TITLE></HEAD><BODY>";
if ($whichpage) {
echo "<B>You are currently on page $whichpage.</B><BR><BR>\n";
$GLOBALS["view${whichpage}count"]++;
}
for ($i = 1; $i <= 4; $i++) {
if ($whichpage == $i) {
echo "<B><A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A></B>";
} else {
echo "<A HREF=%22$PHP_SELF?&quot;.SID.&quot;&whichpage=$i/&quot;>Page $i</A>";
}
echo ", which you have chosen ".$GLOBALS["view${i}count"]." times.<BR>\n";
}
echo "\n\n<BR><BR>\n\n";
echo "</BODY></HTML>";
?>

warning message appeared to me, but when i uploaded it (http://members.lycos.co.uk/aymenplusplus/page_count.php) every think is ok but when i press the first link for example i don't know what happened... why?

missing-score
04-08-2003, 10:05 PM
Firstly, I dont know if it matters, but put { and } in your if statements.

Secondly, and I dont know If this is right, you should change

${i} to {$i} and similar instances.


If this doesn't work, please post the error so that I know what is going wrong.

Nightfire
04-08-2003, 10:42 PM
echo "<A HREF=%22$PHP_SELF?".SID."&whichpage=$i/">Page $i</A>"


should be



echo "<A HREF=\"".$PHP_SELF."?".SID."&whichpage=".$i."\">Page ".$i."</A>";


Also, don't forget the session_start();

The code is kinda messy though

Aymen++
04-09-2003, 12:28 PM
but why my computer prints warning on the first page?

Nightfire
04-09-2003, 02:14 PM
What does the warning say?

Aymen++
04-10-2003, 08:31 PM
that is whole the page that appeared to me:
Warning: open(/tmp\sess_8f32df803149e82883472caec93a6900, O_RDWR) failed: m (2) in C:\apache\htdocs\test\page_count.php on line 2
Page 1, which you have chosen 0 times.
Page 2, which you have chosen 0 times.
Page 3, which you have chosen 0 times.
Page 4, which you have chosen 0 times.



Warning: open(/tmp\sess_8f32df803149e82883472caec93a6900, O_RDWR) failed: m (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

missing-score
04-10-2003, 08:53 PM
Right, that means you have no /tmp folder to store your session data. I am having the same problem, but I am using phpdev.

missing-score
04-10-2003, 08:54 PM
I just remembered, you can change the name of the dir in php.ini

Phip
04-10-2003, 11:54 PM
how about session_start(); at the stop of the page?

Aymen++
04-11-2003, 06:33 PM
ok, how can i solve it?

Aymen++
04-11-2003, 11:31 PM
by the way, what is meaning of "stateless", i searched it in the dictionary and i didn't find it?

Jason
04-11-2003, 11:41 PM
stateless and state normally refer to an object and its state...look it up in an OO based language, I can't think of a way to describe it.


Jason

Aymen++
04-12-2003, 03:22 PM
i did it with phpdev but only the first warning appeared to me, why?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum