I have been working on this for some time and with not really knowing Perl it’s been extremely difficult.

It does seem to be connecting to MySQL because there has not been any of those errors.

I can’t seem to search the database for the value needed.

A short PHP header sends the information the perl script processes.

Is there anyone that can help fix this perl code. I can even send a little by paypal if it’s not to much. The script is working now as long as I don’t try to use the mysql but I would have to hand code each new setup if I want to add more people to it.

The php code could be on any server, the perl will only be on one machine is why I don't put it all in the php page.

I only have 5 people using the setup, so it’s not all that critical, but I have been getting asked by others that would like to use it for their web site.

Before I do that I would like it to stream line it to use a database. Database already exists and can already have data entered by a form page.

Simply saying the script doesn't work is a poor problem description. You should explain in what way it's failing and what errors/warnings it produces.

There are a number of things I'd change, but the initial problem with the database code is in your connection statement. Using single quotes around the vars will prevent interpolation which means that you're passing $user and $pw as literal strings rather than passing the values that those vars hold.

Sorry, I don't know why it's failing other than it's not getting information from the database .

The subscr_id is in the database exactly as it's writen. I even put the subscr_id in the failed message to send me the id and it's not showing is how I figure it's not reading the database at all. I'm getting an error in the subscr_id only - below.

I also tried what you posted and even hard coded the database and connection information. I don't know perl enough to know what else to do.

The database works fine when accessed from a php page on our system. Just this perl one doesn't and it's the only script trying to access the database is why it's hard for me. All the scripts I've found on the internet have all failed. I'm guessing I should just go to using flat files and give up trying to get this working.

$subscr_id is a table name in the database. I've tried the connect lines many different ways with what was on the internet. Upper case DBI lower case dbi and so on. At least 5 or 10 different setups.

All I'm wanting to do with the data from the database is verify the user. If they are not in the database go to the else invalid and send me the notice. If they are valid send them the IP2Location information by email, or text, or both.

username is email address subscr_id should be the id in the php header phone is their phone number@cellphone company domain for text message.

It's working now but only if I hard code each person in the perl file. Just trying to add the database lookup so I won't have to hard code if others start using this. There is only 5 people using it now so hard coding was easy, but if I get more than that the file will get bloated.

That's the funny part. I tried this before also. When it gets declared as you mentioned to try it gives this in the error log. It also did not go to the fail after the removal of the ' if($id eq $subscr_id)

The $subscr_id is the database, $id is from the PHP and it's received fine.

It's unclear from that verbiage if the value of $subscr_id is supposed to be passed in from the php script or hard coded in the perl script.

Code

my $subscr_id = param("subscr_id");

That statement, along with the fact that it's not being assigned elsewhere, tells us that you expect its value to come from the calling php script and the following error message you posted told me that the value was not passed in by the php script which is why you received this error:

You should output all of the vars that are being used in the database calls to verify that they hold what you expect. I suspect (actually expect) that they do not, which would be why the db code is failing.

@lightspd - I just realized there was two here. Here is the script so far. It gives no errors in the logs. The access logs give the two lines listed.

Code

#!/usr/bin/perl use warnings FATAL => 'all'; use strict; use diagnostics; use CGI; use POSIX qw/strftime/; use DBI; use CGI::Carp qw(fatalsToBrowser); # remove this when the script is complete and put into production