我有这个简单的 php 代码。在本地,使用简单的 xampp 1.7.3 echo 返回正确"false" or "true"
。当我将代码放在网上时(我的意思是在服务器上,我并不真正了解服务器是如何制作的)它总是返回“1”。为什么?
<?php
include "connectionToDb.php";
$nome_utente=$_GET['nome_utente'];
$queryUserAvailable = "SELECT * FROM utente where nome_utente='$nome_utente'";
$rsUserAvailable = connetti($queryUserAvailable);
if(mysql_num_rows($rsUserAvailable) == 0){
$valid=true;
}
else{
$valid=false;
}
echo json_encode($valid);
?>
ConnectionToDb.php
<?php
function connetti($SQL){
$conn = mysql_connect("localhost", "root", ""); //(online this data are obviously different)
$db = mysql_select_db("dbName",$conn);
$risultato = mysql_query($SQL,$conn)
or die("Query non valida: " . mysql_error());
return ($risultato);
}
?>