Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
finance products
domain names
dvd information
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Log stats part 2


Log stats

Welcome to the second part of this mini tutorial / code snippet . Now we will log some info to our MySQL database using PHP .

Here is the script we are using , you will have to input ypour own host , username and password for this to operate correctly.

<?php
//store the users browser in a variable
$users_browser = $HTTP_USER_AGENT;
//store the users IP in a variable
$users_ip = $REMOTE_ADDR;
//database connection
$connection = mysql_connect("localhost" , "username" , "password");
//select the stats database
mysql_select_db("stats" , $connection);
//insert the info into the stats table
$sql_query = "INSERT INTO stats(browser,ip,logdate)
VALUES('$users_browser','$users_ip',now())";
//store
$result = mysql_query($sql_query);
?>

Now all we have to do is test the script works correctly , save the above and call it something like logstats.php , now load this page into your web browser , if you have more than one different make of browser that is even better .

Now go back to MySQL command line and type in the following

SELECT * FROM stats;

If all has gone to plan you should now see an entry in your table , here is a screen capture of what we had displayed.

Note this is only part of the table that was displayed but as you can see it has logged 2 different browsers Internet Explorer 5.5 and Opera 5 as well.

In the next part we will show how to display the results in an HTML table in your browser.

Back to Part 1 , Forward to Part 3




Books
 Sponsors


 Random Code
functions(Get thumbnails of a video using ffmpeg and php)
Basic currency conversion(application)
Random passwords(randomizing)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.