Current location: Hot Scripts Forums » Programming Languages » PHP » Undefined index: a - help


Undefined index: a - help

Reply
  #1 (permalink)  
Old 05-16-05, 10:25 AM
andrewvideo andrewvideo is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Undefined index: a - help

I am geting a message saying Undefined index: a line at 3.

this only come up when you type
http://www.homepage.com/index.php

if you put
http://www.homepage.com/index.php?a=whats
it works without messages errors.

How can i can make the php ignore "Undefined index: a line at 3" Can i add a other line so thats ignore that line, if someone only put in index.php

PHP Code:



$a 
$_GET['a']; 
Reply With Quote
  #2 (permalink)  
Old 05-16-05, 02:35 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
if (isset($_GET['a'])) { $a = $_GET['a']; }
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #3 (permalink)  
Old 05-16-05, 04:03 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
$a = (isset($_GET['a'])) ? $_GET['a'] : '';
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #4 (permalink)  
Old 05-17-05, 08:00 AM
andrewvideo andrewvideo is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you that works.

What the diffents beteen Fire's code and becool's code.

which one is the best to use?
Reply With Quote
  #5 (permalink)  
Old 05-17-05, 09:41 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
they both do the same just use different syntax thats all!

if u r new to php tho i wud use my one, ace's is slightly more confusing...
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #6 (permalink)  
Old 05-17-05, 03:33 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
FiRe's is in wrong syntax, the style I used was meant for short checks and one line - FiRe's is an if statement, that are meant for 4 lines or more..

PHP Code:

if (condition)

{
     
// Do something

vs

PHP Code:

(condition) ? condition is true condition is false
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NOTICE: Undefined index jozin PHP 6 04-29-05 04:19 AM
Index page Help @?%^*# yANIME.net JavaScript 3 02-25-05 06:50 AM
Include problem in C bkbenson C/C++ 4 02-08-05 04:24 AM
Create an index with Asp.net-vb code kathryn ASP.NET 0 01-04-05 08:39 AM
Link to index (PR5) or the forum (PR6) iKwak HTML/XHTML/XML 0 08-26-04 03:35 AM


All times are GMT -5. The time now is 06:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.