php_self

mr_jodete

New Member
Messages
19
Reaction score
0
Points
0
I have a ad-free account and i would like to ask if is working the php_self script if a have the Intermediate PHP Configuration

It is because it was working before and now it is stuck.Im using it for counting how many times was viewed the page.
Any ideas?
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
The global variable $_SERVER['PHP_SELF'], works fine on my site with the intermediate version of php. Could you please post the code for your script?
 

mr_jodete

New Member
Messages
19
Reaction score
0
Points
0
This is my code.
<?php
include ("connection.inc.php");
$connection = connect();
$page=$_SERVER["PHP_SELF"];
$ip=$_SERVER["REMOTE_ADDR"];
$date=time();
$query="INSERT INTO tracker(page,ip,date) VALUES ('$page','$ip','$date')";
mysql_query($query,$connection);
$query="SELECT count(*) FROM tracker WHERE page='$page'";
$result=mysql_query($query,$connection);
$views=mysql_result($result,0,"count(*)");
echo "This page has been viewed$views times";
?>
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
try this:

PHP:
<?php
include ("connection.inc.php");
$connection = connect();
$page = $_SERVER['PHP_SELF'];
$ip = $_SERVER['REMOTE_ADDR'];
$date=time();
$query="INSERT INTO tracker(page,ip,date) VALUES ('$page','$ip','$date')";
mysql_query($query,$connection);
$query="SELECT count(*) FROM tracker WHERE page='$page'";
$result=mysql_query($query,$connection);
$views=mysql_result($result,0,"count(*)");
echo "This page has been viewed '$views' times";
?>
 
Last edited:

mr_jodete

New Member
Messages
19
Reaction score
0
Points
0
No error message.I already fixed it,cheers anyway.
Edit:
now i have another problem,
On one page i would like to show the ip adresses and the pages which was accessed by this ips.(its like a static tracker system)

Here is the code
<?php
include "connection.inc.php";
$connection = connect();
$query="SELECT * FROM tracker GROUP BY IP";
$result=mysql_query($query,$connection);
$views=mysql_num_rows($result);
echo $views."Unique IPs<br><br>";

echo "IP views:<br>";
$query="SELECT *,count(*) FROM tracker GROUP BY IP";
$result=mysql_query($query,$connection);
for ($i=0;$i< mysql_num_rows($result);$i++)
{
$IP=mysql_result($result,$i,"IP");
$views=mysql_result($result,$i,"count(*)");
echo"$IP ";
echo "views: $views<br>";
}
echo "<br>Pages views by $IP:<br>";
$query="SELECT *,count(*) FROM tracker WHERE IP = '$IP' GROUP BY page";
$result=mysql_query($query,$connection);

for ($i=0;$i< mysql_num_rows($result);$i++)
{
$page=mysql_result($result,$i,"page");
$views=mysql_result($result,$i,"count(*)");

echo"page: $page views: $views<br> ";
}
echo "<br>Pages views:<br>";
$query="SELECT *,count(*) FROM tracker GROUP BY page";
$result=mysql_query($query,$connection);
for ($i=0;$i< mysql_num_rows($result);$i++)
{
$page=mysql_result($result,$i,"page");
$views=mysql_result($result,$i,"count(*)");
echo"page: $page ";
echo "views: $views<br>";
}
?>
 
Last edited:
Top