我一直有這個奇怪的錯誤,基本上會發生的是,我有這個應用程序在Android上,每當我嘗試添加一個新的「用戶」其中之一值(稱爲「CONTACTO」)有時是錯誤的,怪異的部分是,它發生在一個完全隨機的方式,這是我的.PHPPHP提交MySQL數據庫的錯誤信息
<?PHP
$con=mysqli_connect("localhost","root","","proyecto");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['txtNombre']) && isset($_POST['txtcontactousuarionuevo']) &&
isset($_POST['txtPass']) && isset($_POST['txtprograma'])){
$nombreestudiante = $_POST['txtNombre'];
$contactoestudiante = $_POST['txtcontactousuarionuevo'];
$passestudiante = $_POST['txtPass'];
$programa = $_POST['txtprograma'];
$query = "INSERT INTO estudiante(Nombre, Contacto, Id_Periodo_FK, Pass)
VALUES ('$nombreestudiante', $contactoestudiante, 4, '$passestudiante');";
$query .= "INSERT INTO estudiante_programa(EstudianteE_P_FK, ProgramaE_P_FK)
VALUES(LAST_INSERT_ID(), $programa)";
$result =mysqli_multi_query($con,$query);
if($result > 0){
if(isset($_POST['mobile']) && $_POST['mobile'] == "android"){
echo "success";
exit;
}
echo "Insert Successfully";
}
else{
if(isset($_POST['mobile']) && $_POST['mobile'] == "android"){
echo "failed";
exit;
}
echo "Something Error";
}
}
?>
<html>
<head><title>Insert | ProyectoBD</title></head>
<body>
<h1>Insert ProyectoBD| <a>Santiago Troitiño C - 201421697</a></h1>
<form action="<?PHP $_PHP_SELF ?>" method="post">
Nombre <input type="text" name="txtNombre" value=""/><br/>
Contacto <input type="text" name="txtcontactousuarionuevo" value=""/><br/>
Pass <input type="text" name="txtPass" value=""/><br/>
<input type="submit" name="btnSubmit" value="Insert"/>
</form>
</body>
我的應用程序有一個登錄屏幕和按鈕將它帶到一個註冊表格中,該頁面上執行的.php(登錄頁面)如下所示:
<?PHP
include_once("connection.php");
if(isset($_POST['txtUsername']) && isset($_POST['txtPassword'])){
$username = $_POST['txtUsername'];
$password = $_POST['txtPassword'];
$query = "SELECT * FROM estudiante WHERE Nombre = '$username'
AND Pass = '$password'";
$result = mysqli_query($conn, $query);
if($result->num_rows > 0){ //has record. correct username and password
echo "success";
while($row = $result->fetch_assoc()) {
echo " ". $row["Id_Estudiante"]. "";
exit;
}
exit;
}
else{
echo "Wrong username and password";
exit;
}
exit;
}
?>
<html>
<head><title>Login | ProyectoBD</title></head>
<body>
<h1>Login ProyectoBD | <a>Santiago Troitiño C - 201421697</a></h1>
<form action="<?PHP $_PHP_SELF ?>" method="post">
Nombre <input type="text" name="txtUsername" value="" placeholder="Ingresar Nombre" /><br/>
Password <input type="password" name="txtPassword" value="" placeholder="Ingresar Pass" /><br/>
<input type="submit" name="btnSubmit" value="Login"/>
</form>
</body>
</html>
這些都是excuted上的應用程序,這部分是唯一.PHP ... As you can see on this image the number "2147483647" keeps appearing at complete random times, I used that number for a register once but kkeps appearing
的我怎麼可能解決這個任何想法?謝謝!
數據類型爲int,不能包含非數字字符,因爲我將其限制在Android應用程序上。 –
我改變了數據類型,現在看起來效果很好,謝謝! ^^ –
優秀。不用謝 – xec86