I would like to start off by saying I am very new at PHP. The following code was written by an acquaintance who is no longer able to assist and I am trying to further develop some additional things with it. I am running into an issue that I cannot wrap my head around.
The explode array is used to break a series of commands up into parts that are used within mysql statements to manipulate a database.
The issue I am having is some commands seem to work and some don't. See below:
if(isset ($_POST['commandline'])){
//handle cammand
$command = $_POST['commandline'];
$parts = explode(",",$command);
//print_r($parts);
//we know the first part is a command
//UPDATE NATURE CODE BY EVENT NUMBER WORKS
//PART 1 IS THE EVENT ID PART 2 IS THE NEW CALL TYPE
else if(preg_match("/UTE/",$parts[0])){
mysql_query("UPDATE runs SET calltype='{$parts[2]}' WHERE id='{$parts[1]}'");}
//UPDATE LOCATION EVENT NUMBER WORKS
//PART 1 IS THE EVENT ID PART 2 IS THE NEW LOCATION
else if(preg_match("/ULE/",$parts[0])){
mysql_query("UPDATE runs SET location='{$parts[2]}' WHERE id='{$parts[1]}'");}
//UPDATE DESCRIPTION EVENT NUMBER WILL NOT WORK
//PART 1 IS THE EVENT ID PART 2 IS THE NEW DESCRIPTION
else if(preg_match("/UDE/",$parts[0])){
mysql_query("UPDATE runs SET discrip='{$parts[2]}' WHERE id='{$parts[1]}'");}
else { header("Location: main.php?message=fail");
die;}
}
As you can see from my comments the UTE and ULE command works however the UDE command will not work. I have a feeling it has something to do with the "UTE" and "UDE" part as if I change "UDE" to a random letter like "Q" it will work.
Anyone know what is going on and how to get the "UDE" part to work? Any help is much appreciated.
if
? Or is this not the complete code? As it is you would get an error about unexpected T_ELSE on line 9 of your excerpt. – ScallioXTX May 18 '13 at 21:13code
else { header("Location: main.php?message=fail"); die;} }code
– NC1787 May 18 '13 at 21:23discrip
or should that bedescrip
? – Vedran Šego May 18 '13 at 21:47