<?php
   include('sessioncheck.php');
   if (!$_SESSION['username']) {
    header("Location:loginrequest.php");
   }
?>
<!DOCTYPE HTML>
<html>
 <head>
  <meta charset="utf-8" />
   <title>History</title>
    <link type="text/css" rel="stylesheet" href="css/style.css" />
    <meta charset="utf-8" />
    <meta http-equiv = "X-UA-Compatible" content = "IE=edge"
  </head>
 <body>
 <div class="mainHome">
  <div class="header">
   <div class="logo"><img src="images/logo.png" alt="Kate's Travel Log System"/></div>
   <div class="heading">Kate's Travel Log System</div>
    <button id="logout"><?php echo "Welcome"." ".$login_session;?><a href="logout.php">Logout</a></button>
   
  </div>
  <div class="banner"><img src="images/banner.jpg" alt="Webpage banner"/></div>
  
  
 <div class ="menubar">
  
  
    <ul>
     <li><a href="home.php">Home</a></li>
     <li><a href="history.php">Travel History</a></li>
     <li><a href="#news">Gallery</a></li>
     <li><a href="#contact">Contact Kate</a></li>
     <li><a href="#about">About Us</a></li>
     
    </ul>
 
   
  
 </div>
<div class="mainhistory"><h2></h2>
<div class="wrapper">
<div class="main_contents" >
<div id="edit">
<?php 
if(isset($_GET['edit']))
{
 echo "Successfully Edited!!";
 }
?>
</div>
<div id="delete" >
<?php 
if(isset($_GET['delete']))
{
 echo "Sucessfully deleted!!";
 }
?>
</div>
<p> <h3  align="center"> Visited Areas </h3></p>
<?php
$uid = $_GET['uid'];
$query = "select * from travelinfo where ID='$uid'";
$res = mysql_query($query);
while($data = mysql_fetch_array($res))
{
 ?>
<div class="row-recipe">
<div id="contents" >
 <p><h4> Visited City: <?php echo $data['city']; ?> </h4></p>
 <p>Region<?php echo $data['Region']; ?></p>
 <p>Country<?php echo $data['Country']; ?></p>
 
 <p>Date of Visit:<?php echo  $data['Date_Of_Visit']; ?></p>
  <p> <a href="edit.php?id=<?php echo $data['id']; ?>"> Edit </a> | 
  <a href="delete.php?id=<?php echo $data['id']; ?>" onClick="return confirm('Are you sure to delete???')">Delete </a></p>
</div>
</div>
<hr color="#fff0ab" />
<?php } ?>
</div>
</div>
</div>
<div class="mainBod"><h2></h2>
</div>
<div class="mainBod"><h2></h2>
</div>
<div class="mainBodyd">
<div class="mainBodyd1">
You can follow us on: <br/>
<a href="http://www.facebook.com" target="_blank" ><img src="images/facebook.png" alt="Follow us on facebook"/></a>
<a href="http://www.twitter.com" target="_blank" ><img src="images/twitter.png" alt="Follow us on twitter"/></a>
<a href="http://www.youtube.com" target="_blank" ><img src="images/youtube.png" alt="Subscribe us on youtube"/></a>
</div>
<div class="mainBodyd2">
</div>
</div>
<div class="footer">© 2016 Suraj Neupane</div>
</div>
</body>
</html>
//These are the warnings:
  // Notice: Undefined index: uid in C:\xampp\htdocs\kate\history.php on line 78
  //Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\kate\history.php on line 83*/
            Asked
            
        
        
            Active
            
        
            Viewed 32 times
        
    -1
            
            
        
        Su Raj
        
- 1
 - 3
 
- 
                    http://stackoverflow.com/questions/2973202/mysql-fetch-array-mysql-fetch-assoc-mysql-fetch-row-expects-parameter-1-to Follow this – SkyWalker Mar 15 '16 at 09:29
 - 
                    Please make sure that you are passing `uid` in url like `?uid=1` as your query using this value to get records from database; – itzmukeshy7 Mar 15 '16 at 09:49
 - 
                    thanks for your help – Su Raj Mar 15 '16 at 09:53
 
1 Answers
0
            
            
        Update your code like this.
- You need to check whether 
GETvariable is defined or not before using this for further execution - You should check the result 
$resbefore fetching Array to prevent 2nd Error you got 
<?php
   include('sessioncheck.php');
   if (!$_SESSION['username']) {
    header("Location:loginrequest.php");
   }
?>
<!DOCTYPE HTML>
<html>
 <head>
  <meta charset="utf-8" />
   <title>History</title>
    <link type="text/css" rel="stylesheet" href="css/style.css" />
    <meta charset="utf-8" />
    <meta http-equiv = "X-UA-Compatible" content = "IE=edge"
  </head>
 <body>
 <div class="mainHome">
  <div class="header">
   <div class="logo"><img src="images/logo.png" alt="Kate's Travel Log System"/></div>
   <div class="heading">Kate's Travel Log System</div>
    <button id="logout"><?php echo "Welcome"." ".$login_session;?><a href="logout.php">Logout</a></button>
   
  </div>
  <div class="banner"><img src="images/banner.jpg" alt="Webpage banner"/></div>
  
  
 <div class ="menubar">
  
  
    <ul>
     <li><a href="home.php">Home</a></li>
     <li><a href="history.php">Travel History</a></li>
     <li><a href="#news">Gallery</a></li>
     <li><a href="#contact">Contact Kate</a></li>
     <li><a href="#about">About Us</a></li>
     
    </ul>
 
   
  
 </div>
<div class="mainhistory"><h2></h2>
<div class="wrapper">
<div class="main_contents" >
<div id="edit">
<?php 
if(isset($_GET['edit']))
{
 echo "Successfully Edited!!";
 }
?>
</div>
<div id="delete" >
<?php 
if(isset($_GET['delete']))
{
 echo "Sucessfully deleted!!";
 }
?>
</div>
<p> <h3  align="center"> Visited Areas </h3></p>
<?php
if(isset($_GET['uid'])){
  $uid = $_GET['uid'];
  $query = "select * from travelinfo where ID='$uid'";
  $res = mysql_query($query);
  if($res){
  while($data = mysql_fetch_array($res))
  {
   ?>
  <div class="row-recipe">
  <div id="contents" >
   <p><h4> Visited City: <?php echo $data['city']; ?> </h4></p>
   <p>Region<?php echo $data['Region']; ?></p>
   <p>Country<?php echo $data['Country']; ?></p>
 
   <p>Date of Visit:<?php echo  $data['Date_Of_Visit']; ?></p>
    <p> <a href="edit.php?id=<?php echo $data['id']; ?>"> Edit </a> | 
    <a href="delete.php?id=<?php echo $data['id']; ?>" onClick="return confirm('Are you sure to delete???')">Delete </a></p>
  </div>
  </div>
  <hr color="#fff0ab" />
<?php 
    }
  }
}
?>
</div>
</div>
</div>
<div class="mainBod"><h2></h2>
</div>
<div class="mainBod"><h2></h2>
</div>
<div class="mainBodyd">
<div class="mainBodyd1">
You can follow us on: <br/>
<a href="http://www.facebook.com" target="_blank" ><img src="images/facebook.png" alt="Follow us on facebook"/></a>
<a href="http://www.twitter.com" target="_blank" ><img src="images/twitter.png" alt="Follow us on twitter"/></a>
<a href="http://www.youtube.com" target="_blank" ><img src="images/youtube.png" alt="Subscribe us on youtube"/></a>
</div>
<div class="mainBodyd2">
</div>
</div>
<div class="footer">© 2016 Suraj Neupane</div>
</div>
</body>
</html>
        Jyothi Babu Araja
        
- 10,076
 - 3
 - 31
 - 38