We help IT Professionals succeed at work.
Get Started

I can not figure this out...!

Bruce Gust
Bruce Gust asked
on
63 Views
Last Modified: 2015-09-12
Here's my URL: http://cascsapws1v.nss.vzwnet.com/e2e/EPC_IMS_Report_Card_bg.php?sdate=2015-09-02&edate=2015-09-06®ion=CAROLINAS%2FTENNESSEE%2CCENTRAL+TEXAS%2CFLORIDA&toc=rank&x=45&y=9

Notice the "region..."

OK, now here comes my sql:

	$q2 = "SELECT TIME1, REGION, 

(100*SUM(DNS_FAILURE)/SUM(DNS_ATTEMPTS)) AS DNS_FAILURE_RATE,
(SUM(`DNS_Latency(ms)`)/SUM(DNS_LATENCY_ATTEMPTS)) AS AVG_DNS_LATENCY,
(100*SUM(UL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_UPLINK_PACKETS)) AS TCP_UL_RETX,
(100*SUM(DL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_DOWNLINK_PACKETS)) AS TCP_DL_RETX,
(SUM(CLIENT_ROUND_TRIP_TIME + SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_CombNetwk_RTT(ms)`,
(SUM(CLIENT_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Client_RTT(ms)`,
(SUM(SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Server_RTT(ms)`,

(100*SUM(ATTACH_FAILURES)/SUM(ATTACH_ATTEMPTS)) AS ATTACH_FAILURE_RATE,
(SUM(`Attach_Latency(ms)`)/SUM(ATTACH_ATTEMPTS_FOR_LATENCY)) AS `Avg_Attach_Latency(ms)`,
(100*SUM(PDN_FAILURES)/SUM(PDN_ATTEMPTS)) AS PDN_FAILURE_RATE,
(SUM(`PDN_Latency(ms)`)/SUM(PDN_ATTEMPTS_FOR_LATENCY)) AS `Avg_PDN_Latency(ms)`,
(100*SUM(S6A_FAILURES)/SUM(S6A_ATTEMPTS)) AS S6A_FAILURE_RATE,
(100*SUM(S6B_FAILURES)/SUM(S6B_ATTEMPTS)) AS S6B_FAILURE_RATE,
(100*SUM(ERAB_FAILURES)/SUM(ERAB_ATTEMPTS)) AS ERAB_FAILURE_RATE,
(100*SUM(INITCTXTSETUP_FAILURES)/SUM(INITCTXTSETUP_ATTEMPTS)) AS INITCTXTSETUP_FAILURE_RATE,
(100*SUM(SERVICEREQUEST_FAILURES)/SUM(SERVICEREQUEST_ATTEMPTS)) AS SERVICEREQUEST_FAILURE_RATE,

(100*SUM(SESSION_EFFECTIVE)/SUM(CALL_ATTEMPTS)) AS SEER,
(100*SUM(CALL_DROPS)/SUM(CALL_SETUPCOMPLETES)) AS CALL_DROP_RATE,
(100*SUM(CALL_COMPLETION)/SUM(CALL_ATTEMPTS)) AS SCR,
(100*SUM((EXCELLENT_BIN+GOOD_BIN))/SUM(MOS_VALID_SESSIONS)) AS ACQ,
(100*SUM(LOST_PACKETS)/SUM(SENT_PACKETS)) AS RTP_PACKETLOSS,
(SUM(AVG_PACKET_JITTER)/SUM(SESSION_ATTEMPTS)) AS AVG_RTP_PACKETJITTER,
(SUM(CALL_POST_DIAL_DELAY)/SUM(CALL_ATTEMPTS)) AS AVG_SIP_POSTDIALDELAY,
(100*SUM(ONE_WAY_SESSIONS)/SUM(SESSION_ATTEMPTS)) AS RTP_ONEWAYSESSION,
(100*SUM(`Total_Gap_Length(msec)`)/SUM(`Stream_Duration(msec)`)) AS RTP_GAP_DURATION

FROM epc_rc3 WHERE";

Open in new window


...and then I grab the data in my "region" from the URL:

 
$region_array= (explode(",", $_GET['region']));
echo"<br>";
$region_count= count($region_array);
//echo $region_array[0];
echo "<br>";
$the_region_code="(REGION=";
for($i=0; $i<=$region_count; $i++)
{
	$the_region_code.="'";
	$the_region_code.=$region_array[$i];
	if($i<($region_count-1))
	{
		$the_region_code.="'";
		$the_region_code.=" OR REGION=";
	}	
}
$the_region_code.=")";

Open in new window


...and then I finish up my sql:

$q2.=$the_region_code;
$q2.=" AND left(TIME1,10) between '".$sdate."' and '".$edate."' group by region order by region";

Open in new window


When I echo just the $the_region_code, I get this:

(REGION='CAROLINAS/TENNESSEE' OR REGION='CENTRAL TEXAS' OR REGION='FLORIDA')

Perfect!

But when I echo my sql statement, I get this:

SELECT TIME1, REGION, (100*SUM(DNS_FAILURE)/SUM(DNS_ATTEMPTS)) AS DNS_FAILURE_RATE, (SUM(`DNS_Latency(ms)`)/SUM(DNS_LATENCY_ATTEMPTS)) AS AVG_DNS_LATENCY, (100*SUM(UL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_UPLINK_PACKETS)) AS TCP_UL_RETX, (100*SUM(DL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_DOWNLINK_PACKETS)) AS TCP_DL_RETX, (SUM(CLIENT_ROUND_TRIP_TIME + SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_CombNetwk_RTT(ms)`, (SUM(CLIENT_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Client_RTT(ms)`, (SUM(SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Server_RTT(ms)`, (100*SUM(ATTACH_FAILURES)/SUM(ATTACH_ATTEMPTS)) AS ATTACH_FAILURE_RATE, (SUM(`Attach_Latency(ms)`)/SUM(ATTACH_ATTEMPTS_FOR_LATENCY)) AS `Avg_Attach_Latency(ms)`, (100*SUM(PDN_FAILURES)/SUM(PDN_ATTEMPTS)) AS PDN_FAILURE_RATE, (SUM(`PDN_Latency(ms)`)/SUM(PDN_ATTEMPTS_FOR_LATENCY)) AS `Avg_PDN_Latency(ms)`, (100*SUM(S6A_FAILURES)/SUM(S6A_ATTEMPTS)) AS S6A_FAILURE_RATE, (100*SUM(S6B_FAILURES)/SUM(S6B_ATTEMPTS)) AS S6B_FAILURE_RATE, (100*SUM(ERAB_FAILURES)/SUM(ERAB_ATTEMPTS)) AS ERAB_FAILURE_RATE, (100*SUM(INITCTXTSETUP_FAILURES)/SUM(INITCTXTSETUP_ATTEMPTS)) AS INITCTXTSETUP_FAILURE_RATE, (100*SUM(SERVICEREQUEST_FAILURES)/SUM(SERVICEREQUEST_ATTEMPTS)) AS SERVICEREQUEST_FAILURE_RATE, (100*SUM(SESSION_EFFECTIVE)/SUM(CALL_ATTEMPTS)) AS SEER, (100*SUM(CALL_DROPS)/SUM(CALL_SETUPCOMPLETES)) AS CALL_DROP_RATE, (100*SUM(CALL_COMPLETION)/SUM(CALL_ATTEMPTS)) AS SCR, (100*SUM((EXCELLENT_BIN+GOOD_BIN))/SUM(MOS_VALID_SESSIONS)) AS ACQ, (100*SUM(LOST_PACKETS)/SUM(SENT_PACKETS)) AS RTP_PACKETLOSS, (SUM(AVG_PACKET_JITTER)/SUM(SESSION_ATTEMPTS)) AS AVG_RTP_PACKETJITTER, (SUM(CALL_POST_DIAL_DELAY)/SUM(CALL_ATTEMPTS)) AS AVG_SIP_POSTDIALDELAY, (100*SUM(ONE_WAY_SESSIONS)/SUM(SESSION_ATTEMPTS)) AS RTP_ONEWAYSESSION, (100*SUM(`Total_Gap_Length(msec)`)/SUM(`Stream_Duration(msec)`)) AS RTP_GAP_DURATION FROM epc_rc3 WHERE(REGION='CAROLINAS/TENNESSEE' OR REGION='CENTRAL TEXAS' OR REGION='FLORIDA') AND left(TIME1,10) between '2015-09-02' and '2015-09-06' group by region order by regionSELECT TIME1,AREA, REGION, (100*SUM(DNS_FAILURE)/SUM(DNS_ATTEMPTS)) AS DNS_FAILURE_RATE, (SUM(`DNS_Latency(ms)`)/SUM(DNS_LATENCY_ATTEMPTS)) AS AVG_DNS_LATENCY, (100*SUM(UL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_UPLINK_PACKETS)) AS TCP_UL_RETX, (100*SUM(DL_PACKECTS_RETRANSMITTED)/SUM(NETWORK_DOWNLINK_PACKETS)) AS TCP_DL_RETX, (SUM(CLIENT_ROUND_TRIP_TIME + SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_CombNetwk_RTT(ms)`, (SUM(CLIENT_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Client_RTT(ms)`, (SUM(SERVER_ROUND_TRIP_TIME)/(1000*SUM(SUCCESSFUL_TCP_FLOWS))) AS `Avg_Server_RTT(ms)`, (100*SUM(ATTACH_FAILURES)/SUM(ATTACH_ATTEMPTS)) AS ATTACH_FAILURE_RATE, (SUM(`Attach_Latency(ms)`)/SUM(ATTACH_ATTEMPTS_FOR_LATENCY)) AS `Avg_Attach_Latency(ms)`, (100*SUM(PDN_FAILURES)/SUM(PDN_ATTEMPTS)) AS PDN_FAILURE_RATE, (SUM(`PDN_Latency(ms)`)/SUM(PDN_ATTEMPTS_FOR_LATENCY)) AS `Avg_PDN_Latency(ms)`, (100*SUM(S6A_FAILURES)/SUM(S6A_ATTEMPTS)) AS S6A_FAILURE_RATE, (100*SUM(S6B_FAILURES)/SUM(S6B_ATTEMPTS)) AS S6B_FAILURE_RATE, (100*SUM(ERAB_FAILURES)/SUM(ERAB_ATTEMPTS)) AS ERAB_FAILURE_RATE, (100*SUM(INITCTXTSETUP_FAILURES)/SUM(INITCTXTSETUP_ATTEMPTS)) AS INITCTXTSETUP_FAILURE_RATE, (100*SUM(SERVICEREQUEST_FAILURES)/SUM(SERVICEREQUEST_ATTEMPTS)) AS SERVICEREQUEST_FAILURE_RATE, (100*SUM(SESSION_EFFECTIVE)/SUM(CALL_ATTEMPTS)) AS SEER, (100*SUM(CALL_DROPS)/SUM(CALL_SETUPCOMPLETES)) AS CALL_DROP_RATE, (100*SUM(CALL_COMPLETION)/SUM(CALL_ATTEMPTS)) AS SCR, (100*SUM((EXCELLENT_BIN+GOOD_BIN))/SUM(MOS_VALID_SESSIONS)) AS ACQ, (100*SUM(LOST_PACKETS)/SUM(SENT_PACKETS)) AS RTP_PACKETLOSS, (SUM(AVG_PACKET_JITTER)/SUM(SESSION_ATTEMPTS)) AS AVG_RTP_PACKETJITTER, (SUM(CALL_POST_DIAL_DELAY)/SUM(CALL_ATTEMPTS)) AS AVG_SIP_POSTDIALDELAY, (100*SUM(ONE_WAY_SESSIONS)/SUM(SESSION_ATTEMPTS)) AS RTP_ONEWAYSESSION, (100*SUM(`Total_Gap_Length(msec)`)/SUM(`Stream_Duration(msec)`)) AS RTP_GAP_DURATION FROM epc_rc3 WHERE (REGION = 'CAROLINAS/TENNESSEE,CENTRAL TEXAS,FLORIDA') AND left(TIME1,10) between '2015-09-02' and '2015-09-06' group by region order by region

Open in new window


Notice the "WHERE (REGION = 'CAROLINAS/TENNESSEE,CENTRAL TEXAS,FLORIDA') " at the end.

What am I doing wrong? Why doesn't "$the_region_code" render properly at the end of my sql string?

Thoughts?
Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE