homepage Welcome to WebmasterWorld Guest from 54.237.78.165
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Undefined Index Errors.
Affectless



 
Msg#: 4497205 posted 6:21 am on Sep 19, 2012 (gmt 0)

Hi, I have just gotten back into PHP and I am having a simple error. The reason why I call it simple is because I have seen it answered on google already but they all use If statements to fix it. Heres the errors I get
Notice: Undefined index: id in C:\xampp\htdocs\MemberSystem\config.php on line 7

Notice: Undefined index: password in C:\xampp\htdocs\MemberSystem\config.php on line 7


Now, in my config....

<?php
@session_start(); //allows session

$conn = mysql_connect("localhost","haha",""); //not my actual connectionsl0l
mysql_select_db("haha2") or die(mysql_error());

$logged = MYSQL_QUERY("SELECT * FROM `members` WHERE `id` = '$_SESSION[id]' AND `password` = '$_SESSION[password]'");
$logged = mysql_fetch_array($logged);

?>


As you can see on line 7 is where all the problems happen, I fixed the last error by just adding a bracket on one of them and it removed an undefined index error, but I can't seem to fix this one... Please help.

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4497205 posted 7:02 am on Sep 19, 2012 (gmt 0)

You should be checking those server variables have actually been set waaaay before you attempt to use them.

swa66

WebmasterWorld Senior Member swa66 us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4497205 posted 8:06 am on Sep 19, 2012 (gmt 0)

Also check what's in the variables, anything coming from the browser should never be handed to a database without sanitizing it.

Ref: [xkcd.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved