Undefined variable(how to) define

Notice: Undefined index: member_id in /home/vhosts/myproject.6te.net/search.php on line 89
this is search.php

<?php
    session_start();
    include("connection.php");
    include("function.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
    <!--
    Created by Artisteer v3.0.0.39952
    Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
    -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>New Page</title>
    <meta name="description" content="Description" />
    <meta name="keywords" content="Keywords" />

    <link rel="shortcut icon" a href="images/logo.png" />
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->


    <script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
    <link href="facebox1.2/src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
            <link href="../css/example.css" media="screen" rel="stylesheet" type="text/css" />
            <script src="facebox1.2/src/facebox.js" type="text/javascript"></script>
            <script type="text/javascript">
                jQuery(document).ready(function($) {
                    $(" a[rel*=facebox]" ).facebox({
                        loadingImage : " ../src/loading.gif" ,
                        closeImage   : " ../src/closelabel.png"
                    })
                })
    </script>
</head>
<body>

<div id="art-main">
    <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
            <div class="art-header">
                <div class="art-header-clip">
                <div class="art-header-center">
                    <div class="art-header-png"></div>
                    <div class="art-header-jpeg"></div>
                </div>
                </div>
                <div class="art-logo">
                                 <h1 class="art-logo-name"><a href="./index.html"></a></h1>
                                                 <h2 class="art-logo-text"></h2>
                                </div>
            </div>
            <div class="cleared reset-box"></div>
<div class="art-nav">
    <div class="art-nav-l"></div>
    <div class="art-nav-r"></div>
<div class="art-nav-outer">
    <ul class="art-hmenu">
        <li>
            <a href="hometest.php" ><span class="l"></span><span class="r"></span><span class="t"><font color="#ba1802">Home</font></span></a>
        </li>
            <li>
            <a href="updates.php" ><span class="l"></span><span class="r"></span>
            <span class="t"><font color="#ba1802">Happenings</font></span></a>
            <ul>
                <li>
                    <a href="mails.php" ><span class="l"></span><span class="r"></span>
                    <span class="t"><font color="#000000">Mails</font></span></a>
                </li>
                <li>
                    <a href="updates.php" ><span class="l"></span><span class="r"></span>
                    <span class="t"><font color="#000000">Updates</font></span></a>
                </li>
                <li>
                    <a href="updates.php"><span class="l"></span><span class="r"></span>
                    <span class="t"><font color="#000000">Friendly Offers(<?php

                    $member_id=$_SESSION['member_id'];
                    $seeall=mysql_query("SELECT * FROM friends WHERE friends_with='$member_id' AND status='unconf'") or die(mysql_error());
                    $pila=mysql_numrows($seeall);
                    echo $pila; ?>)</font></span></a>
                </li>
            </ul>
        </li>
        <li>
            <a href="profiletest.php" class="active"><span class="l"></span><span class="r"></span><span class="t"><font color="#ba1802">Profile</font></span></a>
        </li>
        <li>
            <a href="logout.php" ><span class="l"></span><span class="r"></span><span class="t"><font color="#ba1802">Log-out</font></span></a>
        </li>
    </ul>
</div>
</div>
<div class="cleared reset-box"></div>
<div class="art-content-layout">
                <div class="art-content-layout-row">
                    <div class="art-layout-cell art-sidebar1">
<!--<div class="art-vmenublock">
    <div class="art-vmenublock-tl"></div>
    <div class="art-vmenublock-tr"></div>
    <div class="art-vmenublock-bl"></div>
    <div class="art-vmenublock-br"></div>
    <div class="art-vmenublock-tc"></div>
    <div class="art-vmenublock-bc"></div>
    <div class="art-vmenublock-cl"></div>
    <div class="art-vmenublock-cr"></div>
    <div class="art-vmenublock-cc"></div>

</div> -->
<div class="art-block">
    <div class="art-block-tl"></div>
    <div class="art-block-tr"></div>
    <div class="art-block-bl"></div>
    <div class="art-block-br"></div>
    <div class="art-block-tc"></div>
    <div class="art-block-bc"></div>
    <div class="art-block-cl"></div>
    <div class="art-block-cr"></div>
    <div class="art-block-cc"></div>
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">Profile</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-body">
                    <?php
                    $sql=mysql_query("SELECT * FROM members WHERE member_id='$member_id'") or die(mysql_error());
                    $getpic=mysql_fetch_array($sql);
                    echo "<center><img src='image/members/".$getpic['photo']."' width='130px' height='230px' alt='Image cannot be dispalyed'></center>";
                    ?>
                    </div>
                </div>
        <div class="cleared"></div>
    </div>
</div>
<div class="art-block">
    <div class="art-block-tl"></div>
    <div class="art-block-tr"></div>
    <div class="art-block-bl"></div>
    <div class="art-block-br"></div>
    <div class="art-block-tc"></div>
    <div class="art-block-bc"></div>
    <div class="art-block-cl"></div>
    <div class="art-block-cr"></div>
    <div class="art-block-cc"></div>
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                      <h3 class="t"><a href="friends.php?id=<?php echo $member_id;?>" rel='facebox' style="text-decoration:none;"> School Friends</a></h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-body">
            <p>
            <?php
                //showfriends($_SESSION['studentid']['member_id']);
            ?>
             </p>
                                        <div class="cleared"></div>
                    </div>
                </div>
        <div class="cleared"></div>
    </div>
</div>

                      <div class="cleared"></div>
                    </div>
                    <div class="art-layout-cell art-content">
<div class="art-post">
<div align="center" style="margin-top: 20px;">
        <font style="Calibri" size="3%" >
        <img src="images/edit_friend.png"><a href="editqnu.php?id=<?php echo $member_id;?>"  style="text-decoration:none;"> Update Profile </a></strong> &nbsp;&nbsp;&nbsp;&nbsp;
         <img src="images/info.png"><a href="info.php?id=<?php echo $member_id;?>" rel='facebox' style="text-decoration:none;">About Me</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <img src="images/messages.png"><a href="mails.php?id=<?php echo $member_id;?>"  style="text-decoration:none;">Mails</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <img src="images/photo.png"><a href="photo.php" style="text-decoration:none;">Snapshots</a>


        </div>



        <div class="cleared"></div>

</div>
<div class="art-post">

        <div class="art-post-inner art-article"  style="width: 527px;">
            <div class="art-block">
            <div class="art-block-tl"></div>
            <div class="art-block-tr"></div>
            <div class="art-block-bl"></div>
            <div class="art-block-br"></div>
            <div class="art-block-tc"></div>
            <div class="art-block-bc"></div>
            <div class="art-block-cl"></div>
            <div class="art-block-cr"></div>
            <div class="art-block-cc"></div>
            <div class="art-block-body" style="width: 495px;">
                        <div class="art-blockheader">
                            <div class="l"></div>
                            <div class="r"></div>
                            <h3 class="t">Search Result</h3>
                        </div>
                        <div class="art-blockcontent">
                            <div class="art-blockcontent-body">
                            <?php
                        if(isset($_POST['search'])){
                            $search_term = $_POST['friend'];
                             echo "<div style='float: left;padding: 14px 21px;width: 548px;'>";
                             echo "<h3 style='padding-bottom:10px;'></h3>";
                             searchmembers($search_term);
                             echo "</div>";
                        }
                        ?>
                            <h2 class="art-postheader">
                            </h2>
                        <div class="cleared"></div>
                            <div><form method='post' action='test.php'>
                                </form>
                            </div>
                            <div class="cleared"></div>
                            </div>
                        </div>
                <div class="cleared"></div>
            </div>
        </div>

        <div class="cleared"></div>
        </div>

        <div class="cleared"></div>

</div>
            <div class="art-post-body">

            </div>
                      <div class="cleared"></div>
                    </div>
                    <div class="art-layout-cell art-sidebar2">
<div class="art-block">
    <div class="art-block-tl"></div>
    <div class="art-block-tr"></div>
    <div class="art-block-bl"></div>
    <div class="art-block-br"></div>
    <div class="art-block-tc"></div>
    <div class="art-block-bc"></div>
    <div class="art-block-cl"></div>
    <div class="art-block-cr"></div>
    <div class="art-block-cc"></div>
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">Look for your friends</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-body">
                <div>
                  <form name="search" method="POST" id="search">
                    <p>&nbsp;<input type="text" name="friend" id="searchfriend"  onclick="this.value='';" value="CHMSCians..."/></p>
                    <p><input type="submit" name="search" id="searchbutton" value="Search"/></p>


  </form>
</div>
                                        <div class="cleared"></div>
                    </div>
                </div>
        <div class="cleared"></div>
    </div>
</div>
<div class="art-block">
    <div class="art-block-tl"></div>
    <div class="art-block-tr"></div>
    <div class="art-block-bl"></div>
    <div class="art-block-br"></div>
    <div class="art-block-tc"></div>
    <div class="art-block-bc"></div>
    <div class="art-block-cl"></div>
    <div class="art-block-cr"></div>
    <div class="art-block-cc"></div>
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">CHMSCians you may know</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-body">
                <div>
                                   <?php
                                 $id = $_SESSION['member_id'];
                                $post = mysql_query("SELECT * FROM members WHERE member_id != $id LIMIT 0,2")or die(mysql_error());
                                while($row = mysql_fetch_array($post)){
                            echo '
                            <ul>
                                <p align="center"><a href="profilefriends.php?id='.$row['member_id'].'" style="text-decoration:none;"><img src="image/members/'.$row['photo'].'" alt="" height="70" width="70" border="0" class="left_bt" />
                                <p align="center">'.$row['firstname']." ".$row['lastname'].'</p>
                                <p align="center" style="margin-left: 2px;"><a href="addfriend.php?id='.$row['member_id'].'" rel="facebox" style="text-decoration:none;">Add as School Friend</a></p>
                            </ul>';
                        }
                ?>

                </div>
                                        <div class="cleared"></div>
                    </div>
                </div>
        <div class="cleared"></div>
    </div>
</div>
<div class="art-block">
    <div class="art-block-tl"></div>
    <div class="art-block-tr"></div>
    <div class="art-block-bl"></div>
    <div class="art-block-br"></div>
    <div class="art-block-tc"></div>
    <div class="art-block-bc"></div>
    <div class="art-block-cl"></div>
    <div class="art-block-cr"></div>
    <div class="art-block-cc"></div>
    <div class="art-block-body">
                <div class="art-blockheader">
                    <div class="l"></div>
                    <div class="r"></div>
                    <h3 class="t">CHMSC Spots</h3>
                </div>
                <div class="art-blockcontent">
                    <div class="art-blockcontent-body">
                        <script type="text/javascript" src="gallery/js/jquery.js"></script>
<script type="text/javascript" src="gallery/js/swfobject.js"></script>
<script type="text/javascript" src="gallery/js/flashgallery.js"></script>
<script type="text/javascript">
jQuery.flashgallery('gallery/gallery.swf', 'gallery/config.json', { width: '180', height: '250px', background: 'transparent' });
</script>
                    <div class="cleared"></div>
                    </div>
                </div>
        <div class="cleared"></div>
    </div>
</div>
                      <div class="cleared"></div>
                    </div>
                </div>
            </div>
            <div class="cleared"></div>
            <div class="art-footer">
                <div class="art-footer-t"></div>
                <div class="art-footer-l"></div>
                <div class="art-footer-b"></div>
                <div class="art-footer-r"></div>
                <div class="art-footer-body">

                            <div class="art-footer-text">
                            <p>CHMSC United | Copyright © 2011</p>
                                                            </div>
                    <div class="cleared"></div>
                </div>
            </div>
            <div class="cleared"></div>
        </div>
    </div>
    <div class="cleared"></div>

</div>

</body>
</html>
<script type='text/javascript'>
            jQuery(".ended").click( function() {
                var id = $(this).attr("id");

                jQuery.ajax({
                    type: "POST",
                    data: ({id: id}),
                    url: "test.php",
                    success: function(response) {
                    jQuery(".ended").fadeIn().html(response);
                    }
                });
            })
</script>

Problem is that you’re accessing your session variable on line 89 of that code without checking whether it exists or not. So you’ll need to surround that with a condition to handle the possibility that it might not. I don’t see any code in there that sets the session vars, so I assume it is done elsewhere.

Also, you need to stop using mysql calls and migrate to mysqli or PDO instead. There’s a sticky link on the board to advice on how to go about it.

kindly correct the code to work with the file and see also the image that is just uploaded.
one file here
http://tbf.me/a/DmWR2
thanks

He just told you exactly what to do…make sure session is started, then check if session has been set…in other words redirect them to a login page if the session variable does not exist