Jump to content

Script runs local but remote doesn't


fluidsharp

Recommended Posts

Hi all,

I have two issue with script.

1. It works in PhpEd and with apache but doesn't work at remote server with apache.

    Error is well known -  "Warning: Cannot modify header information - headers already sent "

 

2. when I added more than 20 records like $var = $_POST['var']; it stops work local. Error is same.

 

 

adminka_wrapp.php

<?php
$addFormatName = $_POST['addFormatName'];
$addFormatDes  = $_POST['addFormatDes'];
$page               = $_GET['page'];


if (isset($addFormatName) && isset($addFormatDes))
  {
      $page = 'add_formats';
  } else if ($page == NULL)
    {
        $page =  "user_access_log";
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="../style/adminkaview.css">        
    </head>
    <body>
        <div class="col-wrap1">
            <div class="col-wrap2">
                <div class="col1">
                    <div class="content" id="c1">
                        <p><a href="?page=view_add_format">Format and extensions</a></p>
                    </div>
                </div>
                <div class="col2">
                    <div class="content" id="c2">
<?php require("$page.php");?>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </body>
</html>

 

view_add_format.php

<?php
require_once "../function.php"; 

$q = connect("SELECT
                      `formats`.*
              FROM
                       `xxx`.`formats` 
            ");
echo "<form method='post' action='adminka_wrapp.php'>
     <table>
            <tr>
                <td>id</td>
                <td>Formats Name</td>
                <td>Description</td>
            </tr>";             
  while($rowResult = $q->fetch_assoc())
  {
    echo "<tr>";  
    $id            = $rowResult["id"];  
    $formatName    = $rowResult["f_name"];  
    $description   = $rowResult["description"];
    echo    "<td>".$id."</td>"
           ."<td>".$formatName."</td>"
           ."<td>".$description."</td>";
    echo "</tr>";
  }
  
echo " <tr>
           <td>
               <input type='submit' value='AddFormat' name='submitAddFormat'>
           </td>
           <td>
                <input type='text' name='addFormatName' maxlength='20' size='5'>
            </td>
            <td>
                <input type='text' name='addFormatDes' maxlength='20' size='5'>
            </td>    
                ";                
echo "</table>
      </form>";          
?>

 

add_formats.php

<?php
require "../function.php"; 

  if (isset($addFormatName) && isset($addFormatDes) )
{
   
        $q  = connect("INSERT INTO  
                                   `xxx`.`formats`     
                                   (`id`
                                   ,`f_name`
                                   ,`description`
                                   )
                       VALUE
                                   (NULL
                                   ,'$addFormatName'
                                   ,'$addFormatDes'
                                   )               
                   ");   
        header("Location: adminka_wrapp.php?page=view_add_format");
        exit();     
}
?>

 

function.php

<?php
function connect($query)
{
  $db = new mysqli('127.0.0.1', 'xxx', 'xxx', 'xxx');
  if (mysqli_connect_errno()) 
     {
         printf("Connect failed: %s\n", mysqli_connect_error());
         exit();
     }
$result = $db->query($query);
$db->close();
return $result;   
}
?>

Link to comment
https://forums.phpfreaks.com/topic/235676-script-runs-local-but-remote-doesnt/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.