Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: Can i call a handmade perl module within a php file?

by Nik
on May 26, 2008 at 21:09 UTC ( #688556=note: print w/replies, xml ) Need Help??

in reply to Re: Can i call a handmade perl module within a php file?
in thread Can i call a handmade perl module within a php file?

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("", "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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://688556]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-06-24 19:21 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.