General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 26th, 2003, 01:56 PM
neolumi neolumi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 2 neolumi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Functions and arrays

Hey! can anyone help me out, for my site i want to create a function which will output an image and error text. So if an error were to comeup itd be:
error(1);

I've got this:
PHP Code:
<?
error_reporting
(E_ALL);

$errorn = array(
'1' => "Fatal Error",
'2' => 'Please Choose a Section',
'3' => 'No affiliates yet!',
'4' => 'Section not yet complete',
'5' => 'No results found'
);
function 
error($n) {
print 
"<center><img src=\"shared/error.gif\" height=\"19\" width=\"99\" border=\"0\"><br><b>".$errorn['$n']."</b></center><br>"; }

error(1);
?>


Which outputs this error message:
Notice: Undefined variable: errorn in /home/zeldax/public_html/tg/testing/error.php on line 12
Im not too sure why its not getting the variable the answer is robably ive messed up but ah well, any help would be appreciated, thanks!

Last edited by neolumi : May 26th, 2003 at 01:59 PM.

Reply With Quote
  #2  
Old May 26th, 2003, 05:34 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
try this

PHP Code:
print "<center><img src=\"shared/error.gif\" height=\"19\" width=\"99\" border=\"0\"><br><b>" . {$errorn[$n]} . "</b></center><br>"
__________________
-- Jason

Reply With Quote
  #3  
Old May 26th, 2003, 06:19 PM
neolumi neolumi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 2 neolumi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nope no luck, it comes up with a parse error so thats your "{ }", thanks anyways!!

Reply With Quote
  #4  
Old May 26th, 2003, 06:33 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
did you try it without the { } ?

$errorn[$n] and not $errorn['$n']

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Functions and arrays


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway