Welcome to WebmasterWorld Guest from 54.146.239.96

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Undefined Index Errors.

     

Affectless

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

7:02 am on Sep 19, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

swa66

8:06 am on Sep 19, 2012 (gmt 0)

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



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...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month