使用if语句不能正常工作 [英] USING if statement do not work as it should
问题描述
我的代码中使用了 if
,但代码的逻辑不起作用,因为我想要的是当用户输入城市名称时输入区域名称系统必须显示错误消息
I have an if
statment used in my code but the logic of the code do not work as it should what I want is that when the user enter the city name without entering the district name the system must display an error message
当用户输入城市名称和区域名称而不输入lat和long时系统必须显示错误消息。
and when the user enter the city name and the district name without entering the lat and long the system must display an error message .
我的代码中包含的内容是,即使用户进入城市并拉长,系统也会显示错误消息,通知用户输入lat和长
what it hapen in my code is that even if the user enter the city and lat an long the system display an error message inform the user to enter the lat and long
if($_POST['city'])
{
$city = $_POST['city'];
$lat = $_POST['lat'];
$long = $_POST['long'];
if($_POST['dist'] =="")
{
$errorMSG = "you can not add city without having relation with district";
}
if($lat || $long ==""){ $errorMSG = "You can not add village Without its coordination";}
else
{
$sql = mysql_query("INSERT INTO village (id, village_name, district_id, lattitude, longitude)VALUES('', '$city', , '$lat', '$long')")or die(mysql_error());
echo $city;
}
}
推荐答案
if($ lat || $ long ==)
应该是 if($ lat ==|| $ long ==)
这篇关于使用if语句不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!