Welcome to WebmasterWorld Guest from 50.16.126.107

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Undefined Index Errors.

     
6:21 am on Sep 19, 2012 (gmt 0)

New User

joined:Sept 19, 2012
posts:1
votes: 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.
7:02 am on Sept 19, 2012 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


You should be checking those server variables have actually been set waaaay before you attempt to use them.
8:06 am on Sept 19, 2012 (gmt 0)

Senior Member

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

joined:Aug 7, 2003
posts:4783
votes: 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...]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members