Gossamer Forum
Home : General : Perl Programming :

Am I going mad?

Quote Reply
Am I going mad?
Ok, can someone please tell me if i am going mad.

What is wrong with this line;

if (!$address_1 || $address_1 eq " ") { &error("You did not enter an address"); )

If I comment this line out, everything works fine, but as soon as i uncomment it i get an error saying;

[Thu Dec 13 10:23:51 2001] join.cgi: syntax error at /home/ace-installer.com/public_html/develop/join.cgi line 45, near "}"
[Thu Dec 13 10:23:51 2001] join.cgi: Execution of /home/ace-installer.com/public_html/develop/join.cgi aborted due to compilation errors.

Anyone see it?

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Am I going mad? In reply to
Andy,

The codes you posted do have syntax errors in them...The most imporant being that you do not have a closing right bracket....

Use the following:

Quote:

if (!$address_1) {
&error("You did not enter an address");
}

========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Heckler] Am I going mad? In reply to
God, I cant believe i missed that Tongue I think I really need to turn of that auto-complete thing in my Perl editor Frown Its more trouble than its worth.

Thanks Eliot

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Am I going mad? In reply to
Code:
if (!$address_1 || $address_1 eq " ") { &error("You did not enter an address"); )

should be

if (!$address_1 || $address_1 eq " ") { &error("You did not enter an address"); }

- wil
Quote Reply
Re: [Wil] Am I going mad? In reply to
Like I already posted, Wil. Tongue

You do not need to include the "null" testing codes since the !$var already takes care of that.

========================================
Buh Bye!

Cheers,
Me

Last edited by:

Heckler: Dec 13, 2001, 9:21 AM
Quote Reply
Re: [Heckler] Am I going mad? In reply to
Hi Eliot

My apolagies. It took me about half an hour to compose my reply due to a colleague coming into my office to discuss something, therefore I didn't see your reply.

$var can exist with a value of " ". Therefore, !$var will not be the same as $var = " ";. If he would of said $var = ""; then that would of been the same as $var.

- wil

Last edited by:

Wil: Dec 13, 2001, 9:28 AM
Quote Reply
Re: [Wil] Am I going mad? In reply to
Yup, that is the exact reasoning behind my original code. Still can't believe i missed that ) instead of a } Frown

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Am I going mad? In reply to
hm... but you should use a regex cause what if there are two spaces????
$var =~ /^\s*$/
which would also replace the first test as well if I'm not wrong.

--Philip
Links 2.0 moderator
Quote Reply
Re: [ThatPerson1024] Am I going mad? In reply to
Good point. I have changed that now. Thanks for pointing that out Cool

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Am I going mad? In reply to
Andy, you should probably really use some detailed regex if you want it to be semi-foolproof because if you just check thet the field has something in it then for address I could just enter:

.

...and it would be valid. For an address you should make the regex check for letters/numbers/spaces etc...and for zips only digits etc.
Quote Reply
Re: [PaulW] Am I going mad? In reply to
Yeah, I just wanted really to get the basics going first. I did have more complex regexs in there, but i removed them after that line was causing errors, as i assumed it was that which was causing the problems (how wrong i was...lol)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!