2017-03-23 3 views
-1

Dies ist mein erster Beitrag hier, ich fühle mich sehr willkommen, wie die Leute mir sagten, Sie Jungs sind nett, Menschen mit Problemen zu helfen. Ich mache eine Website für ein Festival in der Schule, und ich irgendwie diesen Fehler heute habe:Wahrscheinlich ein einfacher Fehler für Sie, ich bin neu in PHP

mysqli_query() erwartet mindestens zwei Parameter, 1 in C angegeben: \ xampp \ htdocs \ Projektseite \ news.php auf Linie 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> 

Hier ist connect.php

<?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)); 
} 
+0

Hallo, füge das in Zeile 135 hinzu: $ db als erster Parameter. –

Antwort

4

in Ihrem Code ersetzen, die Linie ..

$result = mysqli_query($connection,$query); 
+0

Anser ist korrekt, dann machen Sie es richtig klicken Sie auf die richtige Markierung –

Verwandte Themen