Help with PERL code

Status
Not open for further replies.

oiwio

New Member
Messages
214
Reaction score
0
Points
0
Im trying to have this file run with a cron that will go into the database and add 1 to all the users hp. Right now Im getting the error:
Code:
Can't locate Mysql.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at /home/oiwio/public_html/hpup2.pl line 4.
BEGIN failed--compilation aborted at /home/oiwio/public_html/hpup2.pl line 4.

And here is the code inside the perl file
Code:
[I]#!/usr/bin/perl[/I]


[I]# PERL MODULE WE WILL BE USING[/I]
[B]use[/B] Mysql;


[I]# MySQL CONFIG VARIABLES[/I]
$host = "fmammorpg";
$database = "oiwio_oiwio";
$tablename = "users";
$user = "oiwio_oiwio";
$pw = "moosey11";


[I]# PERL MYSQL CONNECT [/I]
$[B]connect[/B] = Mysql->[B]connect[/B][U]([/U]$host, $database, $user, $pw[U])[/U];


$[B]connect[/B]->selectdb[U]([/U]$database[U])[/U];


SETVALUES [U]([/U]$hp[U])[/U] = $hp + 1;


$myquery = "INSERT INTO
$tablename [U]([/U]username, hp[U])[/U]
VALUES [U]([/U]*, $hp[U])[/U]";


$execute = $[B]connect[/B]->query[U]([/U]$myquery[U])[/U];

Help would be thanked alot since I have no experiance in .pl
 

mattura

Member
Messages
570
Reaction score
2
Points
18
It seems it can't find the Mysql module... Are you sure it is installed? Perhaps it was not uploaded in ascii? Remember it is case-sensitive.
Try putting an absolute path to the module (use /some-path/Mysql;).
Did you install the module yourself or expect it to be there?
 

oiwio

New Member
Messages
214
Reaction score
0
Points
0
Im not sure if the Mysql module is installed or how I would be able to.
I tried put a path like "use /oiwio_oiwio/Mysql" Im not sure if thats right or what would be right.

And I did just expect it to be installed automatically.

Sorry if its frustrating since I dont know that much about the stuff you were talking about.
 

mattura

Member
Messages
570
Reaction score
2
Points
18
Ok, looks like you took the code from a tutorial or something... You need to find a module called "Mysql.pm", download it from somewhere (ask google), unzip it (properly - with the directory structure) and put it in your webspace. Then put the path to the .pm in the "use" line.
Looking up how to use perl modules woudn't go amiss either. I'm not particularly knowledgeable on the subject
The above method may even not work, depends on how x10hosting is set up. Ask an admin!

Or learn a bit of php, it's quite simple to write equivalent code to the above in PHP, actually very similar.
 

oiwio

New Member
Messages
214
Reaction score
0
Points
0
I do know quite a bit of php but Im not sure how or even if I could run a php file off of a cron command.

And I cant seem to find a mysql.pm module
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Of course you can run php files off a cron

You just need to set the appropriate hashbangs at the top of the php document.
 

oiwio

New Member
Messages
214
Reaction score
0
Points
0
in that case, can someone help me create a php document that I can run off of a cron? or do I still have to have the cron run the .sh file then the php file? And i dont know what hashbags are. Im guessing its that #!user/bin/perl code
 
Status
Not open for further replies.
Top