mercredi 25 avril 2018

php error SQLSTATE[HY000] [1044]

I am receiving this error message

Connection failed again: SQLSTATE[HY000] [1044] Access denied for user 'b6022389'@'%.shu.ac.uk' to database '_db3'
Notice: Undefined variable: pdo in /studenthome.hallam.shu.ac.uk/STUDENTHOME5/9/b6022389/public_html/webassignment/webpage/cms/cms.php on line 6


  Fatal error: Uncaught Error: Call to a member function prepare() on null in /studenthome.hallam.shu.ac.uk/STUDENTHOME5/9/b6022389/public_html/webassignment/webpage/cms/cms.php:6 Stack trace: #0 {main} thrown in /studenthome.hallam.shu.ac.uk/STUDENTHOME5/9/b6022389/public_html/webassignment/webpage/cms/cms.php on line 6

The code for this page is as follows:

<?php
ini_set('display_errors', 1);
// add your include
require('../includes/conn.inc.php');
$sql= "SELECT * FROM Matches ORDER BY homeTeam ASC";
$stmt = $pdo->prepare($sql);
$stmt->execute();
?>
<!DOCTYPE html>
<html lang="en">
<head>
          <meta charset="utf-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>Content Management System</title>
          <link href="../css/bootstrap.min.css" rel="stylesheet">
          <link href="../css/styles.css" rel="stylesheet">
</head>
<body>
<div class="container">
          <nav class="navbar navbar-default">
              <div class="container-fluid">
                <ul class="nav navbar-nav">
                  <li><a href="cms.php">CMS Home</a></li>
                </ul>
                <p class="nav navbar-nav navbar-right">
                        <a class="btn btn-danger navbar-btn" href="../index.php" role="button">Log Out</a>
                </p>
              </div>
        </nav>
      <div class="page-header">
        <h1>Content Management System</h1>
      </div>

    <div class="row">
            <div class="col-md-12">
            <p><a href="insert.php" class="btn btn-success">Add New Film</a></p>
              <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Film</th>
                            <th>Edit</th>
                            <th>Delete</th>
                            <th>View</th>
                        </tr>
                    </thead>
                    <?php 
                    while($row = $stmt->fetchObject()){
                        // amend with links to the relevant pages
                                echo "<tr>";
                                echo "<td>{$row->filmName}</td>";   
                echo "<td><a href=\"edit.php?matchID= {$row->matchID}\">Edit</a></td>";
                                echo "<td><a href=\"delete.php?matchID= {$row->matchID}\">Delete</a></td>";
                                echo "<td><a href=\"../details.php?matchID= {$row->matchID}\">View</a></td>";
                                echo "</tr>";
                    }
                    ?>
            </table>
            </div>
    </div>
</div>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire