0
<td>
                <select name="sourceitems">
<?php

            $Qry1->text = "SELECT * FROM sourceitems";
            $Qry1->openSQL();
            $Qry1->first();

        while(!$Qry1->eof){
            $SourceID=$Qry1->fieldByName("SourceID");
            $ItemName=$Qry1->fieldByName("ItemName");
            $selected="";
                   if ($SourceID == $_POST['SourceID'] )
                            $selected="selected";

            print "<option value=\"$SourceID\" $selected> $ItemName </option>";
            $Qry1->next();
        }

?>
                </select>
            </td>


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Webroot\TM\editData.php on line 179

It keeps show the error above at around $ItemName.... that line...Please help me~

Edited by mike_2000_17: Fixed formatting

3
Contributors
20
Replies
21
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

use braces {} around php variables like shown below

print "<option value=\"{$SourceID}\" {$selected}> {$ItemName} </option>";

0

still can not...

the same error shown at the line
$ItemName=$Qry1->fieldByName("ItemName");

0
<?php
require_once("./include/utillib.inc");
require_once("./include/MyConfig.inc");


session_start();
startup_check();
startup_init();
main_process();
main_function();


?>

<?php
//=================== Startup Check ====================
function startup_check()
{
   $returnArray = checkUser ("rateplan.php");

   if(!$returnArray[success])
   {
      header("Location: ./login.php");
      exit();
   }
}

//=================== Startup Initialize ====================
function startup_init()
{
global $PageTitle, $Message, $Qry1, $Error,$rate;

$PageTitle = "Rate Plan";
$Message = "";

get_title();

$Qry1 = new queryODBC(DB_SERVER, DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);
$Qry1->connect();
}

//=================== Process Action ====================
function main_process()
{
 if( $_POST['ActFlag']== "Save" )
  update_changes();
if($_POST['ActFlag']=="Cancel")
  backPage();

}
//=================== Main Function ====================
function main_function()
{
   global $Error, $Message,$rate,$pass;
$pass=$_GET['pass'];
   print "<html>\n";
   print_head();
   print "</html>\n";
   print "<body>\n";
   require_once("header.php");
   print_title();
   load_data();
   editing_form();
  
  print "<script language=\"javascript\" type=\"text/javascript\" src=\"datetimepicker.js\">";
print "</script>";
   print "</body>";
 } 

//=================== Print Head ====================
function print_head()
{
   global $PageTitle;
   print "<head>";
   print "\t<title>".$PageTitle."</title>";
print<<<END
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <link href="./Include/mystyle.css" rel="stylesheet" type="text/css">
  
</head>
END;
}

//=================== Print Title ====================
function print_title()
{
   global $PageTitle, $Message;
   print "\t<P align = \"Center\" >";
   print "\t\t<font class=\"PageTitle\"><b>".$PageTitle."</b></font></P><br><br>";
}

//=================== Entry Form ====================
function entry_form()
{
print "\t<form name=\"NewEntryForm\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
print<<<END
   <table width="100%" cellpadding="3" cellspacing="1" border="0">
      <col width="04%">
      <col width="30%">
      <col width="30%">
      <col width="37%">

      <tr class='PartTitle1'>
         <td colspan="4"><font class="WhiteLabel"><b>Choose your rate plan:</b></font></td>
      </tr>

      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Rate Plan Name</b></font></td>
         <td colspan="3" class="BlackLabel">
END;

  $rate = Array ("Select a rate Plan","Incoming Rate", "Local Call Rate", "Port Rate");
 //Values from array 1 
 print "\t<SELECT NAME=".rateMenu. " SIZE=1>\n";
//for each value of the array assign a variable name word 
for ($x=1; $x<=count($rate); $x++)
      {
   printf ("\t\t<OPTION VALUE=\"%02d\"", $x);
        if ($_POST['rateMenu'] == $x)
            print " SELECTED ";
         print ">".$rate[$x-1]."</OPTION>\n";
      }
      print "\t</SELECT>\n";
   
	  print<<<END
 
         </td>
		
      </tr>

   </table>
END;

go_action_bar();
print<<<END
   </form><br>
END;
}

//=================== Editing Form ====================
function editing_form()
{
global $rate,$pass;
if(isset($_GET['RateCode'])||( $_SESSION['pass']=="incoming")){
print "\t<form name=\"EditingForm\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
print<<<END
   <table width="100%" cellpadding="3" cellspacing="1" border="0">
      <col width="03%">
      <col width="30%">
      <col width="30%">
      <col width="37%">

      <tr class='PartTitle1'>
         <td colspan="4"><font class="WhiteLabel"><b>Incoming Rate</b></font></td>
      </tr>

      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Rate code</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input type=\"hidden\" name=\"RateCode\" value=\"".$_POST['RateCode']."\" >";
print "\t\t\t\t".$_POST['RateCode'];
print<<<END
         </td>
      </tr>

      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Source</b></font></td>
        <td>
<select name="sourceitems">
<?php

$Qry1->text = "SELECT * FROM sourceitems";
$Qry1->openSQL();
$Qry1->first();

while(!$Qry1->eof){
$SourceID=$Qry1->fieldByName("SourceID");
$ItemName=$Qry1->fieldByName("ItemName");
$selected="";
if ($SourceID == $_POST['SourceID'] )
$selected="selected";

print "<option value=\"$SourceID\" $selected> $ItemName </option>";
$Qry1->next();
}

?>
</select>
</td>
	 </tr>

  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Start Date/Time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffStartDT\" value=\"".$_POST['EffStartDT']."\" size=\"50\" maxlength=\"125\" >";
print "<input name=\"EffStartDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffStartDT'])."\"><a href=\"javascript:NewCal('EffStartDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>

 <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>End Date/Time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffEndDT\" value=\"".$_POST['EffEndDT']."\" size=\"50\" maxlength=\"125\" >";
print "<input name=\"EffEndDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffEndDT'])."\"><a href=\"javascript:NewCal('EffEndDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>
	  
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>AmountCharge</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"AmountCharge\" value=\"".$_POST['AmountCharge']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>	
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Description</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Description\" value=\"".$_POST['Description']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
   </table>
    
END;
save_action_bar();
print<<<END
   </form><br>
END;

}

if(isset($_GET['LocalCode'])||( $_SESSION['pass']=="local")) {
print "\t<form name=\"EditingForm\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
print<<<END
   <table width="100%" cellpadding="3" cellspacing="1" border="0">
      <col width="03%">
      <col width="30%">
      <col width="30%">
      <col width="37%">

      <tr class='PartTitle1'>
         <td colspan="4"><font class="WhiteLabel"><b>Local Call Rate</b></font></td>
      </tr>
	  
 <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Local code</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input type=\"hidden\" name=\"LocalCode\" value=\"".$_POST['LocalCode']."\" >";
print "\t\t\t\t".$_POST['LocalCode'];
print<<<END
         </td>
      </tr>
	  
      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Start Date/Time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;

//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffStartDT\" value=\"".$_POST['EffStartDT']."\" size=\"40\" maxlength=\"30\" >";
print "<input name=\"EffStartDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffStartDT'])."\"><a href=\"javascript:NewCal('EffStartDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>

      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>End Date/Time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffEndDT\" value=\"".$_POST['EffEndDT']."\" size=\"50\" maxlength=\"125\" >";
print "<input name=\"EffEndDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffEndDT'])."\"><a href=\"javascript:NewCal('EffEndDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>

<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Label</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Label\" value=\"".$_POST['Label']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>

<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Band 1 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WDB1ChargeBlockID\" value=\"".$_POST['WDB1ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Band 2 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WDB2ChargeBlockID\" value=\"".$_POST['WDB2ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Band 3 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WDB3ChargeBlockID\" value=\"".$_POST['WDB3ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Band 1 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WEB1ChargeBlockID\" value=\"".$_POST['WEB1ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Band 2 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WEB2ChargeBlockID\" value=\"".$_POST['WEB2ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Band 3 chargeblockID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"WEB3ChargeBlockID\" value=\"".$_POST['WEB3ChargeBlockID']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Setup Fee</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Setup_Fee\" value=\"".$_POST['Setup_Fee']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Start Weekday</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Start_Week_Day\" value=\"".$_POST['Start_Week_Day']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>End Weekday</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"End_Week_Day\" value=\"".$_POST['End_Week_Day']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
		 </tr>
		 
		 <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Start time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Start_Week_Time\" value=\"".$_POST['Start_Week_Time']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>End time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"End_Week_Time\" value=\"".$_POST['End_Week_Time']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Band 1 time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_Day_Band_1\" value=\"".$_POST['Week_Day_Band_1']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Band 2 time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_Day_Band_2\" value=\"".$_POST['Week_Day_Band_2']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr> 
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Rate 1</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_Day_Rate_1\" value=\"".$_POST['Week_Day_Rate_1']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	  
	   <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Rate 2</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_Day_Rate_2\" value=\"".$_POST['Week_Day_Rate_2']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	   <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekday Rate 3</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_Day_Rate_3\" value=\"".$_POST['Week_Day_Rate_3']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Band 1 time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_End_Band_1\" value=\"".$_POST['Week_End_Band_1']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Band 2 time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_End_Band_2\" value=\"".$_POST['Week_End_Band_2']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr> 
	  
	  <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Rate 1</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_End_Rate_1\" value=\"".$_POST['Week_End_Rate_1']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>  
	  
	   <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Weekend Rate 2</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_End_Rate_2\" value=\"".$_POST['Week_End_Rate_2']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
	   <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>WeekendRate 3</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Week_End_Rate_3\" value=\"".$_POST['Week_End_Rate_3']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>      
   </table>
    
END;
save_action_bar();
print<<<END
   </form><br>
END;

}

if(isset($_GET['PortCode'])||( $_SESSION['pass']=="port")){
print "\t<form name=\"EditingForm\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
print<<<END
   <table width="100%" cellpadding="3" cellspacing="1" border="0">
      <col width="03%">
      <col width="30%">
      <col width="30%">
      <col width="37%">

      <tr class='PartTitle1'>
         <td colspan="4"><font class="WhiteLabel"><b>Port Rate</b></font></td>
      </tr>
	  
 <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Port code</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input type=\"hidden\" name=\"PortCode\" value=\"".$_POST['PortCode']."\" >";
print "\t\t\t\t".$_POST['PortCode'];
print<<<END
         </td>
      </tr>
	  
      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Source ID</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input type=\"hidden\" name=\"SourceID\" value=\"".$_POST['AmtPerHour']."\" >";
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"SourceID\" value=\"".$_POST['SourceID']."\" size=\"40\" maxlength=\"30\" >";
print<<<END
         </td>
      </tr>

      <tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Speed</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"Speed\" value=\"".$_POST['Speed']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>

<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Start Date/time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffStartDT\" value=\"".$_POST['EffStartDT']."\" size=\"50\" maxlength=\"125\" >";
print "<input name=\"EffStartDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffStartDT'])."\"><a href=\"javascript:NewCal('EffStartDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>

<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>End Date/time</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
//print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"EffEndDT\" value=\"".$_POST['EffEndDT']."\" size=\"50\" maxlength=\"125\" >";
print "<input name=\"EffEndDT\" type=\"text\" size=\"25\" value=\"".trim($_POST['EffEndDT'])."\"><a href=\"javascript:NewCal('EffEndDT','ddmmyyyy','true','24')\"><img src=\"cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
print<<<END
         </td>
      </tr>

<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>First Block</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"FirstBlock\" value=\"".$_POST['FirstBlock']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Sub Block</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"SubBlock\" value=\"".$_POST['SubBlock']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
	  
<tr class='GrayBackground1'>
         <td><font class="BlackLabel"><b>Charge per Hour</b></font></td>
         <td colspan="3" class="BlackLabel">
END;
print "\t\t\t\t<input class=\"InputA\" type=\"text\" name=\"AmtPerHour\" value=\"".$_POST['AmtPerHour']."\" size=\"50\" maxlength=\"125\" >";
print<<<END
         </td>
      </tr>
   </table>
    
END;
save_action_bar();
print<<<END
   </form><br>
END;

}
}
//=================== Back to Main Form ====================
function back_to_first()
{
print "\t<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
print "\t\t<input class=\"ButtonB\" type=\"Submit\" value=\"Back to First Page\" >";
print "\t</form>";
}

//=================== Load a Record From DB ====================
function load_data()
{
   // --- Preparing for Edit form ---
   global $Message, $Qry1, $Error,$rate;
   $Error = false;
  
   
if(isset($_GET['RateCode']))
{
  unset($_SESSION['pass']);
   if(!$Error)
   {
    
     $RateCode= $_GET['RateCode'];
         $Qry1->text = "SELECT * FROM incomingrate WHERE RateCode ='$RateCode'";
		// die($Qry1->text);
         $Qry1->openSQL();

         if(!$Qry1->eof)
         {
            $_POST['RateCode'] = $Qry1->fieldByName("RateCode");
            $_POST['SourceID'] = $Qry1->fieldByName("SourceID");
            $_POST['EffStartDT'] =$Qry1->fieldByName("EffStartDT");
		    $_POST['EffEndDT'] = $Qry1->fieldByName("EffEndDT");
			$_POST['AmountCharge'] = $Qry1->fieldByName("AmountCharge");
			$_POST['Description'] = $Qry1->fieldByName("Description");
		 }else
         
            $Message .= "\\nFail to Get Detail<br>\n";
         
      }
	}
	
if(isset($_GET['PortCode'])) { 
	
unset($_SESSION['pass']);
   if(!$Error)
   {
    
      $PortCode= $_GET['PortCode'];
         $Qry1->text = "SELECT * FROM portrate WHERE PortCode = '$PortCode'";
         $Qry1->openSQL();

         if(!$Qry1->eof)
         {
		   $_POST['PortCode'] = $Qry1->fieldByName("PortCode");
            $_POST['SourceID'] = $Qry1->fieldByName("SourceID");
            $_POST['Speed'] = $Qry1->fieldByName("Speed");
            $_POST['EffStartDT'] = $Qry1->fieldByName("EffStartDT");
			$_POST['EffEndDT'] = $Qry1->fieldByName("EffEndDT");
			$_POST['FirstBlock'] = $Qry1->fieldByName("FirstBlock");
			$_POST['SubBlock'] = $Qry1->fieldByName("SubBlock");
			$_POST['AmtPerHour'] = $Qry1->fieldByName("AmtPerHour");
         }else
         
            $Message .= "\\nFail to Get Detail<br>\n";
     
	}
}

if(isset($_GET['LocalCode'])) {
	unset($_SESSION['pass']);
   if(!$Error)
   {
     $LocalCode= $_GET['LocalCode'];
		
         $Qry1->text = "SELECT * FROM localcallrate WHERE LocalCode = '$LocalCode' ";
         $Qry1->openSQL();
         if(!$Qry1->eof)
         {
				$_POST['LocalCode'] = $Qry1->fieldByName("LocalCode");
				$_POST['EffStartDT'] = $Qry1->fieldByName("EffStartDT");
				$_POST['EffEndDT'] = $Qry1->fieldByName("EffEndDT");
				$_POST['Label'] = $Qry1->fieldByName("Label");
			    $_POST['WDB1ChargeBlockID'] = $Qry1->fieldByName("WDB1ChargeBlockID");
			    $_POST['WDB2ChargeBlockID'] = $Qry1->fieldByName("WDB2ChargeBlockID");
			    $_POST['WDB3ChargeBlockID'] = $Qry1->fieldByName("WDB3ChargeBlockID");
				$_POST['WEB1ChargeBlockID'] = $Qry1->fieldByName("WEB1ChargeBlockID");
			    $_POST['WEB2ChargeBlockID'] = $Qry1->fieldByName("WEB2ChargeBlockID");
			    $_POST['WEB3ChargeBlockID'] = $Qry1->fieldByName("WEB3ChargeBlockID");
				$_POST['Setup_Fee'] = $Qry1->fieldByName("Setup_Fee");
				$_POST['Start_Week_Day'] = $Qry1->fieldByName("Start_Week_Day");
				$_POST['End_Week_Day'] = $Qry1->fieldByName("End_Week_Day");
				$_POST['Start_Week_Time'] = $Qry1->fieldByName("Start_Week_Time");
				$_POST['End_Week_Time'] = $Qry1->fieldByName("End_Week_Time");
				$_POST['Week_Day_Band_1'] = $Qry1->fieldByName("Week_Day_Band_1");
				$_POST['Week_Day_Band_2'] = $Qry1->fieldByName("Week_Day_Band_2");
				$_POST['Week_Day_Rate_1'] = $Qry1->fieldByName("Week_Day_Rate_1");
				$_POST['Week_Day_Rate_2'] = $Qry1->fieldByName("Week_Day_Rate_2");
				$_POST['Week_Day_Rate_3'] = $Qry1->fieldByName("Week_Day_Rate_3");
				$_POST['Week_End_Band_1'] = $Qry1->fieldByName("Week_End_Band_1");
				$_POST['Week_End_Band_2'] = $Qry1->fieldByName("Week_End_Band_2");
				$_POST['Week_End_Rate_1'] = $Qry1->fieldByName("Week_End_Rate_1");
				$_POST['Week_End_Rate_2'] = $Qry1->fieldByName("Week_End_Rate_2");
				$_POST['Week_End_Rate_3'] = $Qry1->fieldByName("Week_End_Rate_3");
         }else
         
            $Message .= "\\nFail to Get Detail<br>\n";
         
      }
	}

}

//=================== Update Changes into DB ====================
function update_changes()
{
   // --- Add new Discount to databases ---
		global $Message, $Qry1, $Error,$pass;
		$Error = false;
		$RateCode = $_POST['RateCode'];
		$SourceID = $_POST['SourceID'];
		$Description = $_POST['Description'];
		$AmtPerCharge = $_POST['AmtPerCharge'];
		$EffStartDT =preg_replace("/[^a-zA-Z0-9\s]/", "",$_POST['EffStartDT']);
		$EffEndDT = preg_replace("/[^a-zA-Z0-9\s]/", "",$_POST['EffEndDT']);
		$AmountCharge = $_POST['AmountCharge'];
		$LocalCode=$_POST['LocalCode'];
		$PortCode=$_POST['PortCode'];
		$Speed = $_POST['Speed'];
		$FirstBlock = $_POST['FirstBlock']; 
		$SubBlock = $_POST['SubBlock'];
		$AmtPerHour = $_POST['AmtPerHour'];
		$Label=$_POST['Label'];
		$WDB1ChargeBlockID=$_POST['WDB1ChargeBlockID'];
		$WDB2ChargeBlockID=$_POST['WDB2ChargeBlockID'];
		$WDB3ChargeBlockID=$_POST['WDB3ChargeBlockID'];
		$WEB1ChargeBlockID=$_POST['WEB1ChargeBlockID'];
		$WEB2ChargeBlockID=$_POST['WEB2ChargeBlockID'];
		$WEB3ChargeBlockID=$_POST['WEB3ChargeBlockID'];
		$Setup_Fee=$_POST['Setup_Fee'];
		$Start_Week_Day=$_POST['Start_Week_Day'];
		$End_Week_Day=$_POST['End_Week_Day'];
		$Start_Week_Time=$_POST['Start_Week_Time'];
		$End_Week_Time=$_POST['End_Week_Time'];
		$Week_Day_Band_1=$_POST['Week_Day_Band_1'];
		$Week_Day_Band_2=$_POST['Week_Day_Band_2'];
		$Week_Day_Rate_1=$_POST['Week_Day_Rate_1'];
		$Week_Day_Rate_2=$_POST['Week_Day_Rate_2'];
		$Week_Day_Rate_3=$_POST['Week_Day_Rate_3'];
		$Week_End_Band_1=$_POST['Week_End_Band_1'];
		$Week_End_Band_2=$_POST['Week_End_Band_2'];
		$Week_End_Rate_1=$_POST['Week_End_Rate_1'];
		$Week_End_Rate_2=$_POST['Week_End_Rate_2'];
		$Week_End_Rate_3=$_POST['Week_End_Rate_3'];
		
   if(!$Error)
   {
   if( $_SESSION['pass']=="incoming"){
    $Qry1->text ="INSERT INTO incomingrate(SourceID,EffStartDT,EffEndDT,AmountCharge,Description) VALUES('$SourceID','$EffStartDT','$EffEndDT','$AmountCharge','$Description')";
	$Qry1->execSQL(); 
	
	$url = 'rateplan.php?RateCode='.$_POST['RateCode']; 
     header("Location: $url"); 
     exit();
	 }
   if( $_SESSION['pass']=="local"){
    $Qry1->text ="INSERT INTO localcallrate(EffStartDT,
							EffEndDT,
							Label,
							WDB1ChargeBlockID,
							WDB2ChargeBlockID,
							WDB3ChargeBlockID,
							WEB1ChargeBlockID,
							WEB2ChargeBlockID,
							WEB3ChargeBlockID,
							Setup_Fee,
							Start_Week_Day,
							End_Week_Day,
							Start_Week_Time,
							End_Week_Time,
							Week_Day_Band_1,
							Week_Day_Band_2,
							Week_Day_Rate_1,
							Week_Day_Rate_2,
							Week_Day_Rate_3,
							Week_End_Band_1,
							Week_End_Band_2,
							Week_End_Rate_1,
							Week_End_Rate_2,
							Week_End_Rate_3	) VALUES('$EffStartDT',
													'$EffEndDT',
													'$Label',
													'$WDB1ChargeBlockID',
													'$WDB2ChargeBlockID',
													'$WDB3ChargeBlockID',
													'$WEB1ChargeBlockID',
													'$WEB2ChargeBlockID',
													'$WEB3ChargeBlockID',
													'$Setup_Fee',
													'$Start_Week_Day',
													'$End_Week_Day',
													'$Start_Week_Time',
													'$End_Week_Time',
													'$Week_Day_Band_1',
													'$Week_Day_Band_2',
													'$Week_Day_Rate_1',
													'$Week_Day_Rate_2',
													'$Week_Day_Rate_3',
													'$Week_End_Band_1',
													'$Week_End_Band_2',
													'$Week_End_Rate_1',
													'$Week_End_Rate_2',
													'$Week_End_Rate_3')";
	$Qry1->execSQL(); 
	
	  $url = 'rateplan.php?LocalCode='.$_POST['LocalCode']; 
      header("Location: $url"); 
     exit();
	 }
    if( $_SESSION['pass']=="port"){
    $Qry1->text ="INSERT INTO portrate(SourceID,Speed,EffStartDT,EffEndDT,FirstBlock,SubBlock,AmtPerHour) VALUES('$SourceID','$Speed','$EffStartDT','$EffEndDT','$FirstBlock','$SubBlock','$AmtPerHour')";
	$Qry1->execSQL(); 
	$url = 'rateplan.php?PortCode='.$_POST['PortCode']; 
     header("Location: $url"); 
     exit();
	 }
   if($RateCode!=null){
   
      $Qry1->text = "UPDATE incomingrate set SourceID = '$SourceID',
                                         EffStartDT = '$EffStartDT',
										 EffEndDT = '$EffEndDT',
										 AmountCharge = '$AmountCharge',
										 Description = '$Description'
                                   WHERE RateCode ='$RateCode'";      
					
										 
      $Qry1->execSQL(); 
//die($Qry1->text );
	$url = 'rateplan.php?RateCode='.$_POST['RateCode']; 
     header("Location: $url"); 
     exit();
   }
   
  if($LocalCode!=null){
      $Qry1->text = "UPDATE localcallrate set EffStartDT  = '$EffStartDT',
                                         EffEndDT = '$EffEndDT',
                                         Label = '$Label',
										 WDB1ChargeBlockID = '$WDB1ChargeBlockID',
										 WDB2ChargeBlockID = '$WDB2ChargeBlockID',
										 WDB3ChargeBlockID = '$WDB3ChargeBlockID',
										 WEB1ChargeBlockID = '$WEB1ChargeBlockID',
										 WEB2ChargeBlockID = '$WEB2ChargeBlockID',
										 WEB3ChargeBlockID = '$WEB3ChargeBlockID',
										 Setup_Fee='$Setup_Fee',
										 Start_Week_Day='$Start_Week_Day',
										End_Week_Day='$End_Week_Day',
										Start_Week_Time='$Start_Week_Time',
										End_Week_Time='$End_Week_Time',
										Week_Day_Band_1='$Week_Day_Band_1',
										Week_Day_Band_2	='$Week_Day_Band_2',
										Week_Day_Rate_1	='$Week_Day_Rate_1',
										Week_Day_Rate_2	='$Week_Day_Rate_2',
										Week_Day_Rate_3='$Week_Day_Rate_3',
										Week_End_Band_1='$Week_End_Band_1',
										Week_End_Band_2='$Week_End_Band_2',
										Week_End_Rate_1='$Week_End_Rate_1',
										Week_End_Rate_2='$Week_Day_Rate_2',
										Week_End_Rate_3	='$Week_Day_Rate_3'
				 WHERE LocalCode  = '$LocalCode'";
										 
										
										 
      $Qry1->execSQL();
   
      $Message .= "\\nRate changes saved";
	  $url = 'rateplan.php?LocalCode='.$_POST['LocalCode']; 
      header("Location: $url"); 
     exit();
	  
   }
  if($PortCode!=null){
      $Qry1->text = "UPDATE portrate set SourceID   = '$SourceID',
                                         Speed = '$Speed',
                                         EffStartDT = '$EffStartDT',
										 EffEndDT = '$EffEndDT',
										 FirstBlock = '$FirstBlock',
										 SubBlock = '$SubBlock',
										 AmtPerHour='$AmtPerHour'
										 WHERE PortCode ='$PortCode'";
										
										 
      $Qry1->execSQL();
     
	  $url = 'rateplan.php?PortCode='.$_POST['PortCode']; 
      header("Location: $url"); 
      exit();
   }
}

}
function action_bar()
{

print<<<END
      <div style="position: absolute; height: 29; width: 100%; background-color:#B2B2D5;">
         <div style="position: absolute; top: 5; left: 25; ">
            <input class="ButtonA" type="submit" name="ActFlag" value="Remove" onClick="return DoCancel()">
         </div>
         <div style="position: absolute; top: 5; left: 125; ">
            <input class="ButtonA" type="submit" name="ActFlag" value="Edit">
         </div>
      </div>
<table cellpadding="3" cellspacing="1" ><tr><td>
   </td></tr>
</table>
END;
}

function save_action_bar()
{
print<<<END
      <div style="position: absolute; height: 29; width: 100%; background-color:#B2B2D5;">
         <div style="position: absolute; top: 5; left: 25; ">
            <input class="ButtonA" type="submit" name="ActFlag" value="Save">
			<input class="ButtonA" type="submit" name="ActFlag" value="Cancel">
         </div>
      </div>
	  
<table cellpadding="3" cellspacing="1" ><tr><td>
   </td></tr>
</table>

END;
}

function get_title()
{
   global $PageTitle;

   $dbMain = odbc_connect(DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);

   $Page = $_SERVER['PHP_SELF'];
   $tok = strtok($Page,"/");

   while ($tok) {
      $last = $tok;
      $tok = strtok("/");
      if(!$tok)
        break;
   }
   $Page = $last;

   $textSQL = sprintf("SELECT Description FROM FileAccessPrivilege WHERE FileName = '%s'", $Page);
   $result = odbc_do($dbMain, $textSQL);
   if( odbc_fetch_row($result, 1) )
   {
      $PageTitle = odbc_result($result, "Description");
   }
}

function backPage()
{
   // --- Add new Discount to databases ---
		global $Message, $Qry1, $Error,$pass;
		$Error = false;
		$RateCode = $_POST['RateCode'];
		$LocalCode = $_POST['LocalCode'];
		$PortCode = $_POST['PortCode'];
		$SourceID = $_POST['SourceID'];
		$Description = $_POST['Description'];
		$AmtPerCharge = $_POST['AmtPerCharge'];
		$EffStartDT =preg_replace("/[^a-zA-Z0-9\s]/", "",$_POST['EffStartDT']);
		$EffEndDT = preg_replace("/[^a-zA-Z0-9\s]/", "",$_POST['EffEndDT']);
		$AmountCharge = $_POST['AmountCharge'];
		$Speed = $_POST['Speed'];
		$FirstBlock = $_POST['FirstBlock']; 
		$SubBlock = $_POST['SubBlock'];
		$AmtPerHour = $_POST['AmtPerHour'];
		$Label=$_POST['Label'];
		$WDB1ChargeBlockID=$_POST['WDB1ChargeBlockID'];
		$WDB2ChargeBlockID=$_POST['WDB2ChargeBlockID'];
		$WDB3ChargeBlockID=$_POST['WDB3ChargeBlockID'];
		$WEB1ChargeBlockID=$_POST['WEB1ChargeBlockID'];
		$WEB2ChargeBlockID=$_POST['WEB2ChargeBlockID'];
		$WEB3ChargeBlockID=$_POST['WEB3ChargeBlockID'];
		$Setup_Fee=$_POST['Setup_Fee'];
		$Start_Week_Day=$_POST['Start_Week_Day'];
		$End_Week_Day=$_POST['End_Week_Day'];
		$Start_Week_Time=$_POST['Start_Week_Time'];
		$End_Week_Time=$_POST['End_Week_Time'];
		$Week_Day_Band_1=$_POST['Week_Day_Band_1'];
		$Week_Day_Band_2=$_POST['Week_Day_Band_2'];
		$Week_Day_Rate_1=$_POST['Week_Day_Rate_1'];
		$Week_Day_Rate_2=$_POST['Week_Day_Rate_2'];
		$Week_Day_Rate_3=$_POST['Week_Day_Rate_3'];
		$Week_End_Band_1=$_POST['Week_End_Band_1'];
		$Week_End_Band_2=$_POST['Week_End_Band_2'];
		$Week_End_Rate_1=$_POST['Week_End_Rate_1'];
		$Week_End_Rate_2=$_POST['Week_End_Rate_2'];
		$Week_End_Rate_3=$_POST['Week_End_Rate_3'];
		
   if(!$Error)
   {
   if(( $_SESSION['pass']=="incoming")||($_POST['RateCode']!=null)){
   print"1";
	$url = 'rateplan.php?RateCode='.$_POST['RateCode']; 
     header("Location: $url"); 
     exit();
	 }
   if( ($_SESSION['pass']=="local")||($_POST['LocalCode']!=null)){
    $url = 'rateplan.php?LocalCode='.$_POST['LocalCode']; 
      header("Location: $url"); 
     exit();
	 }
    if(( $_SESSION['pass']=="port")||($_POST['PortCode']!=null)){
	$url = 'rateplan.php?PortCode='.$_POST['PortCode']; 
     header("Location: $url"); 
     exit();
	 }
  
   
}

}
?>

Edited by sinyi: n/a

0

you can not use php tags inside php code
AT line number 171 CHANGE <?PHP TO END;

AT Line number 188 change ?> to print <<<END

0

Thanks.no error already but the drop down list is empty and the other contents below 'Source'are also gone.Why?

0

Cool Let try this code and be happy!

<select name="select">
<?php
	$host = "localhost"; 
	$user = "root"; 
	$pass = ""; 
	$db = "testdb"; 
	$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 
	mysql_select_db($db) or die ("Unable to select database!"); 
	$query = "SELECT country FROM symbols";
	$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
	
	print("<option select value=\"0\">Select any Option</option>");
	
	if (mysql_num_rows($result) > 0) { 
		 while ($row = mysql_fetch_row($result)) {
			if($row[0]=='India')$dtext = "selected";
			else $dtext = "";
			print("<option $dtext value=\"$row[0]\">$row[0]</option>");
		 }
	}
	else { 
      echo "No rows found!"; 
	} 
	mysql_free_result($result);
	mysql_close($connection);
?>

Just change your query according to your subject! Tested..

0

Sorry.I am new for php.I don't know how to change.

0

You try to run your <select> </select> code in separte php file. see whether there list box is loading properly.

Output may have stoped due to some error in accessing $Qry1 object/

0

Just replace this code within your <td>MY CODE</td> Change your sql username, host and password, change the table name and field to retrieve. Just implement the code and tell me what is happening?

0

Still empty also when i put in nother page,and will cause other contents gone also

0

place following lines in the begining of the page after first <?php tag.

error_reporting(E_ALL); 
ini_set("display_errors", 1);

when you run it will show so many warning and error messages. look what is the last error message. post that error message here.

Edited by urtrivedi: n/a

0

do you attach your files?

Ya...posted at the first page.I already replace with your code,there is a empty drop down list but it print out all the text from sql statement 'SELECT...

0

place following lines in the begining of the page after first <?php tag.

error_reporting(E_ALL); 
ini_set("display_errors", 1);

when you run it will show so many warning and error messages. look what is the last error message. post that error message here.

this is the last error message

Notice: A session had already been started - ignoring session_start() in D:\Webroot\TM\header.php on line 6

0

The text within the database retrieved and displayed in your drop down list, that is what you want right?

Ya.And when the value same with the post value from another page,the value will be selected.

0
if($row[0]==$_POST['$sourceid'])$dtext = "selected";

Here you have the code for that! slightly change your code and get selected the value.

0
if($row[0]==$_POST['$sourceid'])$dtext = "selected";

Here you have the code for that! slightly change your code and get selected the value.

Sorry for bother again.still gt error on the line after replacing with the statement above:


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Webroot\TM\editData.php on line 188

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.