CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Can't call method "header" on an undefined value at /var/www/html/.... line 211

 



Emmanuel
New User

May 21, 2018, 12:24 PM

Post #1 of 8 (5314 views)
Can't call method "header" on an undefined value at /var/www/html/.... line 211 Can't Post

Hello Everyone, im trying to run an administrative sistem on a web server, im not the owner of the script, just been asked fol help, but i cant get this script running.
I dont work with Perl, which makes it more difficult form me, but im trying
Can you help me please?

Apache error log:

Can't call method "header" on an undefined value at /var/www/....alum-admin-n.cgi line 211


Line 211 on the script:

209 sub create_form {
210 $title = "Entraste por accidente aqui amigo !!";
211 print $query->header;
212 print $query->start_html($title);
213 print "<H1>$title</H1>\n";
214 print $query->start_form(-target=>'_blank');
215 print "<b>Quien hizo esto?</b> <p>",$query->textfield('T1','Daniel Beltrán Román');
216 print "<p>Porque lo hizo?",$query->textfield('T2','well, that is life!');
217 print "\n<P>",$query->reset('this will not work Ok!');
218 print $query->end_form;
219 print $query->end_html;
220 }


I also added the content type on the beginning:

1 #!/usr/bin/perl
2 print "Content-Type: text/html\n\n";
3

But it still no running


BillKSmith
Veteran

May 21, 2018, 1:43 PM

Post #2 of 8 (5306 views)
Re: [Emmanuel] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

You have not shown us enough code to offer much help. The code that you do show expects the perl scalar variable $query to contain either the name of a class or a reference to an object which has the method "header". Your error message tell us that when line 211 executed, the variable was undefined (i.e. Either it does not exist or if it does, it does not contain any value.)

If you attach the complete script, someone may be willing to debug if for you. A better option is to post a pared down version of your script which demonstrates the problem but does not even try to do anything not directly related to the problem. This must be a complete perl program which we can run and duplicate the error.

It may also help if you tell us the history of this code. Is it new code? Did it ever work? What changed?
Good Luck,
Bill


Emmanuel
New User

May 21, 2018, 3:15 PM

Post #3 of 8 (5301 views)
Re: [BillKSmith] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

Thank you very much for the help, ok, im moving the system to a new server, in the old server it was working fine, its old code, I didnt change anything in the script
Attachments: Script (12.6 KB)


BillKSmith
Veteran

May 21, 2018, 8:55 PM

Post #4 of 8 (5290 views)
Re: [Emmanuel] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

The file that you posted is not the one that you tried to execute. First, I had to rename it with a valid perl name. Then I had to remove the line numbers. The resulting file still does not compile without errors. Something is missing from the end of line 128. When I added enough to make the line valid perl (I have no idea whether or not the SQL is complete), the file did compile.

The error you reported in your first post occurs in the subroutine create_form. This is only called if the input parameter 'aspauth' contains neither OkdbR nor OkGo. This file never successfully called create_form on any server. I would not be doing you a favor by telling you how to fix this error. You really must start with a file that you are 100% certain works on the old server.
Good Luck,
Bill


Emmanuel
New User

May 22, 2018, 1:59 PM

Post #5 of 8 (5282 views)
Re: [BillKSmith] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

Again, thank you for the help, I asked about it and they send me the files again, I can see that the script is different this time, it has more lines, they told me is the script running on the old server, would you look at it please?
Attachments: alum-admin-n.cgi (11.8 KB)


FishMonger
Veteran / Moderator

May 22, 2018, 2:15 PM

Post #6 of 8 (5279 views)
Re: [Emmanuel] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

You need to change each $query to $struct.


Code
sub create_form { 
$title = "Entraste por accidente aqui amigo !!";
print $struct->header;
print $struct->start_html($title);
print "<H1>$title</H1>\n";
print $struct->start_form(-target=>'_blank');
print "<b>Quien hizo esto?</b> <p>",$struct->textfield('T1','Daniel Beltrán Román');
print "<p>Porque lo hizo?",$struct->textfield('T2','well, that is life!');
print "\n<P>",$struct->reset('this will not work Ok!');
print $struct->end_form;
print $struct->end_html;
}



Emmanuel
New User

May 22, 2018, 2:29 PM

Post #7 of 8 (5277 views)
Re: [FishMonger] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

I did that and it runs, but now it shows the error text included in the script


(This post was edited by Emmanuel on May 22, 2018, 2:29 PM)
Attachments: captura (17.5 KB)


BillKSmith
Veteran

May 22, 2018, 9:10 PM

Post #8 of 8 (5269 views)
Re: [Emmanuel] Can't call method "header" on an undefined value at /var/www/html/.... line 211 [In reply to] Can't Post

Your new file is no more help than the original because neither one could have possibly worked on the old server. You really do not have a perl problem, but rather a configure control problem. A correct perl program should work on either server.

FishMonger's correction allows the function 'create_form' to run without any errors. It prints html. Your browser renders this html exactly as you show.

I cannot even begin to guess what else you expect this function to do. If you cannot get a copy of the working program, you are going to need a copy of its specification in order to fix what you have. Do you really expect that the rest of your file will do what you want after you fix this function?
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives