Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by Nik (Initiate)
on May 26, 2008 at 21:09 UTC ( [id://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("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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://688556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-20 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found