2013-05-04 263 views
-1

這是我使用更新data.I試了很多時間在頁面的完整代碼,但它仍然沒有database..also更新值試圖呼應,但仍沒有更新更新查詢不起作用

<?php 
session_start(); 
include '../func-tion/func.php'; 
if(isset($_SESSION['m_uname']) && isset($_SESSION['m_pass'])) 
{ 

?> 
<?php 
if(isset($_POST['subup'])) 
{ 
$SQL="update appid set android_appid='".$_POST['and_a']."' , iphone_appid='".$_POST['iph_a']."' , ipad_appid='".$_POST['ipa_a']."' where u_name='".$_GET['name']."'"; 
echo $SQL; 
} 
?> 



<?php 
       $main_qry=mysql_query("select * from users where u_name='".$_GET['name']."'"); 
       $main_fetch=mysql_fetch_assoc($main_qry); 

?> 
<center><h2 class="art-postheader">Edit details of <b></b></h2></center><br/><br/> 
<table align="center"> 
<tr align="center"> 
    <td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Username:<br> 
<input type="text" name="u_name" style="width: 300px;" value="<?php echo $main_fetch['u_name']?>"></td> 
</tr> 
<tr align="center"> 
    <td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Email:<br> 
    <input type="text" name="u_email" style="width: 300px;" value="<?php echo $main_fetch['u_email']?>"></td> 
</tr><?php 
       $main_qrys=mysql_query("select * from appid where u_name='".$_GET['name']."'"); 
       $row=mysql_fetch_assoc($main_qrys); 

?>  <form name="user" method="post" action="users_edit.php" onSubmit="return valid();"> 
<tr align="center"> 
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Android Appid:<br> 
    <input type="text" name="and_a" style="width: 300px;" value="<?php echo $row['android_appid']?>"></td> 

</tr> 
<tr align="center"> 
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone Appid:<br> 
    <input type="text" name="iph_a" style="width: 300px;" value="<?php echo $row['iphone_appid']?>"></td> 

</tr> 
<tr align="center"> 
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone(ipad) Appid:<br> 
    <input type="text" name="ipa_a" style="width: 300px;" value="<?php echo $row['ipad_appid']?>"></td> 

</tr> 
<tr align="center"> 
    <td style="height: 28px;"> 
    <button name="subup" type="submit">Edit</button> 
    </td> 
</tr> 
</form> 
</table> 



</div> 
       </div> 
      </div> 
     </div> 

</div> 

</body></html> 

<?php 
} 
else 
{ 
header("Location:notserver.php?l=fake"); 
} 
?> 

如果有人know..Please幫助我,我會非常心存感激他

+0

while循環是否被調用? mysql_affected_rows()返回什麼? – tobspr 2013-05-04 19:24:13

+0

需要...消毒...輸入... – 2013-05-04 19:28:57

+1

[**請不要在新代碼中使用'mysql_ *'函數**](http://bit.ly/phpmsql)。他們不再被維護[並且被正式棄用](http://j.mp/XqV7Lp)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。 – Kermit 2013-05-04 19:29:04

回答

0

使用查詢:

UPDATE appid 
set android_appid='$android_appid', iphone_appid='$iphone_appid', ipad_appid='$ipad_appid' 
where u_name IN (select u_name from users where u_id = $_GET[id]) 

我不知道爲什麼你使用$_GET['id']而非$_POST['id']像腳本中的其他參數一樣。確保這是正確的。你應該檢查mysql_query()的錯誤;如果返回false,請打印mysql_error()查看原因。

+0

是的...因爲我從鏈接獲取ID ...我試過你的查詢,但沒有成功。我已經編輯了我現在使用的問題.. – gss 2013-05-05 07:18:42

+0

您是否收到錯誤?出現錯誤時應打印'mysql_error()'。發佈'echo $ sqq'的輸出。 – Barmar 2013-05-05 14:42:11

+0

沒有沒有錯誤,但仍然沒有更新數據庫 – gss 2013-05-05 20:28:58