我想在php中使用mySql執行多個查詢。但我沒有得到結果。請讓我知道我在代碼中做了什麼錯誤。我是全新的PHP和mySql。這是我下面的PHP代碼:如何在mySql中執行多個查詢
<?php
//-----------------------------------------------------------------------------------
$host='localhost';
$uname='root';
$pwd='welcome';
$db='database name';
//-----------------------------------------------------------------------------------
$con=mysql_connect($host,$uname,$pwd) or die("Connection Failed");
mysql_select_db($db,$con) or die("database selection failed");
//-----------------------------------------------------------------------------------
$mobile = mysql_real_escape_string($_POST['Mobile']); # Secure the input!
$password = mysql_real_escape_string($_POST['Password']);
$time = date("D M d, Y G:i a");
//-----------------------------------------------------------------------------------
// echo $time;
$flag['code']=0;
$select="select * from Insert1 where Mobile = '$mobile' AND Password = '$password'";
$select . ="update table Insert1 set Time='$time' where Mobile='$mobile',Password='$password',Time is null";
$r=mysql_query($select,$con); # This will always return something "true"
if(mysql_num_rows($r) > 0) { # You want to count rows instead.
$flag['code']=1;
}
print(json_encode($flag));
mysql_close($con);
?>
我真的希望那不是你的密碼 –
@RUJordan解決方案plzz ... !!! – user3660303
如何回答沒有具體問題的問題?你不能只是轉儲你的腳本,並說修復它..請閱讀如何提出一個好問題。 –