My script is not working on php 5 version??

Discussion in 'PHP' started by extra, Feb 19, 2008.

  1. #1
    my script is working fine in php4 version, when i have upgraded it to php 5..it is not longer working !!.When i try to go to this page "process_report.php, it always auto directing to my second page "report.php ". this is my script

    please someone to look what is the problem in my script

    
    
    <?
    session_start();
    $sid=session_id();
    
    if(strcmp ($_SESSION["SID"], $sid))
    {
            $_SESSION["MSG"]="Invalid Session ID!!";
            Header("Location: login.php");
    }
    
    include "header.php";
    include "function.php";
    
    $msg = $_SESSION["MSG"];
    //echo "MSG=".$msg;
    
    if(isset($_POST["ProcessData"]))
    {
    	if(!isset($_POST["DateFrom"]) || !isset($_POST["DateTo"]))
    		$_SESSION["MSG"] = "Please select the date!";
    	else
    	{	$year = $_POST["year"];
    		$DateFrom = $_POST["DateFrom"];
    		$DateTo = $_POST["DateTo"];
    		$_SESSION["YR"] = $year;
    		$_SESSION["MONTHFROM"] = $DateFrom;
    		
    		$error = FALSE;
    		if($DateTo < $DateFrom)
    			$error = TRUE;
    		else
    		{
    			for($i=$DateFrom; $i<=$DateTo; $i++)
    			{
    				for($j=1; $j<=31; $j++)
    				{	
    					
    					$ReadDate = $j."-".$i."-".$year;
    					$ReadDate=ddmmyyyy($ReadDate);
    					//echo "ReadDate->". $ReadDate;
    					$db_date = date_format($ReadDate);	
    					$today=date("Y-m-d");
    					$valid = mysql_query("SELECT status FROM datelist WHERE date='$db_date'");
    					$svalid = mysql_fetch_assoc($valid);
    					$v_status = $svalid["status"];
    					mysql_free_result($valid);
    					//echo "stat->".$v_status;	
    					if($v_status==1)
    						echo "";
    					elseif($v_status==2)
    					{
    					  $sql = mysql_query("DELETE FROM charge WHERE datein='$db_date'");
    					  $ReadFile = $ReadDate.".txt";
    					  $status = insert_conf($ReadFile);
    					  $status=1;
    					  if($today==$db_date) $status=2;
    					  $sql = "UPDATE datelist SET status='$status' WHERE date='$db_date'";
    					  query_db($sql);
    
    					}
    					elseif(is_null($v_status))
    					{
    					  $ReadFile = $ReadDate.".txt";
    					  $status = insert_conf($ReadFile);
    					  //echo " ->status-".$status."<br>";
    					  if($status==1)
    					  {
    					    if($today==$db_date) $status=2;
    					    $sql = "INSERT INTO datelist VALUES('$db_date','$status')";
    					    query_db($sql);
    					  }
    					 
    					}
    					
    										
    				}
    			}
    		}		
    	}
    	
    
    }
    
    $_SESSION["PD"] = 1;
    Header("Location: report.php");
    
    ?>
    
    
    <table width="75%" border="0">
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="2"><h2>Process Data</h2></td>
      </tr>
      <tr> 
        <td width="23%">&nbsp;</td>
        <td width="59%">&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="2">Please select the date in order to process the data.</td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="2" valign="top">
    <form action="process_data.php" method="post" name="process_date" id="process_date">
            <table width="87%" border="0">
              <tr> 
                <td width="25%"><strong><font size="2">Month From</font></strong></td>
                <td width="1%">&nbsp;</td>
                <td width="74%"><select name="DateFrom" id="DateFrom">
                    <option value="1" selected>Jan</option>
                    <option value="2">Feb</option>
                    <option value="3">Mar</option>
                    <option value="4">Apr</option>
                    <option value="5">May</option>
                    <option value="6">June</option>
                    <option value="7">July</option>
                    <option value="8">Aug</option>
                    <option value="9">Sept</option>
                    <option value="10">Oct</option>
                    <option value="11">Nov</option>
                    <option value="12">Dec</option>
                  </select></td>
              </tr>
              <tr> 
                <td><strong><font size="2">Month To</font></strong></td>
                <td>&nbsp;</td>
                <td><select name="DateTo" id="DateTo">
                    <option value="1" selected>Jan</option>
                    <option value="2">Feb</option>
                    <option value="3">Mar</option>
                    <option value="4">Apr</option>
                    <option value="5">May</option>
                    <option value="6">June</option>
                    <option value="7">July</option>
                    <option value="8">Aug</option>
                    <option value="9">Sept</option>
                    <option value="10">Oct</option>
                    <option value="11">Nov</option>
                    <option value="12">Dec</option>
                  </select></td>
              </tr>
              <tr>
                <td><strong><font size="2">Year</font></strong></td>
                <td>&nbsp;</td>
                <td><select name="year">
                    <option value="2005">2005</option>
                    <option value="2006">2006</option>
                    <option value="2007">2007</option>
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                  </select></td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td><input name="ProcessData" type="submit" id="ProcessData" value="ProcessData"></td>
              </tr>
            </table>
          </form></td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    
    
    
    <?
    include "footer.php";
    ?>
    
    
    
    PHP:

     
    extra, Feb 19, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Isn't it supposed to go there...? I mean, you do have this:

    Header("Location: report.php");

    right before it outputs the table with the form...
     
    zerxer, Feb 19, 2008 IP
  3. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Instaed of this <? use this <?php

    I think this is the problem in your script. Try this and let me know.

    Thanks,
    Subikar
     
    Subikar, Feb 20, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    ^ if that was the case, the PHP code wouldn't be executed at all. But PHP is redirecting, which means it's being parsed and executed.

    Anyway, as Zerxer said, you have the header() redirect there. According to the code, it should redirect. What happened when you had PHP 4?
     
    nico_swd, Feb 20, 2008 IP
  5. keyspy

    keyspy Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You must replace <? ?> with <?php ?>. I tried.
     
    keyspy, Feb 20, 2008 IP
  6. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I fail to see how that would make any difference unless he does not have XML-style PHP tags enabled on his server, in which case the code would not properly execute anyways as nico_swd pointed out.
     
    zerxer, Feb 20, 2008 IP
  7. !Redghost!

    !Redghost! Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    maby work ..
    i hav this promelom
     
    !Redghost!, Apr 25, 2008 IP