4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 visitors infomation
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
retro
Junior WebHelper
Junior WebHelper


Joined: 10 Apr 2004
Posts: 5

PostPosted: Sat Apr 10, 2004 2:54 pm (20 years ago) Reply with QuoteBack to Top

I've been trying to code a simple app which will store the date, ip, hostname and referer of the visitor and store it into mysql database.
I've have so many problems with doing this. In the end i decided to start basic and i've coded and very simple one which will only get the hostname, byusing the following code.

Code:

<?php
$db = mysql_connect("host","username","password");
mysql_select_db("database",$db);
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$query = "INSERT INTO stats(hostname) VALUES('$hostname');
$result = mysql_query($query);
?>


This still doesn't work, can someone give me some help or advice?

Regards
OfflineView User's ProfileFind all posts by retroSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sat Apr 10, 2004 3:56 pm (20 years ago) Reply with QuoteBack to Top

Are the entries in your database empty, or are there none at all?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
retro
Junior WebHelper
Junior WebHelper


Joined: 10 Apr 2004
Posts: 5

PostPosted: Sat Apr 10, 2004 4:18 pm (20 years ago) Reply with QuoteBack to Top

Nothing at all but also i get an error
Parse error: parse error in stats.php on line 9
OfflineView User's ProfileFind all posts by retroSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sat Apr 10, 2004 4:29 pm (20 years ago) Reply with QuoteBack to Top

Here is the problem:

Code:
$query = "INSERT INTO stats(hostname) VALUES('$hostname');

Replace that with
Code:
$query = "INSERT INTO stats(hostname) VALUES('$hostname')";

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
retro
Junior WebHelper
Junior WebHelper


Joined: 10 Apr 2004
Posts: 5

PostPosted: Mon Apr 12, 2004 4:03 pm (20 years ago) Reply with QuoteBack to Top

Display the results in the database

Code:

<?php

$db = mysql_connect("host","user","password");
mysql_select_db("retro",$db);

Print ("Visitor Stats Logfile");
print ("<P><table width=\"100%\" border=\"0\"> <tr> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Date</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">IP</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Hostname</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Referer</font></td></tr>");

$Query2 = "SELECT * from Stats";
$Results = mysql_db_query("retro",$query, $db);
while($Row2 = mysql_fetch_array($Result2)){
print(" <tr> <td width=\"242\"><font size=\"2\"?$Row2[id]</font></td>
<td width=\"242\"><font size=\"2\">$Row2[date]</font></td> <td width=\"242\"><font size=\"2\">$Row2[ip]</font></td>
<td width=\"242\"><font size=\"2\">$Row2[hostname]</font></td> <td width=\"242\"><font size=\"2\">$Row2[referer]</font></td>
</tr>");} print("</table">;
?>


Parse error: parse error in /mnt/host-users/r/e/t/viewstats.php on line 15
OfflineView User's ProfileFind all posts by retroSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Apr 12, 2004 4:59 pm (20 years ago) Reply with QuoteBack to Top

Replace
Code:
print(" <tr> <td width=\"242\"><font size=\"2\"?$Row2[id]</font></td>
<td width=\"242\"><font size=\"2\">$Row2[date]</font></td> <td width=\"242\"><font size=\"2\">$Row2[ip]</font></td>
<td width=\"242\"><font size=\"2\">$Row2[hostname]</font></td> <td width=\"242\"><font size=\"2\">$Row2[referer]</font></td>
</tr>");
with
Code:
print(' <tr> <td width="242"><font size="2">' . $Row2[id] . '</font></td>
<td width="242"><font size="2">' . $Row2[date] . '</font></td> <td width="242"><font size="2">' . $Row2[ip] . '</font></td>
<td width="242"><font size="2">' . $Row2[hostname] . '</font></td> <td width="242"><font size="2"> ' . $Row2[referer] . '</font></td>
</tr>');

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
retro
Junior WebHelper
Junior WebHelper


Joined: 10 Apr 2004
Posts: 5

PostPosted: Tue Apr 13, 2004 3:07 pm (20 years ago) Reply with QuoteBack to Top

Sad Still having problems with it
this is the full code as of now:

Code:

<?php

$db = mysql_connect(host,username,password);
mysql_select_db("retro",$db);

Print ("Visitor Stats Logfile");
print ("<P><table width=\"100%\" border=\"0\"> <tr> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Date</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">IP</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Hostname</font></td> <td width=\"242\"><p><font face=\"Verdana\" size=\"2\">Referer</font></td></tr>");

$Query2 = "SELECT * from Stats";
$Results = mysql_db_query("retro",$query, $db);

while($Row2 = mysql_fetch_array($Result2))
{
print(' <tr> <td width="242"><font size="2">' . $Row2[id] . '</font></td> <td width="242"><font size="2">' . $Row2[date] . '</font></td> <td width="242"><font size="2">' . $Row2[ip] . '</font></td> <td width="242"><font size="2">' . $Row2[hostname] . '</font></td> <td width="242"><font size="2"> ' . $Row2[referer] . '</font></td> </tr>');
}

print("</table">;
?>
OfflineView User's ProfileFind all posts by retroSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue Apr 13, 2004 4:25 pm (20 years ago) Reply with QuoteBack to Top

What is the problem now?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
retro
Junior WebHelper
Junior WebHelper


Joined: 10 Apr 2004
Posts: 5

PostPosted: Tue Apr 13, 2004 4:45 pm (20 years ago) Reply with QuoteBack to Top

still getting 'Parse error' i've looked and looked and cant find anything wrong with it. I think its something to do with the loop, but like i said i cant find anything wong with it.
OfflineView User's ProfileFind all posts by retroSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Tue Apr 13, 2004 4:52 pm (20 years ago) Reply with QuoteBack to Top

Its this:
print("</table">;

should be:
print("</table>");
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.430226 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme