Connecting Tech Pros Worldwide Forums | Help | Site Map

send_message problems

Newbie
 
Join Date: Nov 2006
Posts: 1
#1: Nov 3 '06
hello everyone

i'm well new to perl, so please bear with me

I've been given a sample perl script from a company called Dialogue

Theres a couple of issues I'm having so here's the sample file

http://pastie.caboo.se/21022

if I run the script from the command line, then the scritp only executes the first send_message. I understand this as I'm not passing it the $number and $message variable from the form.
If I declare the $number and the $message variable in the perl script though, it still doesn't send the second message, run the sub routine of send_message.

if I don't declare the variables and send the form to it, then I get a 500 error but the script does complete the first send_message again, but not teh second.

I also get these errors in my apache log.

main::send_message() called too early to check prototype at messaging.mpl line 15., referer: http://pathtoform.php
malformed header from script. Bad header=HTTP/1.1 200 OK: messaging.mpl, referer: http://pathtoform.php

Can someone tell me if the perl logic is good in that script plesae? As far as i can tell it's trying to declare $number and $message using @_, but I'm not familiar with this at all

Anu help, greatly appreciated

apache2
php 5.14
System FreeBSD burnaby.textdrive.com 5.4-STABLE FreeBSD 5.4-STABLE #0: Sun Oct 23 20:24:16 GMT 2005 root@mother.textdrive.com:/usr/obj/usr/src/sys/TEXTOVERDRIVE i386
Build Date Jun 8 2006 08:47:05
Configure Command './configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--enable-spl' '--program-prefix=' '--enable-force-cgi-redirect' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' 'i386-portbld-freebsd5.4'
Server API CGI/FastCGI

miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#2: Nov 5 '06

re: send_message problems


Your problem can be traced to the following bit of code:

Quote:

Originally Posted by vanderkerkoff

print "Submit result: ",send_message("44976918568","this is a test message using POST"),"\n";

#
# Send SMS message
#

sub send_message() {
my ($number,$message) = @_;

Your definition of the send_message function is using a prototype. IE the (). That prototype claims that the send_message function receives no parameters. But it does in fact receive two parameters, so I would remove the parenthesis from your definition.

What the exact error message is saying is that because of the way that apache compiles and runs the perl script, the prototype definition is not being reached before a call to the function. The whole point of a prototype is to enforce the expected parameters to a function, but because of your placement, perl isn't able to do that and a warning a thrown.

In this case though, the only bit of that you need to understand is that when perl is talking about prototypes, it is talking about the fact that you have a () in your sub definition. Remove them.
Reply