Notice: Undefined variable: result in C:\Users\User\Desktop\Desktop\htdocs\trip1.php on line 67

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\Users\User\Desktop\Desktop\htdocs\trip1.php on line 67

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--


-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Yakity Yak</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    </div>
    <div id="menu">
      <ul>
        <li class="current_page_item"><a href="file:///D:/blackpolish/homepage.php">Homepage</a></li>
        <li><a href="file:///D:/blackpolish/trip.php">Destinations</a></li>
        <li><a href="#">contact </a></li>
        <li><a href="#">Login</a></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
  <blockquote>
    <blockquote>
      <p> <center><img src="../../Documents/Unnamed Site 2/IMG_1913.jpg" width="999" height="388"  alt=""/></center>  </p>
    </blockquote>
  </blockquote>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome to Yakity yak club</a></h2>
            <div class="entry">
                <table border='1'>

    </div>
  <?php

/* This code establishes a connection with the database on the server. 
The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. 
It accepts two parameters, one is the name of the database and the other is the connection variable.*/

   $connect=mysql_connect("localhost","root","");
    $db_selected = mysql_select_db("assesment", $connect);
    $query = "SELECT 'ID' FROM taranaki WHERE ID='45'";





echo "<table border='1'>
<tr>
    <th>ID</th>
    <th>Destination</th>
    <th>Difficulty</th>
    </tr>";

while($row = mysqli_fetch_array($result))
{   
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['Destination'] . "</td>";
echo "<td>" . $row['Difficulty'] . "</td>";
echo "</tr>";  
  }
 echo "</table>";


?>

</body>
</html>

You're missing a line of code:

$result = mysql_query($query);

And your query needs a fix:

$query = "SELECT `ID` FROM taranaki WHERE ID='45'";

You need to use backticks around ID instead of single quotes.

$db_selected = mysql_select_db("assesment", $connect);

I should've spotted it sooner, before I posted my solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.