xProteuSx Posted November 12, 2011 Share Posted November 12, 2011 I have been working on a PHP site on an actual server that is online. This is bad practice, and a huge pain in the ass as I need to upload all files to test whether the work. So I've installed XAMPP and have transferred my database and website to the root folder. Now I get these errors: Notice: Undefined index: username in C:\xampp\htdocs\members.html on line 19 This error is produced here: session_start(); $fc_user = ''; $fc_pass = ''; if (isset($_SESSION['fc_handle']) && isset($_SESSION['fc_password'])) { $fc_user = $_SESSION['fc_handle']; $fc_pass = base64_encode($_SESSION['fc_password']); } else if (isset($_POST['username']) && isset($_POST['password'])) { $fc_user = $_POST['username']; $fc_pass = base64_encode($_POST['password']); } else if ((($_POST['username'] == '') || ($_POST['password'] == '')) && (($_SESSION['fc_handle'] == '') || ($_SESSION['fc_id'] == ''))) /// <-- THIS IS LINE 19 { header("Location: http://www.familychores.com/index_coming.html"); exit; } I can't figure this out ... Link to comment https://forums.phpfreaks.com/topic/250976-undefined-variable-index/ Share on other sites More sharing options...
trq Posted November 12, 2011 Share Posted November 12, 2011 You need to use isset to check that variables are set prior to accessing them. Link to comment https://forums.phpfreaks.com/topic/250976-undefined-variable-index/#findComment-1287536 Share on other sites More sharing options...
xProteuSx Posted November 12, 2011 Author Share Posted November 12, 2011 Actually, it turns out the problem was a little different than what I wrote before ... I am using code like this: <a href="add.html?id=' . $row[id] . '&name=' . $row[name] . '">Add</a> As you can see I am using variables like $row[id] instead of $row['id'] I can't get this to work: <a href="add.html?id=' . $row[\'id\'] . '&name=' . $row[\'name\'] . '">Add</a> And I'd rather not do this: $id = $row['id']; $name = $row['name']; <a href="add.html?id=' . $id . '&name=' . $name . '">Add</a> Any other ideas??? Please??? Link to comment https://forums.phpfreaks.com/topic/250976-undefined-variable-index/#findComment-1287539 Share on other sites More sharing options...
xProteuSx Posted November 12, 2011 Author Share Posted November 12, 2011 Jeez, I figured it out. I was doing this: echo '<a href="add.html?id=' . $row[id] . '&name=' . $row[name] . '">Add</a>'; That is why I couldn't do this: <a href="add.html?id=' . $row[\'id\'] . '&name=' . $row[\'name\'] . '">Add</a> However, I can do this: <a href="add.html?id=' . $row["id"] . '&name=' . $row["name"] . '">Add</a> Link to comment https://forums.phpfreaks.com/topic/250976-undefined-variable-index/#findComment-1287540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.