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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.