السلام عليكم ورحمةالله وبركاته ادرس في تطوير الويب للزيرو كورس متجر الكتروني الحلقة 22 ولاحظت خطا غريب جدا حدث في الصفحة بتاعت الMEMBER لا ادري ما المشكلة مع ان جميع الاكواد صحيحة هل ممكن مساعدة<?php
الخطا الذي حدث
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE UserID ='2' LIMIT 1' at line 1 in C:\xampp\htdocs\ecommerce\admin\members.php:111 Stack trace: #0 C:\xampp\htdocs\ecommerce\admin\members.php(111): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\ecommerce\admin\members.php on line 111
الكود الموجود في الصفحة الMEMBERS
session_start();
if(isset($_SESSION['Username'])){
$pageTitle = 'members';
include 'init.php';
if(isset($_GET['do'])){
$do = $_GET['do'];
}
else{
$do = 'manage';
}
//manage page
if($do == 'Manage'){
}elseif ($do == 'Edit') {
// Check If Get Request userid Is Numeric & Get Its Integer Value
$userid = isset($_GET['userid']) && is_numeric($_GET['userid']) ? intval($_GET['userid']) : 0;
// Select All Data Depend On This ID
$stmt = $con->prepare("SELECT * FROM users WHERE UserID = ? LIMIT 1");
// Execute Query
$stmt->execute(array($userid));
// Fetch The Data
$row = $stmt->fetch();
// The Row Count
$count = $stmt->rowCount();
// If There's Such ID Show The Form
if ($count > 0) { ?>
<h1 class="text-center">Edit Member</h1>
<div class="container">
<form class="form-horizontal" action="?do=update" method="POST">
<input type="hidden" name="userid" value="<?php echo $userid ?>" />
<!-- Start Username Field -->
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label">Username</label>
<div class="col-sm-10 col-md-6">
<input type="text" name="username" class="form-control" value="<?php echo $row['Username'] ?>" autocomplete="off" required="required" />
</div>
</div>
<!-- End Username Field -->
<!-- Start Password Field -->
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label">Password</label>
<div class="col-sm-10 col-md-6">
<input type="hidden" name="oldpassword" value="<?php echo $row['Password'] ?>" />
<input type="password" name="newpassword" class="form-control" autocomplete="new-password" placeholder="Leave Blank If You Dont Want To Change" />
</div>
</div>
<!-- End Password Field -->
<!-- Start Email Field -->
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label">Email</label>
<div class="col-sm-10 col-md-6">
<input type="email" name="email" value="<?php echo $row['Email'] ?>" class="form-control" required="required" />
</div>
</div>
<!-- End Email Field -->
<!-- Start Full Name Field -->
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label">Full Name</label>
<div class="col-sm-10 col-md-6">
<input type="text" name="full" value="<?php echo $row['FullName'] ?>" class="form-control" required="required" />
</div>
</div>
<!-- End Full Name Field -->
<!-- Start Submit Field -->
<div class="form-group form-group-lg">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" value="Save" class="btn btn-primary btn-lg" />
</div>
</div>
<!-- End Submit Field -->
</form>
</div>
<?php
// If There's No Such ID Show Error Message
}
else{
echo'there is no such id';
}
}elseif($do == 'update'){
echo "<h1 class='text-center'>update Member</h1>";
if($_SERVER['REQUEST_METHOD']=='POST'){
$id = $_POST['userid'];
$user = $_POST['username'];
$email = $_POST['email'];
$name = $_POST['full'];
$stmt =$con->prepare("UPDATE users SET Username = ?, Email = ?, FullName =?, WHERE UserID =? ");
$stmt->execute(array($user,$email,$name,$id));
$Count = $stmt->rowCount();
echo $Count.'Record Updated';
}
else{
echo 'you can not enter this page directly';
}
}
?>
<?php
include $tpl. 'footer.php';
}else{
header('Location:index.php');
}
?>
مرفق صورة لمكان الخطا ولم اعرفه ما هو بالضبط
التعليقات