2017-06-26 2 views
-3

Ich bin neu in PHP und Sql. Ich versuche gerade, einen Blog zu bauen, und ich bekomme Fehlermeldung, wenn ich versuche, durch localhost zu laufen. Ich benutze PHP Version 7 und SQL Version 5.7. Ich bekomme Fehler auf der Linie 26, die diese istParse-Fehler: Syntaxfehler, unerwartete "Werte" (T_STRING) in C: wamp2017 www PHPCMS categories.php

bitte helfen Sie mir aus. vielen Dank

<?php require_once("Include/db.php"); ?> 
<?php require_once("Include/sessions.php"); ?> 
<?php require_once("Include/functions.php"); ?> 

<?php 
if(isset($_POST["Submit"])){ 
    $Category=mysqli_real_escape_string($_POST["Category"]); 
date_default_timezone_set("Europe/London"); 
$CurrentTime=time(); 
//$DateTime=strftime("%Y-%m-%d %H:%M:%S",$CurrentTime); 
$DateTime=strftime("%B-%d-%Y %H:%M:%S",$CurrentTime); 
$DateTime; 
$Admin="Admin"; 
if(empty($Category)){ 
    $_SESSION["ErrorMessage"]="All Fields must be filled out"; 
    Redirect_to("categories.php"); 

}elseif(strlen($Category)>99){ 
    $_SESSION["ErrorMessage"]="Too long Name for category"; 
    Redirect_to("categories.php"); 

}else{ 

     global $linkDB; 
     $Query="INSERT INTO category(datetime,name,creatorname)" 
     VALUES('$DateTime','$Category','$Admin'); 
     $Execute=mysqli_query($Query); 
     if($Execute){ 
      $_SESSION["SuccessMessage"]="Category Added Successfully"; 
      Redirect_to("categories.php"); 
} 
else{ 
      $_SESSION["ErrorMessage"]="Catrgory failed to Add"; 
      Redirect_to("categories.php"); 
} 
} 

} 

?> 
<!DOCTYPE> 

<html> 
    <head> 
    <title>Manage Categories</title> 
     <link rel="stylesheet" href="css/bootstrap.min.css"> 
     <script src="js/jquery-3.2.1.min.js"></script> 
     <script src="bootstrap.min.js"></script> 
     <link rel="stylesheet" href="css/adminstyles.css"> 
    </head> 

    <body> 
     <div class="container-fluid"> 
     <div class="row"> 

       <div class="col-sm-2"> 
       <h1>My First Blog</h1> 

       <ul id="side_Menu" class="nav nav-pills nav-stacked"> 

       <li><a href="admin_dashboard.php"> 

       <span class="glyphicon glyphicon-home"></span>&nbsp; Dashboard</a></li> 

       <li><a href="#"><span class="glyphicon glyphicon-list-alt"></span>&nbsp; Add New Post</a></li> 

       <li class="active"><a href="categories.php"><span class=" glyphicon glyphicon-tag "></span>&nbsp; Categories</a></li> 

       <li><a href="#"><span class="glyphicon glyphicon-user"></span>&nbsp; Manage Admins</a></li> 

       <li><a href="#"><span class="glyphicon glyphicon-comment"></span>&nbsp; Comments</a></li> 

       <li><a href="#"><span class="glyphicon glyphicon-equalizer"></span>&nbsp; Live Blog</a></li> 

       <li><a href="#"><span class="glyphicon glyphicon glyphicon-log-out"></span>&nbsp; Logout</a></li> 

     </ul> 


     </div> <!--Ending of Side area--> 
     <div class="col-sm-10"> 
     <h1>Manage Categories</h1> 
     <div><?php echo Message(); 
       echo SuccessMessage(); 
       ?> 
     <div> 
     <form action="categories.php" method="post"> 
     <fieldset> 
        <div class="form-group"> 
     <label for="categoryname">Name:</label> 
     <input class="form-control" type="text" name="Category" id="catrgoryname" placeholder="Name"> 
     </div> 
     <input class="btn btn-success btn-block" type="Submit" name="Submit" value="Add New Category"> 
     </fieldset> 
     <be> 
</form> 


       </div> <!--ending of main area--> 


     </div> <!--ending of row--> 

     <!--end of container --> 

     <div id="Footer"> 
     <hr><p>Blog by A R Khalid ¦ &copy;Media Shark</p> 
     <a style="color: white; text-decoration: none; pointer; font-weight:bold;"> 

     <div style="height: 10px; background:#27AAE1;"></div> 

    </body> 



</html> 

Antwort

-1

Die Linie für die Suche nach für Einsatz:

$Query="INSERT INTO category(datetime,name,creatorname)" 
     VALUES('$DateTime','$Category','$Admin'); 

sollte sein:

$Query="INSERT INTO category(datetime,name,creatorname) 
     VALUES('$DateTime','$Category','$Admin')"; 

oder:

$Query="INSERT INTO category(datetime,name,creatorname)". 
     "VALUES('$DateTime','$Category','$Admin')"; 
+0

Syntaxfehler, wie Sie vergessen haben, ein abschließendes doppelten Anführungszeichen "" –

Verwandte Themen