ทำไมแก้ไขข้อมูลเป็นตัวอักษรไม่ได้ แต่ถ้าเป็นตัวเลขแก้ไขได้ปกติ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

Pursuitz Kung
PHP Newbie
PHP Newbie
Posts: 1
Joined: 27/02/2017 10:05 pm

ทำไมแก้ไขข้อมูลเป็นตัวอักษรไม่ได้ แต่ถ้าเป็นตัวเลขแก้ไขได้ปกติ

Post by Pursuitz Kung » 27/02/2017 10:09 pm

edit

Code: Select all

<?php
session_start();
$uname = $_SESSION["uname"];
$pword = $_SESSION["pword"];
if(isset($uname) and  isset($pword)) {
	
$proid = $_REQUEST["proid"];
?>
<!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">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Edit Member==>Login : <?php echo $_SESSION["fullname"]; ?></title>

    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="dist/css/sb-admin-2.css" rel="stylesheet">
	
	<!-- DataTables Responsive CSS -->
    <link href="vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="vendor/morrisjs/morris.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <?php
	include "header.php";
	?>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Edit Member</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
          	<!-- .row -->
			<?php 
					include "../inc/config.php";
	$sql = "SELECT * FROM member WHERE member_id='$proid'";
	$qpro = mysql_query($sql);
	$rpro = mysql_fetch_array($qpro);
	$member_uname = $rpro["member_uname"];
	$member_pword = $rpro["member_pword"];
	$member_fullname = $rpro["member_fullname"];
	$member_address = $rpro["member_address"];
	$member_email = $rpro["member_email"];
  $member_tel = $rpro["member_tel"];
	
					?>
            <div class="row">
               <form class="form-horizontal" action="updatemember.php" method="POST" enctype="multipart/form-data">
								 
								 
								 <div class="form-group">
									 <label class="control-label col-sm-2" for="proid">รหัสสมาชิก</label>
									 <div class="col-sm-6">
										 
									 <input type="text" class="form-control" name="proid" id="proid" value="<?php echo $proid; ?>" readonly >
								 </div>
								</div>
									<div class="form-group">
										<label class="control-label col-sm-2" for="member_uname">ชื่อผู้ใช้</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" name="member_uname" id="member_uname" value="<?php echo $member_uname; ?>" readonly >
										</div>
								 </div>
								 <div class="form-group">
									 <label class="control-label col-sm-2" for="member_pword">รหัสผ่าน</label>
									 <div class="col-sm-6">
										 <input type="text" class="form-control" name="member_pword" id="member_pword" value="<?php echo $member_pword; ?>" >
									 </div>
								 </div>
								 <div class="form-group">
									 <label class="control-label col-sm-2" for="member_fullname">ชื่อ-นามสกุล</label>
									 <div class="col-sm-6">
										 <input type="text" class="form-control" name="member_fullname" id="member_fullname" value="<?php echo $member_fullname; ?>">
									 </div>
								 </div>
								 <div class="form-group">
									 <label class="control-label col-sm-2" for="member_address">ที่อยู่</label>
									 <div class="col-sm-6">
										 <input type="text" class="form-control" name="member_address" id="member_address" value="<?php echo $member_address; ?>">
									 </div>
								 </div>
                 <div class="form-group">
									 <label class="control-label col-sm-2" for="member_email">อีเมล์</label>
									 <div class="col-sm-6">
										 <input type="text" class="form-control" name="member_email" id="member_email" value="<?php echo $member_email; ?>">
									 </div>
								 </div>
                 <div class="form-group">
									 <label class="control-label col-sm-2" for="member_tel">เบอร์โทร</label>
									 <div class="col-sm-6">
										 <input type="text" class="form-control" name="member_tel" id="member_tel" value="<?php echo $member_tel; ?>">
									 </div>
								 </div>
								 <div class="form-group col-sm-4">
									 <button type="submit" class="btn">
										 Save
									 </button>
								 </div>
							</form>
            </div>
            <!-- /.row -->
			<!-- / div class row-->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    <script src="vendor/datatables/js/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="vendor/datatables-responsive/dataTables.responsive.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>
	
	<!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
    </script>

</body>

</html>
<?php
} else {
	header("Location: index.php");
}
?>
update

Code: Select all

<?php
session_start();
if(isset($_SESSION["uname"]) and isset($_SESSION["pword"])) {
  include "../inc/config.php";
  $proid = $_POST["proid"];
  $member_uname = $_POST["member_uname"];
  $member_pword = $_POST["member_pword"];
  $member_fullname = $_POST["member_fullname"];
  $member_address = $_POST["member_address"];
  $member_email = $_POST["member_email"];
  $member_tel = $_POST["member_tel"];
  $sql = "UPDATE member SET member_uname='$member_uname',member_pword='$member_pword',member_fullname='$member_fullname',member_address=$member_address,member_email='$member_email',member_tel='$member_tel' WHERE member_id='$proid'";
  $q = mysql_query($sql);
  if(isset($q)) {
  
    header("Location: listmember.php");
  } else {
    echo "ไม่สามารถปรับเปลี่ยนข้อมูลได้";
  }
} else {
  header("Location: index.php");
}
?>

bom_002
PHP Super Member
PHP Super Member
Posts: 443
Joined: 06/03/2017 10:51 am

Re: ทำไมแก้ไขข้อมูลเป็นตัวอักษรไม่ได้ แต่ถ้าเป็นตัวเลขแก้ไขได้ปกติ

Post by bom_002 » 06/03/2017 5:39 pm

ลืมใส่ ' ' ในโค้ด update --> member_address=$member_address หรือป่าวครับ
ไม่ก็ ชนิดของฐานข้อมูล เป็น int เปลี่ยนเป็น vachar น่าจะใช้ได้นะ
:plusone:

Post Reply

Return to “Programming - PHP”

Users browsing this forum: No registered users and 12 guests