Adding Conditional Where to PHP Code
$5-10 USD
Posted about 14 years ago
$5-10 USD
Paid on delivery
I have some PHP code which works today. I am trying to add some more predicates to the WHERE clause.? The new ones do not work.? The code is below. ? I have highlighted the nonworking statements.? Entire test installation with mySQL installation is attached.? This PHP is TCPTerm1.php.
Instructions to install are in the attached zip file.
<?php
$LocIpAddr=$_GET["LocIpAddr"];
$RmtIpAddr=$_GET["RmtIpAddr"];
If ($LocIpAddr == "") $LocIpAddr = "%";
If ($RmtIpAddr == "") $RmtIpAddr = "%";
$LocPortSingleFld=$_GET["LocPortSingleFld"];
$LocPortWhere = "";
If ($LocPortSingleFld == "")
? ? {? $LocPortWhere = "";
? ? }
Else
? ? { $LocPortWhere = "And TTLPORT=" . $LocPortSingleFld . ";
? ? ? ? echo $LocPortWhere;
? ? ? }
$con = mysql_connect("localhost","root","");
if (!$con)
{
? $ErrMsg = "{";
? $ErrMsg = $ErrMsg . "ErrMsg: ";
? $ErrMsg = $ErrMsg . "'Houston we have a problem!!'";
? $ErrMsg = $ErrMsg . "}";
? echo $ErrMsg;
? exit(0);
}
$arr = array();
mysql_select_db('DBITS200');
$Query = "Select
? ? ? ? ? ? ? ? ? ? ? TTEDATE,
? ? ? TTETIME,
? ? ? TTLIP,
? ? ? TTLPORT,
? ? ? TTRIP,
? ? ? TTRPORT,
? ? ? TTINBYTES,
? ? ? TTOUTBYTES,
? ? ? TTTERMCODE,
? ? ? Case TTTERMCODE
? ? ? ? When 82 Then 'APP CLOS'
? ? ? ? When 83 then 'PSC CLOS'
? ? ? End as TTERMDCODE,
? ? ? Timestamp(TTEDATE,TTETIME) - Timestamp(TTSDATE,TTSTIME) as DURATION,
? ? ? TTRTT,
? ? ? TTRVA,
? ? ? TTXRT,
? ? ? TTDUPACKS
? ? ? From TBITS201
? ? ? Where TTLIP Like '" . $LocIpAddr . "'?
? ? ? And TTRIP Like '" . $RmtIpAddr . "'
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ". $LocPortWhere .";
$ResultSet = mysql_query($Query);
while($obj = mysql_fetch_object($ResultSet))
{
? $arr[] = $obj;
}
echo json_encode($arr);
mysql_close($con);
exit(0);
?>
Project ID: 3353469
About the project
1 proposal
Remote project
Active 14 yrs ago
Looking to make some money?
Benefits of bidding on Freelancer
Set your budget and timeframe
It's free to sign up and bid on jobs
1 freelancer is bidding on average $9 USD for this job
$8.50 USD in 1 day
4.9 (264 reviews)