Re: uninitialized variable

2005-11-01 Thread Chris Devers
On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:

 my $action = param('form_action');

Try setting a default value when 'form_action' isn't specified:

my $action = param('form_action') or '';

Or set it to 0, or 'do nothing' or undef, or whatever is appropriate.


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread DBSMITH
   
 Chris Devers  
 [EMAIL PROTECTED] 
 m To 
   Adedayo Adeyeye 
 11/01/2005 10:42  [EMAIL PROTECTED]
 AM cc 
   beginners-cgi@perl.org  
   Subject 
 Please respond to Re: uninitialized variable  
 [EMAIL PROTECTED] 
   l.org   
   
   
   
   







On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:

 my $action = param('form_action');

Try setting a default value when 'form_action' isn't specified:

my $action = param('form_action') or '';

Or set it to 0, or 'do nothing' or undef, or whatever is appropriate.


--
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





from Perl Best Practices


use

my $action = param('form_action') | | q{ }


instead of

or ' '

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread Sara

my $action = param('form_action') || 'any_default_value';

HTH,
Sara.


- Original Message - 
From: Chris Devers [EMAIL PROTECTED]

To: Adedayo Adeyeye [EMAIL PROTECTED]
Cc: beginners-cgi@perl.org
Sent: Tuesday, November 01, 2005 8:42 PM
Subject: Re: uninitialized variable



On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:


my $action = param('form_action');


Try setting a default value when 'form_action' isn't specified:

   my $action = param('form_action') or '';

Or set it to 0, or 'do nothing' or undef, or whatever is appropriate.


--
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread Chris Devers
On Tue, 1 Nov 2005 [EMAIL PROTECTED] wrote:

 from Perl Best Practices
 
 use
 
my $action = param('form_action') | | q{ }
 
 instead of
 
or ' '


Good catch. Yes, that's clearer than simple apostrophes.

However, you probably didn't really mean | | over ||, right ? :-)

I still think 'or' is clearer than '||' for this kind of thing, but if 
PBP had a different rationale I can't remember what it was...


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: uninitialized variable

2005-11-01 Thread Dave Doyle
On Tuesday, November 01, 2005 Chris Devers wrote: 
On Tue, 1 Nov 2005 [EMAIL PROTECTED] wrote:
 from Perl Best Practices
 
 use
 
my $action = param('form_action') | | q{ }
 
 instead of
 
or ' '

Good catch. Yes, that's clearer than simple apostrophes.

However, you probably didn't really mean | | over ||, right ? :-)

I still think 'or' is clearer than '||' for this kind of thing, but if 
PBP had a different rationale I can't remember what it was...

My understanding is that you use || because it's more tightly bound than
'or'.  Although I would suggest something further for this:

my $action 
= defined( param('form_action') ) 
? param('form_action') 
: 'default_value'
;

This way if zero is a valid value for the form_action parameter it will
still pass through. Depends how you're doing things really.

Further, Data::FormValidator might be of interest in the future.

--
Dave Doyle

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread DBSMITH
   
 Chris Devers  
 [EMAIL PROTECTED] 
 m To 
   [EMAIL PROTECTED]  
 11/01/2005 11:10   cc 
 AMbeginners-cgi@perl.org  
   Subject 
   Re: uninitialized variable  
 Please respond to 
 [EMAIL PROTECTED] 
   l.org   
   
   
   







On Tue, 1 Nov 2005 [EMAIL PROTECTED] wrote:

 from Perl Best Practices

 use

my $action = param('form_action') | | q{ }

 instead of

or ' '


Good catch. Yes, that's clearer than simple apostrophes.

However, you probably didn't really mean | | over ||, right ? :-)

I still think 'or' is clearer than '||' for this kind of thing, but if
PBP had a different rationale I can't remember what it was...


--
Chris Devers
*


yes dudegood catch as well . aka || and {}
Its a lotus notes thing... : (


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread Shawn Corey

Adedayo Adeyeye wrote:

Hello,

I'm getting an error when trying to run a script. Part of the scripts is

Line 10 my $action = param('form_action');

 .

 Line 14 Search_DB()  if($action eq 'search');

The error I get is:

 


[Tue Nov  1 16:28:41 2005] connect_script.cgi: Use of uninitialized value in
string eq at connect_rodopi.cgi line 14. 

 


How am I supposed to initialize this value?

 


Kind regards

 


Dayo

 

 






Two things you can do:

line 10: my $action = param('form_action') || '';

or

line 14: Search_DB() if( defined( $action )  $action eq 'search' );

The first solution implies that the value '' for $action will never be 
tested for. I prefer the second one. You can always put it in its own if 
statement:


if( defined( $action )){
  # list of actions
  ...
  Search_DB() if $action eq 'search';
  ...
}else{
  # page for no action
  ...
}


--

Just my 0.0002 million dollars worth,
   --- Shawn

Probability is now one. Any problems that are left are your own.
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: uninitialized variable

2005-11-01 Thread David Dorward
On Tue, Nov 01, 2005 at 04:34:45PM +0100, Adedayo Adeyeye wrote:

 I'm getting an error when trying to run a script. Part of the scripts is

 my $action = param('form_action');
 if($action eq 'search');

 The error I get is:
 Use of uninitialized value in string eq at connect_rodopi.cgi line 14. 

Looks more like a warning then an error to me.

 How am I supposed to initialize this value?

By assigning something to it, but in this case its possibly better to
test if something was assigned to it.

if (defined $action  $action eq 'search') ...

or 

if (!defined $action) {
  ...
} elsif ($action eq 'search') {
  ...
} 

-- 
David Dorward  http://dorward.me.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: uninitialized variable

2005-11-01 Thread Adedayo Adeyeye
Thanks. That's cleared now.

I'm also trying to connect to an mssql db from a cgi, and I'm getting the
following error:

Cannot connect: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does
not exist or access denied. (SQL-08001)[Microsoft][ODBC SQL Server
Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000)(DBD:
db_login/SQLConnect err=-1)Aborting at C:\Savant\cgi-bin\connect_rodopi.cgi
line ...

Help appreciated.

Kind regards

Dayo



-Original Message-
From: David Dorward,,, [mailto:[EMAIL PROTECTED] On Behalf Of David Dorward
Sent: Tuesday, November 01, 2005 4:40 PM
To: beginners-cgi@perl.org
Subject: Re: uninitialized variable

On Tue, Nov 01, 2005 at 04:34:45PM +0100, Adedayo Adeyeye wrote:

 I'm getting an error when trying to run a script. Part of the scripts is

 my $action = param('form_action');
 if($action eq 'search');

 The error I get is:
 Use of uninitialized value in string eq at connect_rodopi.cgi line 14. 

Looks more like a warning then an error to me.

 How am I supposed to initialize this value?

By assigning something to it, but in this case its possibly better to
test if something was assigned to it.

if (defined $action  $action eq 'search') ...

or 

if (!defined $action) {
  ...
} elsif ($action eq 'search') {
  ...
} 

-- 
David Dorward  http://dorward.me.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: uninitialized variable

2005-11-01 Thread Chris Devers
On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:

 I'm also trying to connect to an mssql db from a cgi, and I'm getting the
 following error:
 
 Cannot connect: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL 
 Server does not exist or access denied. (SQL-08001)[Microsoft][ODBC 
 SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). 
 (SQL-01000)(DBD: db_login/SQLConnect err=-1)Aborting at 
 C:\Savant\cgi-bin\connect_rodopi.cgi line ...

This seems to be the meat of the problem:

SQL Server does not exist or access denied

Sounds like a DB admin issue to me. 

Can you use the same login credentials to connect to the database via 
some other means than the CGI script you're writing? If you can't, then 
there's the problem; if you can, then something about using that user / 
password pair from the host where your CGI script is running is broken.

Either way, it sounds like a SQL Server admin config issue, not CGI.



-- 
Chris Devers

by¯LcìØL è…8
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


RE: uninitialized variable

2005-11-01 Thread Adedayo Adeyeye
Thanks once again.

I'm running this script on two different machines, both separate from the
machine the Database is running on. 

It works on one Server and it fails on the other. I believe that, it's
trying to connect to a local database on the system it fails rather than
connecting to an external database on another system.

What's the syntax to specify a DSN that includes the IP of Remote MSSql
Server when using dbi-odbc?

Kind regards

Dayo



-Original Message-
From: Chris Devers [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 01, 2005 10:23 PM
To: Adedayo Adeyeye
Cc: Perl Beginners - CGI List
Subject: RE: uninitialized variable

On Tue, 1 Nov 2005, Adedayo Adeyeye wrote:

 I'm also trying to connect to an mssql db from a cgi, and I'm getting the
 following error:
 
 Cannot connect: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL 
 Server does not exist or access denied. (SQL-08001)[Microsoft][ODBC 
 SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). 
 (SQL-01000)(DBD: db_login/SQLConnect err=-1)Aborting at 
 C:\Savant\cgi-bin\connect_rodopi.cgi line ...

This seems to be the meat of the problem:

SQL Server does not exist or access denied

Sounds like a DB admin issue to me. 

Can you use the same login credentials to connect to the database via 
some other means than the CGI script you're writing? If you can't, then 
there's the problem; if you can, then something about using that user / 
password pair from the host where your CGI script is running is broken.

Either way, it sounds like a SQL Server admin config issue, not CGI.



-- 
Chris Devers

by¯LcìØL è…8



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response