troubleshooting Question

This error driving me crazy :(

Avatar of team2005
team2005 asked on
HTMLPHP
12 Comments1 Solution1273 ViewsLast Modified:
Hi!

I making a PDF file, but get this error message:

PHP Fatal error:  Cannot redeclare class mPDF in C:\DWASFiles\Sites\AgressionTestMysql\VirtualDirectory0\site\wwwroot\mssql\Reports\MPDF\mpdf.php on line 67


<?php
include_once("../mpdf.php");
require_once('Connect_databse.php');

ini_set('memory_limit', '256M');

session_start();


$table3='Reportform';
$table4 = 'P_SHOW_Transactions';


//$mpdf=new mPDF('c');
$mpdf=new mPDF('win-1252', 'A4', 11, 'DejaVuSansCondensed', 15, 15, 15, 15, 8, 8);
$mpdf->mirrorMargins = 0; // Use different Odd/Even headers and footers and mirror margins
$mpdf->defaultheaderfontsize = 10; /* in pts */
$mpdf->use_kwt = true;
$mpdf->keep_table_proportions = true;
$mpdf->shrink_tables_to_fit=1;
$mpdf->debug = true;
$mpdf->defaultheaderfontstyle = B; /* blank, B, I, or BI */
$mpdf->defaultheaderline = 1; /* 1 to include line below header/above footer */
$mpdf->defaultfooterfontsize = 10; /* in pts */
$mpdf->defaultfooterfontstyle = B; /* blank, B, I, or BI */
$mpdf->defaultfooterline = 1; /* 1 to include line below header/above footer */
$mpdf->SetHeader('{DATE j-m-Y}||Agreppa Report');
$mpdf->SetFooter('Side:{PAGENO}'); /* defines footer for Odd and Even Pages - placed at Outer margin */
$mpdf->SetFooter(array(
'L' => array(
'content' => 'Text to go on the left',
'font-family' => 'sans-serif',
'font-style' => 'B', /* blank, B, I, or BI */
'font-size' => '10', /* in pts */
),
'C' => array(
'content' => '- {PAGENO} -',
'font-family' => 'serif',
'font-style' => 'BI',
'font-size' => '18', /* gives default */
),
'R' => array(
'content' => 'Printed @ {DATE j-m-Y H:m}',
'font-family' => 'monospace',
'font-style' => '',
'font-size' => '10',
),
'line' => 1, /* 1 to include line below header/above footer */
), 'E' /* defines footer for Even Pages */
);





$html = '
<html>
<head>
<meta charset="utf-8" />
<style>
table.testtabell
{
    border:1px solid #cccccc;
  border-collapse: collapse;
  font-family: Verdana;
  font-size: 20px;
  margin-right: 15px;
}
.rapport2_header
{
    background-color: #efefef;
    border:1px solid #cccccc;
  color:#cccccc;
  font-size: 15px;
  font-family: Verdana;
  border-collapse: collapse;
    box-shadow: none ! important;
  padding-left:10px;
  padding-top:10px;
}
.rapport1_del8
{
   border:1px solid #cccccc;
   border-collapse: collapse;
   box-shadow: none ! important;
   padding-left:10px;
   padding-top:10px;
   font-size:12px;
   color:#b2b3c3;
}

.rapport1_del9
{
   border:1px solid #cccccc;
   border-collapse: collapse;
   box-shadow: none ! important;
   padding-left:10px;
   padding-bottom:8px;
   font-size:12px;
   color:#b2b3c3;
}

.rapport1_del1
{
    background-color: #efefef;
    border:0px solid #cccccc;
  border-collapse: collapse;
    box-shadow: none ! important;
  padding-left:10px;
}
.rapport1_del2
{
   background-color: #f8f8f8;
   border-left:0px solid #cccccc;
   border-bottom:1px solid #cccccc;
   border-right:0px solid #cccccc;
   border-collapse: collapse;
   padding-left:10px;
}
.rapport_brukernavn
{
   background-color: #f8f8f8; 
   border-right:1px solid #cccccc;
   border-left:0px solid #cccccc;
   border-bottom:1px solid #cccccc;
   border-collapse: collapse;
   padding-right:10px;
   font-family: Verdana;
   font-size: 11px;
   color:#cccccc;
   text-align:right;
}
.blank_row_noborder {
  height: 20px !important;
  background-color: #FFFFFF;
}
.blank_row {
  height: 20px !important;
  background-color: #FFFFFF;
  border-bottom: 1px solid #cccccc; /* or whatever specific values you prefer */
}
.rapport1_del3
{
   background-color: #ffffff;
   font-size:12px;
    border:0px solid #cccccc;
   border-collapse: collapse;
   box-shadow: none ! important;
}
.rapport_image1
{
   background-color: #ffffff;
   border: none ! important;
   box-shadow: none ! important;
   padding-right:10px;
}
IMG.displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
</style>

</head>

<body>
';


$brukerID = $_GET["brukerID"];
$kundeid = $_GET["kundeid"];


echo "MERKE1";
die();


$sql = "SELECT * FROM {$table3} WHERE UserID={$brukerID} and Organisation={$kundeid}";
$resultraptmp = sqlsrv_query($conn,$sql); 

// Hent parametere som er valgt for utvalget til rapporten
while($row3 = sqlsrv_fetch_array($resultraptmp)){

      $datofra = $row3['Datefrom'];
      $datotil = $row3['Dateto'];
      $kontr = $row3['Controllername'];
      $brukere = $row3['Username'];
      $svarsp = $row3['Answer'];
      $vilkenrapport = $row3['Report'];
      $organisasjon = $row3['OrganisationName'];
      $antsider = $row3['Pages'];
      $rec_count = $row3['Numberrecords'];
      $antrader = $row3['NumRows'];
      $datobrukes = 1;
      $side = $row3['Page'];

} 

if ($vilkenrapport=="Enkel rapport"){    
$html .= '<table width="100%" align="left" class="testtabell">'; 
$html .= '<tr>';
$html .= '<th class="rapport2_header" height="40px" align="left">Kontroller</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Lokasjon</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Dato</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Spørsmål</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Svar</th>';
      
$html .= '</tr>';  
}  
     

$sql = "SELECT Name,ControlName,LocationID,Location,ControlID,Organisation,Question,Note,CreatedDate,Answer,UserID,IsScale,Object,TransactionID,Organisationname FROM {$table4}";


$sql = $sql." Where CreatedDate between '{$datofra}' AND '{$datotil}'";


$substr = "Alle kontrollere";
if (strpos($kontr, $substr) === false) {
  $sql = $sql." and ControlName='{$kontr}'";
}

$substr = "Alle brukere";
if (strpos($brukere, $substr) === false) {

  
  // Hent UserID    
   $tsql_callSP = "{call GET_UserID( ?, ?)}";
   $params = array( 
                 array($brukere, SQLSRV_PARAM_IN),
                 array($brID, SQLSRV_PARAM_INOUT)
               );

/* Execute the query. */
   $stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params);
   if( $stmt3 === false )
   {
       echo "Error in executing statement 1.\n";
       die( print_r( sqlsrv_errors(), true));
   }
   else
   {sqlsrv_free_stmt( $stmt3);}


  $sql = $sql." and UserID='{$brID}'";
}

if ($svarsp=="Ja"){
  $sql = $sql." and Answer='Ja'";
}

if ($svarsp=="Nei"){
  $sql = $sql." and Answer='Nei'";
}

if ($svarsp=="Avvik"){
  $sql = $sql." and Answer='Avvik'";
}

if ($svarsp=="Scale"){
  $sql = $sql." and Answer<>'Ja' and Answer<>'Nei' and Answer<>'Avvik' ";
}
  
$sql = $sql." and Organisationname='{$organisasjon}'";

$sql = $sql." ORDER BY ControlID,CreatedDate";

$retval = sqlsrv_query($conn,$sql); 

if( $retval === false )
{
       echo "Error in executing statement 12.\n";
       die( print_r( sqlsrv_errors(), true));
}

$TMP_KID=0;
$forstekontroller = 1;
$TMP_LOK=0;
$farge1="#ffffff";
$farge2="#d9eefa";
$valgfarge="#ccc";
$byttfarge = 1;
$antrader=1;
$antraderMAX= 20;



while($row3 = sqlsrv_fetch_array($retval)){
   
   $kontrollernavn = $row3['ControlName'];
   $lokasjonnr = $row3['LocationID'];
   $K_ID = $row3['ControlID'];
   $kunde_ID = $row3['Organisation'];
   $lokasjonnavn = $row3['Location']; 
   $sporsmal = $row3['Question'];
   $kommentar = $row3['Note'];
   $transdato = $row3['Location'];
   $svar = $row3['Answer']; 
   $usID = $row3['UserID'];  
   $scaleant = $row3['IsScale'];
   $bilderef="";     // Midligtidig satt til blank
   $brukernavn= $row3['Name'];

if ($vilkenrapport=="Enkel rapport"){  
    
    
$html .= '<tr>';
                                                     
if ($byttfarge==1){
   $valgfarge=$farge2;
   $byttfarge=2;
}
else
{ 
   $byttfarge=1;
   $valgfarge=$farge1;
}   

$html .= '<td class="rapport1_del8" bgcolor=' . $valgfarge . ' align="left">' . $kontrollernavn . '</td>'; 
$html .= '<td class="rapport1_del8" bgcolor=' . $valgfarge . ' align="left">' . $lokasjonnavn .'</td>';
$html .= '<td class="rapport1_del8"  bgcolor=' . $valgfarge . ' align="left">'. $transdato .'</td>';
$html .= '<td class="rapport1_del8"  bgcolor=' . $valgfarge . ' align="left">'. $sporsmal .'</td>'; 
      
if($svar=="Ja"){ 
   $html .= '<td colspan="2" class="rapport1_del9"  bgcolor=' . $valgfarge . ' align="left">' . $svar . '<img class="bildeviser" src="../../../images/jasvar.png" alt="Smiley face"></td>';
}

if($svar=="Nei"){ 
   $html .= '<td class="rapport1_del9"  bgcolor=' . $valgfarge . ' align="left">' . $svar . '<img class="bildeviser" src="../../../images/neisvar.png" alt="Smiley face"></td>';
}

 if($svar<>"Ja" and $svar<>"Nei"){
   $html .= '<td class="rapport1_del9"  bgcolor=' . $valgfarge . ' align="left">' . $svar . '<img class="bildeviser" src="../../../images/scale.png" alt="Smiley face"></td>';
}


}    
     
if ($vilkenrapport=="Standard rapport"){   
   
   if ($forstekontroller==1)
    {
       $forstekontroller=0;
     $TMP_KID = $K_ID;
     $TMP_LOK = $lokasjonnr;
     
        $html .='<table width="100%" align="center" class="testtabell"  style="page-break-inside:avoid">'; 
    $html .='<tr>';
    $html .='<td class="rapport1_del1" height="40px" colspan="4">' . $kontrollernavn .'</td>';
    $html .='</tr>';
    $html .='<tr>';
      $html .='<td class="rapport1_del2" colspan="3" height="40px">' . $lokasjonnavn . '</td>';
        $html .='<td class="rapport_brukernavn" >' . $brukernavn .'</td>';      
      $html .='</tr>';

    }
  

  
   if ((($TMP_KID<>$K_ID) or ($TMP_LOK<>$lokasjonnr)) and $forstekontroller==2)
   {
      if ($TMP_KID<>$K_ID) {$TMP_KID = $K_ID;}
    if ($TMP_LOK<>$lokasjonnr) {$TMP_LOK = $lokasjonnr;}
        $html .='</table>';
        $html .='<table width="100%" align="center" class="testtabell" style="page-break-inside:avoid">'; 
    $html .='<tr>';
    $html .='<td class="rapport1_del1" colspan="4" height="40px">' . $kontrollernavn . '</td>';
    $html .='</tr>';
    $html .='<tr>';
      $html .='<td class="rapport1_del2" colspan="3" height="40px">' . $lokasjonnavn .'</td>';
    $html .='<td class="rapport_brukernavn">' . $brukernavn .'</td>';
      $html .='</tr>';   
  
   }
   
    $html .='<tr class="blank_row_noborder">';
    $html .='<td colspan="4"></td>';
    $html .='</tr>';  
  
  $html .='<tr>';  
  $html .='<td  class="rapport1_del3" align="right" valign="top" width="120px"> Sporsmål: </td>';
  $html .='<td class="rapport1_del3" valign="top" width="380px">' . $sporsmal . '</td>';
    
  if ($bilderef=="")
    { 
    $html .='<td class="rapport1_del3" valign="top"></td>';
      $html .='<td valign="top" class="rapport_image1" rowspan="4"><img src="../../../images/ingen.png" height="160" width="150px" /></td>';
  }
  else
  {
    $html .='<td class="rapport1_del3" valign="top"></td>'; 
    $html .='<td valign="top" class="rapport_image1" rowspan="4"><img src="../../../uploads/' . $bilderef .'" height="160" width="150px" /></td>';
    }
  $html .='</tr>';  
  $html .='<tr>';
  $html .='<td  class="rapport1_del3" align="right" valign="top" width="120px"> Dato: </td>'; 
  $html .='<td  class="rapport1_del3" valign="top" width="380px">' . $transdato .'</td>';
  $html .='<td class="rapport1_del3" valign="top"></td>';
  $html .='</tr>';
  
  $html .='<tr>'; 
  $html .='<td  class="rapport1_del3" align="right" valign="top" width="120px"> Svar:</td>'; 
     
      if (($svar=="Ja") or ($svar=="Nei"))
    { 
         $html .='<td  class="rapport1_del3" valign="top" width="380px">' . $svar .'</td>';
    
    }
    else {
    
       $html .='<td  class="rapport1_del3" valign="top" width="380px">' . $svar . ' av ' . $scaleant .'</td>';
     }
  $html .='<td class="rapport1_del3" valign="top"></td>'; 
  $html .='</tr>';
  
  $html .='<tr>'; 
  $html .='<td  class="rapport1_del3" align="right" valign="top" width="120px"> Kommentar:</td>'; 
  $html .='<td  class="rapport1_del3" valign="top" width="380px">' . $kommentar .'</td>';
  $html .='<td class="rapport1_del3" valign="top"></td>';
  $html .='</tr>'; 
  
  $html .='<tr class="blank_row">';
    $html .='<td colspan="4"></td>';
    $html .='</tr>';  
   
   $forstekontroller=2;
}}

$html .= '</table>';
$html .= '</body>';
$html .= '</html>';

echo $html;
die();

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->WriteHTML($html);

$mpdf->Output();
exit;

?>


I dont know why this is happening ?????
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros