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">
<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" />
<div id="wrapper">
  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    <div id="menu">
        <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>
      <p> <center><img src="../../Documents/Unnamed Site 2/IMG_1913.jpg" width="999" height="388"  alt=""/></center>  </p>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome to Yakity yak club</a></h2>
            <div class="entry">
                <table border='1'>


/* 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.*/

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

echo "<table border='1'>

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>";


3 Years
Discussion Span
Last Post by Assembly Guy

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.

Edited by Assembly Guy

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.