1 Replies - 256 Views - Last Post: 01 February 2013 - 01:35 PM

#1 knightmare2dream  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 13-February 10

php code getting commented out

Posted 01 February 2013 - 01:19 PM

When I try to run simple php script to test my ajax request I see that the php is getting editted out. I inspected element in chrome's debugging and instead of
<?php
echo "Hello World"
?>

Its showing:
<!--?php
echo "Hello World"
?-->

Any idea why it would be doing this? Below is my html:
<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>T1 Dispatch Site</title>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
    document.write(unescape("%3Cscript src='jquery-1.8.3.min.js' type='text/javascript'%3E%3C/script%3E")); //local
}
</script>
<style>
  #head{
  height: 75px;
  background-color:#3399FF;
	}
  html, body {
	height:100%;
	font-size:16px;
	margin: 0px;
	padding: 0;
	}
	table {
    border-collapse: collapse;
	border-spacing: 0;
	cellspacing: 0;
	cellpadding: 0;
	}
	th, td {
    padding: 0;
	margin: 0;
	}
	tr{
	padding: 0;
	margin: 0;
	border-style:solid;
	border-color:black;
	}
	input{
	width:100px;
	text-align:center;
	font-weight:bold;
	}
	.shift1 input{
	background-color:#FF9494;
	}
	.shift2 input{
	background-color:#FFFF66;
	}
	.shift3 input{
	background-color:#B2CCFF;
	}
	.shift3 input{
	background-color:#00FF00;
	}
	.shift4 input{
	background-color:#E57EE5;
	}
	.shift5 input{
	background-color:#FF0000;
	}
	.shift6 input{
	background-color:#B2CCFF;
	}
  </style>
 
 <script>
 <!--Load current ticket values-->
function loadTicket(){
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","ticketData.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var emps = xmlDoc.getElementsByTagName("employee");
var startTickets = xmlDoc.getElementsByTagName("start");
var assignTick = xmlDoc.getElementsByTagName("assigned");
var reopenTick = xmlDoc.getElementsByTagName("reopened");
var handoffTick = xmlDoc.getElementsByTagName("handoff");
var endTick = xmlDoc.getElementsByTagName("end");

	for(var x=0;x < emps.length;x++)
	{
		var empNum = "emp" + x
		document.getElementById(empNum).innerHTML=
		emps[x].childNodes[0].nodeValue;
	}
	for(var x=1;x<=startTickets.length;x++)
	{
		var empstart = "emp" + x +"start";
		document.getElementById(empstart).value=
		startTickets[x-1].childNodes[0].nodeValue;
	}
	for(var x=1;x<=assignTick.length;x++)
	{
		var empassigned = "emp" + x +"assigned";
		document.getElementById(empassigned).value=
		assignTick[x-1].childNodes[0].nodeValue;
	}
	for(var x=1;x<=reopenTick.length;x++)
	{
		var empreopen = "emp" + x +"reOpen";
		document.getElementById(empreopen).value=
		reopenTick[x-1].childNodes[0].nodeValue;
	}
	for(var x=1;x<=handoffTick.length;x++)
	{
		var emphandoff = "emp" + x +"handoff";
		document.getElementById(emphandoff).value=
		handoffTick[x-1].childNodes[0].nodeValue;
	}
	for(var x=1;x<=endTick.length;x++)
	{
		var empend = "emp" + x +"end";
		document.getElementById(empend).value=
		endTick[x-1].childNodes[0].nodeValue;
	}
	
	var kickTick = xmlDoc.getElementsByTagName("kicked");
	document.getElementById('kicked').value= kickTick[0].childNodes[0].nodeValue;
}

<!--ready jquery---->
$( document ).ready( function() {

	<!--Clear the form-->
	$("#clear").click(function () {
	
		for(var x=1;x<=12;x++)
		{
			var current = "emp"+x+"start";
			document.getElementById(current).value='0';
			var current = "emp"+x+"assigned";
			document.getElementById(current).value='0';
			var current = "emp"+x+"reOpen";
			document.getElementById(current).value='0';
			var current = "emp"+x+"handoff";
			document.getElementById(current).value='0';
			var current = "emp"+x+"end";
			document.getElementById(current).value='0';
		}
		
		document.getElementById("total").value = 0;
		document.getElementById("kicked").value = 0;
	});
	
	<!-----------------save xml tickets------>
	$("#save").click(function () {
		<!--Get array of employees-->
		var emps=new Array();
		for(var x=0;x<12;x++)
		{
			var current = "emp"+(x);
			emps[x]= document.getElementById(current).innerHTML;
		}
		
		<!--Get arrays tickets---->
		var starts=new Array();
		var assigned=new Array();
		var reopen=new Array();
		var handoff=new Array();
		var end=new Array();
		for(var x=0;x<12;x++)
		{
			var current = "emp"+(x+1)+"start";
			starts[x]= document.getElementById(current).value;
			var current = "emp"+(x+1)+"assigned";
			assigned[x]= document.getElementById(current).value;
			var current = "emp"+(x+1)+"reOpen";
			reopen[x]= document.getElementById(current).value;
			var current = "emp"+(x+1)+"handoff";
			handoff[x]= document.getElementById(current).value;
			var current = "emp"+(x+1)+"end";
			end[x]= document.getElementById(current).value;
		}
		var total= document.getElementById("total").value;
		var kicked= document.getElementById("kicked").value;
		
		var xmlHttp = getXMLHttp();
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4)
			{
				HandleResponse(xmlHttp.responseText);
			}
		}

		xmlHttp.open("GET", "saveTickets.php", true);
		xmlHttp.send(null);
	});
	
	<!-----------------Email ticket numbers--->
	$("#email").click(function () {
		var day= new Date();
		var addresses = "aaronm@amazon.com;portillo@amazon.com";
		var body = "New Trends: %0D%0A %0D%0A %0D%0A"
		body += "%09%09Start%09%09Assigned%09Re-opened%09Handoff%09%09EndofDay%0D%0A%0D%0A"
		for(var x=1;x<=12;x++)
		{
			var current = "emp"+(x-1);
			body += document.getElementById(current).innerHTML +":%09%09";
			var current = "emp"+x+"start";
			body += document.getElementById(current).value +";%09";
			var current = "emp"+x+"assigned";
			body += document.getElementById(current).value+";%09";
			var current = "emp"+x+"reOpen";
			body += document.getElementById(current).value+";%09";
			var current = "emp"+x+"handoff";
			body += document.getElementById(current).value+";%09";
			var current = "emp"+x+"end";
			body += document.getElementById(current).value+";%09";
			body += "%0D%0A";
		}
		body += "Kicked: " + document.getElementById('kicked').value + "%0D%0A";
		body += "Total Tickets Assigned: " + document.getElementById('total').value;
		var subject = "Dispatch report for " + day
		var href = "mailto:" + addresses + "?"
         + "subject=" + subject + "&"
         + "body=" + body;
		 
		var wndMail;
		wndMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10");
		if(wndMail)
		{
			wndMail.close();    
		}
	});
	
});

<!-----------------update total tickets---------->
function addTotal(){
		var total=0;
		for(var x=1;x<=12;x++)
		{
			var inputName;
			inputName = "emp"+x+"assigned";
			total+= Number(document.getElementById(inputName).value);
		}
		document.getElementById("total").value = total;
		
	};

function HandleResponse(response)
{
  document.getElementById('return').innerHTML = response;
}
function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}
 </script>
 </head>
 <body onload="loadTicket();addTotal();">
	<div id="head"><br>
	<h1><center>T1 Dispatch</center></h1>
	</div>
	<form method="POST" action="saveTickets.php" id="myForm">
	<div id="body" style="padding-left:10px;">
		<span style="float:right;">
		<a href="https://portal.ant.amazon.com/sites/aot/helpdesk/Lists/Announcements/DispForm.aspx?ID=24&Source=https%3A%2F%2Fportal.ant.amazon.com%2Fsites%2Faot%2Fhelpdesk%2Fdefault.aspx" style="padding-right:20px">Tier 1 Schedule</a> </span>
		<table id='thetable'>
		<tr>
		<th></th>
		<th>Start of Day:</th>
		<th>Assigned:</th>
		<th>Re-Opened:</th>
		<th># at Handoff:</th>
		<th>End of Day:</th>
		</tr>
		<tr class="shift1">
		<th id="emp0"></th>
		<td ><input type="text" id="emp1start"></td>
		<td ><input type="text" id="emp1assigned" onchange="addTotal();"></td>
		<td ><input type="text" id="emp1reOpen"></td>
		<td ><input type="text" id="emp1handoff"></td>
		<td ><input type="text" id="emp1end"></td>
		</tr>
		<tr class="shift1">
		<th id="emp1"></th>
		<td><input type="text" id="emp2start"></td>
		<td><input type="text" id="emp2assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp2reOpen"></td>
		<td><input type="text" id="emp2handoff"></td>
		<td><input type="text" id="emp2end"></td>
		</tr>
		<tr class="shift1"><th id="emp2"></th>
		<td><input type="text" id="emp3start"></td>
		<td><input type="text" id="emp3assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp3reOpen"></td>
		<td><input type="text" id="emp3handoff"></td>
		<td><input type="text" id="emp3end"></td>
		</tr>
		<tr class="shift2"><th id="emp3"></th>
		<td><input type="text" id="emp4start"></td>
		<td><input type="text" id="emp4assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp4reOpen"></td>
		<td><input type="text" id="emp4handoff"></td>
		<td><input type="text" id="emp4end"></td>
		</tr>
		<tr class="shift2"><th id="emp4"></th>
		<td><input type="text" id="emp5start"></td>
		<td><input type="text" id="emp5assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp5reOpen"></td>
		<td><input type="text" id="emp5handoff"></td>
		<td><input type="text" id="emp5end"></td>
		</tr>
		<tr class="shift3"><th id="emp5"></th>
		<td><input type="text" id="emp6start"></td>
		<td><input type="text" id="emp6assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp6reOpen"></td>
		<td><input type="text" id="emp6handoff"></td>
		<td><input type="text" id="emp6end"></td>
		</tr>
		<tr class="shift3"><th id="emp6"></th>
		<td><input type="text" id="emp7start"></td>
		<td><input type="text" id="emp7assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp7reOpen"></td>
		<td><input type="text" id="emp7handoff"></td>
		<td><input type="text" id="emp7end"></td>
		</tr>
		<tr class="shift3"><th id="emp7"></th>
		<td><input type="text" id="emp8start"></td>
		<td><input type="text" id="emp8assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp8reOpen"></td>
		<td><input type="text" id="emp8handoff"></td>
		<td><input type="text" id="emp8end"></td>
		</tr>
		<tr class="shift4"><th id="emp8"></th>
		<td><input type="text" id="emp9start"></td>
		<td><input type="text" id="emp9assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp9reOpen"></td>
		<td><input type="text" id="emp9handoff"></td>
		<td><input type="text" id="emp9end"></td>
		</tr>
		<tr class="shift5"><th id="emp9"></th>
		<td><input type="text" id="emp10start"></td>
		<td><input type="text" id="emp10assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp10reOpen"></td>
		<td><input type="text" id="emp10handoff"></td>
		<td><input type="text" id="emp10end"></td>
		</tr>
		<tr class="shift6"><th id="emp10"></th>
		<td><input type="text" id="emp11start"></td>
		<td><input type="text" id="emp11assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp11reOpen"></td>
		<td><input type="text" id="emp11handoff"></td>
		<td><input type="text" id="emp11end"></td>
		</tr>
		<tr class="shift6"><th id="emp11"></th>
		<td><input type="text" id="emp12start"></td>
		<td><input type="text" id="emp12assigned" onchange="addTotal();"></td>
		<td><input type="text" id="emp12reOpen"></td>
		<td><input type="text" id="emp12handoff"></td>
		<td><input type="text" id="emp12end"></td>
		</tr>
		<tr>
		<th>total:</th><td></td>
		<td><input type="text" id="total"></td>
		<th>kicked:</th><td></td>
		<td><input type="text" id="kicked"></td>
		</table>
		<br>
		<input type="button" id="save" value="Save"></input>
		<input type="button" id="email" value="Email"></input>
		<span style="float:right;"><input type="button" id="clear" value="Clear"></input></span>
	</div>
	<div id="return">
	</div>
	</form>
 </body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: php code getting commented out

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3738
  • View blog
  • Posts: 13,067
  • Joined: 12-December 12

Re: php code getting commented out

Posted 01 February 2013 - 01:35 PM

Why would you expect to see a PHP script-fragment in your page? Surely you should just be expecting "Hello World!" in your page, which is the value that should be returned when the PHP script is executed on the server.

Anyway, you have an HTML comment in your JS script, so I would delete this line:
 <!--Load current ticket values-->

or change it to a JS comment:
// Load current ticket values

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1