Click to See Complete Forum and Search --> : script error, help!!!


casy
05-07-2003, 10:14 PM
I am trying to display my records from an oracle database with the code section below:

while(@row=$sth->fetchrow_array)
{
($fac,$dept,$deg,$major,$credits)=@row;
print "<tr>";
print "<td>$fac</td>";
print "<td>$dept</td>";
print "<td>$deg</td>";
print "<td>$major</td>";
print "<td>$credits</td>"; #line 30
print "</tr>\n";
}

but i always get an error that says 'Use of uninitialized value in concatenation (.) or string at status.cgi line 30.'

what must i do to solve this and get the results printed out?? I've been trying for quite long and nothing works, please help!!!

Scriptage
05-08-2003, 08:53 AM
hmmmmmmmmmmm sorry my example was poor...didnt know what i was on about lol

jeffmott
05-08-2003, 09:16 AM
print "<td>".$credits."</td>";This and what the original poster had do the exact same thing.

Casy, the error you're getting is because the value for the variable $credits is undef. You'll need to have it default to an empty string instead of the undefined value.$credits ||= '';

Scriptage
05-08-2003, 09:18 AM
lol sorry

<------------noob

But...I'm confused.......How can undef make a concatenation error????????? If it's undef then it just prints nothing!!!

Try

#!/usr/bin/perl

$value = undef;

print "$value";

output: " " <-----------nothing

!!!????!!!????

jeffmott
05-08-2003, 09:32 AM
Now try it with warnings enabled, which they always should be.

Scriptage
05-08-2003, 09:35 AM
yeah,
use of uninitialised value in string
not in concactenation!!!!!!!!!!!!!
It is a concactenation error, which means perl is finding a . somewhere..... probably in $credits dont you think

lol

jeffmott
05-08-2003, 10:02 AM
Your example doesn't mention concatentation because you havn't concatenated anything. Replace with this line and see.print "foo $value";which means perl is finding a . somewhere..... probably in $credits dont you thinkDon't confuse variable interpolation with evaling. A period occuring in an interpolated string will not be interpreted as a concatenation operator.

Scriptage
05-08-2003, 10:09 AM
im on about the original posters example read it!!!

jeffmott
05-08-2003, 10:12 AM
im on about the original posters example read it!!!I have read it. And I've answered it. And I've answered you. I'm not sure what you don't understand anymore.

Scriptage
05-08-2003, 10:13 AM
she said she got an error saying concactenation error, an undef variable does not produce a concatenation error!

jeffmott
05-08-2003, 10:20 AM
an undef variable does not produce a concatenation errorIt does if warnings are enabled. So... (a very mild amount of deductive thinking required here) the original poster must have warnings enabled.

Scriptage
05-08-2003, 10:34 AM
no..it says use of unitialised value!!!!!!!!!!!!!!!!!1 not concactenation!!!!!!!!!!!!!! FFS

jeffmott
05-08-2003, 10:37 AM
not concactenationThe original poster's, or your example. Because the error message posted by the OP does say concatenation.

Scriptage
05-08-2003, 10:41 AM
The original poster says she gets a concatenation error.....you say it is because a variable is undef. However....if you try my example you will find that an undef variable produces the error "use of unitialised value" not "concactenation".
Understand???

jeffmott
05-08-2003, 10:45 AM
....if you try my example you will find that an undef variable produces the error "use of unitialised value" not "concactenation".
Understand???Yes, I do understand. I understood 8 posts ago where I already told you why.

Scriptage
05-08-2003, 10:49 AM
lol sorry
missed it
<------------complete tit

casy
05-08-2003, 08:58 PM
thx all, i've switch to another script so itz alrite now.