I decided to follow step No3 although i dont know any php :)
The closest solution i came up with is the following, please correct my mistakes
This is the function that i want to make a php module out of it so every php script can easily invoke the php module: This is just the function i dont know how to make it a php module...
<?php
function counter($pagename,$db,$host) {
preg_match("{([^/\\]+?)(?:\.[^/\\.]+)?$}", $pagename, $matches); l
+ist($pagename) = $matches;
//======= Insert or Update pagecounter appropriately, then display
+ it ========
@$db->do('INSERT INTO counters (pagename, pagecounter) VALUES (?,
+0)', null, $pagename);
if ($host != 'webmaster') $db->do('UPDATE counters SET pagecounter
+ = pagecounter + 1 WHERE pagename = ?', null, $pagename);
list($counter) = $db->selectrow_array('SELECT pagecounter FROM cou
+nters WHERE pagename = ?', null, $pagename);
return $counter;
}
?>
...and after the creation of the module i will have to invoke it as follows(iam sure i have errors)
$file = $_SERVER['SCRIPT_FILENAME'];
$host = $_SERVER['SERVER_ADDR'];
$db = mysql_pconnect("mysql1.000webhost.com", "a3310457_counter", "a33
+10457_akis", "*****"); #i changed host and details here
$counter = counter( $file, $db, $host );
This became php coding now but it started as a perl question and ended like this (sorry for this)
If someone knows a bit of php then please helpe me correct soem errore i have so i get this thing finally to work.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.