2017-03-23 10 views
-1

これは私の最初の投稿です、私は非常に歓迎されている人々はあなたが問題の人々を助けるためにいいですね。 は私が学校で祭りのためのウェブサイトを作っています、と私は何とか今日、このエラーを得た:)おそらくあなたのための簡単なエラー、私はPHPに新しいです

mysqli_query(見込んCに与えられた少なくとも2つのパラメータ、1:\ xamppの\ htdocsに\ projectsite \ News.phpにライン135

<?php 
session_start(); 
if (isset($_SESSION['test'])){ 

}else{ 
    $_SESSION["test"]=0; 
}?> 
<!DOCTYPE html> 
<html> 
<head> 
<link rel="icon" type="" href="http://example.com/myicon.png"> 
    <link rel="stylesheet" type="text/css" href="css.css"> 
</head> 
<title>News</title> 
</style> 
<body bgcolor="#E6E6FA"> 
<a href="http://localhost/projectsite/index.php" ><img src="images/nl.png"/></a> 
<a href="http://localhost/projectsite/homeenglish.php" ><img src="images/uk.png"/></a> 
<body background="images/achtergrondje2.jpg" style=> 
<style> 
ul { 
    list-style-type: none; 
    margin: 0; 
    padding: 0; 
    overflow: hidden; 
    border: 1px solid #ffffff; 
    background-color: #494b4a; 
} 

li { 
    float: left; 
} 

li a { 
    display: block; 
    color: #dadada; 
    text-align: center; 
    padding: 14px 16px; 
    text-decoration: none; 
} 

li a { 
    display: block; 
    <img src="images/bannertje2.jpg" 
    text-align: center; 
    padding: 14px 16px; 
    text-decoration: none; 
} 

li a:hover:not(.active) { 
    background-color: #dadada; 
} 

li a.active { 
    color: white; 
    background-color: #e83d3d; 
} 
</style> 

</head> 
</head> 
<body><font color="white" 
</body> 
<ul> 
    <li><a href="http://localhost/projectsite/index.php">Home</a></li> 
    <li><a href="http://localhost/projectsite/lineup.php">Line-up</a></li> 
    <li><a href="http://localhost/projectsite/inschrijven.php">Inschrijven</a></li> 
    <li><a class="active" href="http://localhost/projectsite/news.php">Nieuws</a></li> 
    <li style="float:right"><a class="active" href="http://localhost/projectsite/contact.php">Over ons</a></li> 
    <li style="float:right"><a class="active" href="http://localhost/projectsite/logout.php">Logout</a></li> 
    <li style="float:right"><a class="active" href="http://localhost/projectsite/Loginmain.php">Login</a></li> 

    <br> 
</ul> 
    <?php if ($_SESSION["test"] == 1) 
    { 
?><li style="float:right" ><a class="active" href="html.php">uitloggen</a></li><?php 
?><li style="float:right" ><a href=''><?php echo "Welkom Back ". $_SESSION["username"] . "(͡° ͜ʖ ͡°)"?></a></li><?php 
    }else{ 
    } 
    ?> 
</ul> 
<div class="flex-container"> 
<form method="POST"> 
    <table> 
    <tr><td><h2>Nieuwsitem Toevoegen</h2></td></tr> 
     <tr> 
      <th>Title:</th> 
      <td><input type="text" name="txtTitle" /></td> 
     </tr> 
     <tr> 
      <th>Plaats:</th> 
      <td><input type="text" name="txtPlaats" /></td> 
     </tr> 
     <tr> 
      <th>Description:</th> 
      <td><input type="text" name="txtDescription" /></td> 
     </tr> 
     <tr> 
      <th></th> 
      <td><input type="submit" name="btnnews" value="Invoeren" /></td> 
     </tr> 
     <tr> 
      <th></th> 
      <td><input type="submit" name="btnnwesplaatsen1" value="plaatsen" /></td> 
     </tr> 
    </table> 
</form> 


<?php 
    require('connect.php'); 
    // If the values are posted, insert them into the database. 
    if (isset($_POST['btnnews'])) 
    { 
     $title = $_POST['txtTitle']; 
    $Description = $_POST['txtDescription']; 
     $plaatsID = $_POST['txtPlaats']; 

     $query = "INSERT INTO `nieuwsitems` (txtPlaats, txtTitle, txtDescription) VALUES ($plaatsID, '$title', '$Description')"; 
     $result = mysqli_query($connection); 
     if($result) 
     { 
      $smsg = "Succes"; 
     }else{ 
      $fmsg =""; 
     } 
    } 
include("connect.php"); 
if(isset($_POST['btnnwesplaatsen1'])) 
{ 
$query = "SELECT * FROM nieuwsitems WHERE PlaatsID= 1"; 
$result = mysqli_query($db, $query); 

$row = mysqli_fetch_array($result); 

$titel = $row['Title']; 
$item = $row['Description']; 

echo "$titel".'<br>'; 
echo "$item".'<br><hr>'; 
} 
?> 
</body> 

</html> 

ここでは...あなたのコード内で

をその行を置き換える
+0

こんにちは、これを最初のパラメータとして$ db:$ dbに追加してください。 –

答えて

4

<?php 
$connection = mysqli_connect('localhost', 'root', ''); 
if (!$connection){ 
die("Database Connection Failed" . mysqli_error($connection)); 
} 
$select_db = mysqli_select_db($connection, 'projectfestival'); 
if (!$select_db){ 
die("Database Selection Failed" . mysqli_error($connection)); 
} 

connect.phpです
+0

アンサーは正しいですか? –

関連する問題