Jump to content

Undefined variable / index


xProteuSx

Recommended Posts

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

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???

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.