0
我更新了名爲「Mohit sharma」的數據庫,但它將輸出數據庫輸入爲first_name
:0和'last_name`:阿羅拉這裏是一個事先知情同意http://postimg.org/image/jp2fy1yy7/進入我的數據庫`first_name`顯示爲0,並且last_name在更新名稱後顯示爲「Arora」
請幫助
這裏是形式我的源代碼:
<div id="left_box"><br>
<img src="Images/general_setting.png" height="18" width="18"><a href="general_settings.php" style="text-decoration: none; color: #000000; font-family: Arial";> General</a><br><br>
<img src="Images/photo_setting.png" height="18" width="18"><a href="photo_settings.php" style="text-decoration: none; color: #000000; font-family: Arial";> Photos</a><br><br>
</div>
<div class="box">
<h1 style="font-family: consolas">Change your name</h1><hr>
<div id="change_name">
<label><strong>Your current name: </strong></label>
<?php
include('change_setting_db.php');
while($row = mysqli_fetch_array($result))
{
echo "(".$row['id'].") ".$row['first_name']." ".$row['last_name'];
}
?>
<br>
<br>
<form method="post" action="do_update_name.php">
<input type="hidden" name="id" value="<?php echo $row['id'];?>">
<label><strong>First name: </strong></label>
<input type="text" name="first_name" value="<?php echo $row['first_name'];?>">
<label><strong>Last name: </strong></label>
<input type="text" name="last_name" value="<?php echo $row['last_name'];?>">
<input type="submit" value="Submit">
</form>
</div>
</div>
,這裏是爲do_update_name.php
我的源代碼..
<?php
$firstname=$_POST['first_name'];
$lastname=$_POST['last_name'];
$id=$_POST['id'];
$con=mysqli_connect("localhost","root","Bhawanku", "members");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$update =mysqli_query($con,"UPDATE admin SET first_name='$firstname' AND last_name='$lastname' WHERE id='$id' ");
if($update){
echo "Successfully created!!";
}
?>
[**請不要在新代碼中使用'mysql_ *'函數**](http://bit.ly/phpmsql)。他們不再被維護[並被正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**粉紅色框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://j.mp/PoWehJ)。 – h2ooooooo