Page 1 of 1
Interesting problem
Posted: Fri Dec 02, 2005 7:20 pm
by InnerShadow
As far as i know, the copy paste function doesn't miss things, however this script that used to work doesn't know, and it does't return any errors, so i know it's not the IF/ELSE statements, it's the mysql update, but im not sure what to change since it isn't giving me any errors.
EDIT: nvm, in looking at my submission, the answer hit me. Sry to waste time.
Posted: Fri Dec 02, 2005 8:15 pm
by josh
I know you already solved your problem, but what was the point of posting this without posting example code or anything that could hint us what your problem is?
Posted: Fri Dec 02, 2005 8:37 pm
by InnerShadow
i did, but it was really long, so i took it out when i solved it
Posted: Fri Dec 02, 2005 8:38 pm
by InnerShadow
here it is if you want it:
Code: Select all
<?php
$LResource = $_POST['LResource'];
if($ID == "United States" or "Great Britain" or "France" or "Spain"){
$Check = "yes";
} else if($ID == "Nicaragua"){
if($LResource == "Timber" or "Fruit" or "Vegetables" or "Sugar" or "Tobacco" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Hawaii"){
if($LResource == "Timber" or "Fruit" or "Vegetables" or "Sugar"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Panama"){
if($LResource == "Iron" or "Timber" or "Fruit" or "Vegetables" or "Sugar" or "Tobacco" or "Silver" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Jamaica"){
if($LResource == "Fruit" or "Vegetables" or "Cotton" or "Sugar" or "Tobacco" or "Silver"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "India"){
if($LResource == "Coal" or "Iron" or "Timber" or "Vegetables" or "Cotton" or "Silver"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Sudan"){
if($LResource == "Coal" or "Cotton" or "Sugar" or "Tobacco" or "Silver" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Libya"){
if($LResource == "Iron" or "Cotton" or "Sugar" or "Tobacco" or "Silver" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Algeria"){
if($LResource == "Cotton" or "Sugar" or "Tobacco" or "Silver" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Vietnam"){
if($LResource == "Timber" or "Fruit" or "Cotton" or "Sugar" or "Tobacco"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Costa Rica"){
if($LResource == "Fruit" or "Vegetables" or "Sugar" or "Tobacco" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Philippines"){
if($LResource == "Coal" or "Iron" or "Timber" or "Fruit" or "Vegetables" or "Sugar" or "Tobacco" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "China"){
if($LResource == "Coal" or "Iron" or "Timber" or "Fruit" or "Vegetables" or "Cotton" or "Sugar" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Puerto Rico"){
if($LResource == "Fruit" or "Vegetables" or "Cotton" or "Sugar" or "Tobacco"){
$Check = "yes";
} else {
$Check = "no";
}//end if
} else if($ID == "Cuba"){
if($LResource == "Timber" or "Fruit" or "Vegetables" or "Cotton" or "Sugar" or "Tobacco" or "Gold"){
$Check = "yes";
} else {
$Check = "no";
}//end if
}//end if
if($Check == "yes"){
$conn = mysql_connect("localhost", "root", "") or die('Could not connect to the database: '.mysql_error());
mysql_select_db("countries", $conn) or die('Could not select the database: '.mysql_error());
$sql = "update bonuses set LargePlantation = '$LResource' where convert(country using utf8) = '$ID' limit 1";
$res = mysql_query($sql) or die(mysql_error().'<p>SQL:<br />'.$sql.'</p>');
print "Resource Augmented";
} else {
print "you can't augment what you don't have";
}//end if
?>
Posted: Fri Dec 02, 2005 8:52 pm
by Charles256
look at arrays and the switch statement if you want to make that much prettier

Posted: Fri Dec 02, 2005 10:20 pm
by InnerShadow
the problem is it ends up being just about as long as each possibility has different parameters, plus i was more comfortable with IF/ELSE statements when i wrote it, and i haven't gotten around to rewritting it along with the newer scripts.
Posted: Fri Dec 02, 2005 10:45 pm
by josh
InnerShadow wrote:i did, but it was really long, so i took it out when i solved it
Fair enough,
