php giving a blank page, no errors


I have the following part of an AJAX application, which gives no errors, but also nothing is displayed to the screen, so I am unsure of where the problem lies. Calling this page directly from a browser with ?cmd&id=1 should return, or even calling it without ?cmd should return the cmd error message.

edit: added test cases: I do get the cmd error message, but when I pass &id=1 (1 is a valid id), no html gets returned whatsoever, view source is completely blank. Have I used echo incorrectly or something similar?

edit2: added echo as first line: the first echo is not seen whatsoever

edit3: After going back to an older version and making all the changes again, I now get test charset output when calling with valid cmd and id paramters. The code I am using is identical to what is pasted below.

the code:

echo "hello world";    

if (isset($_GET["cmd"]))
  $cmd = $_GET["cmd"];
  die("You should have a 'cmd' parameter in your URL");

$id = $_GET["id"];

$con = mysqli_connect("localhost", "user", "password", "db");
echo "test con";

  die('Connection failed because of' .mysqli_connect_error());
  echo "test error";

//$con->query("SET NAMES 'utf8'"); 
echo "test charset";

  echo "test cmdifloop";

  if ($getRecords = $con->prepare("SELECT * FROM SALES WHERE PRODUCT_NO = ?"))
    echo "test recordifloop";

    $getHtml = $con->prepare("SELECT PRODUCT_DESC FROM SALES WHERE PRODUCT_NO = ?");
    $getHtml->bind_param("s", $id);

    $getRecords->bind_param("s", $id);
                             $FEE_INSERTION, $FEE_FINAL, $FEE_LISTING, $PIC_XXL, $PIC_DIASHOW,
                             $PIC_COUNT, $ITEM_SITE_ID
    while ($getRecords->fetch()) 
      $ccodes = array(  "1" => "USA",
                       "77" => "Germany",
                       "16" => "Austria",
                      "122" => "Luxemburg",
                      "193" => "Switzerland",

      $conditions = array( "0" => "USA",
                          "77" => "Germany",
                          "16" => "Austria",

      $country = $ccodes[$COUNTRYCODE];
      if ( $country == "" ) $country = "Not applicable";


      foreach($columns as $column) {
        $$column = $row[$column] ? 'YES' : 'NO';

      imageResize($PIC_URL, 250, 300);
      file_put_contents($id, file_get_contents($PIC_URL));

      $html = htmlentities(json_encode($PRODUCT_DESC));
      $shortDate = strftime("%d %m %Y", strtotime($ACCESSSTARTS));

      echo "<h1>".$PRODUCT_NAME."</h1>
<div id='leftlayer' class='leftlayer'>
<p><strong>Username: </strong>".$USERNAME."
<p><strong>PRODUCT Number: </strong>".$PRODUCT_NO."
<p><strong>Subtitle: </strong>".$SUBTITLE."
<p><strong>SALE Start: </strong>".$ACCESSSTARTS." 
<p><strong>SALE End: </strong>".$ACCESSENDS."
<p><strong>SALE Type: </strong>".$SALE_TYPE."
<p><strong>Category: </strong>".$CAT_DESC."
<div class='leftlayer2'>
  <p><strong>Condition: </strong> ".$CURRENT_PRICE."
  <p><strong>Total Items: </strong> ".$QUANT_TOTAL."
  <p><strong>Total Sales: </strong> ".$QUANT_SOLD."
  <p><strong>Start Price: &#8364</strong> ".$START_PRICE."
  <p><strong>Buyitnow Price: &#8364</strong> ".$BUYITNOW_PRICE."
  <p><strong>PRICEs: </strong> ".$PRICE_COUNT." 
  <p><strong>Revised: </strong> ".$REVISED."
<div class='leftlayer2'>
  <p><strong>Private: </strong> ".$PRIVATE_SALE."
  <p><strong>Finished: </strong> ".$FINISHED."
  <p><strong>Cancelled: </strong> ".$PRE_TERMINATED."
  <p><strong>Paypal: </strong> ".$PAYPAL_ACCEPT."
  <p><strong>Country: </strong> ". $country ."
  <p><strong>Location: </strong> ".$LOCATION."
  <p><strong>Shipping to: </strong> ". $country ."
<div id='rightlayer'>
 <img src='".$PIC_URL."' width='".$imageSize["width"]."' height='".$imageSize["height"]."'>
 <p><a href='#' onclick=\"makewindows(" . $html . "); return false;\">Click for full description </a></p>


  function imageResize($imageURL, $maxWidth, $maxHeight)
    $imageSize["width"] = 0;
    $imageSize["height"] = 0;

    $size = getimagesize($imageURL);
    if ($size) {
      $imageWidth  = $size[0];

      $imageHeight = $size[1];
      $wRatio = $imageWidth / $maxWidth;
      $hRatio = $imageHeight / $maxHeight;
      $maxRatio = max($wRatio, $hRatio);

      if ($maxRatio > 1) {
        $imageSize["width"] = $imageWidth / $maxRatio;
        $imageSize["height"] = $imageHeight / $maxRatio;
        return $imageSize;
      } else {
        $imageSize["width"] = $imageWidth;
        $imageSize["height"] = $imageHeight;
        return $imageSize;
    } else {


I apologize for the spacing, but it happens automatically when I press the code button.


If you are sure you have no error and keep getting a blank page, I would suggest you install php-process.

yum -y install php-process

In other cases, you get such an error if you do not have pear installed.

yum -y install php-pear php-pear-DB or just to install the db pear install DB

Hope this helps someone with the blank page issue.

The reason this is happening is because your server config is set to not display errors, so your script is relying on executing that error_reporting(E_ALL); - this should work fine as long as the error_reporting() function gets executed. However, if there is a parse error, the error_reporting(E_ALL) won't get executed, and there foreyou will not see an error as the php.ini error reporting settings never get overwritten.

The only solution for you is to set error_reporting in a higher places such as htaccess or php.ini. But now at least you know that a blankpage = a parse error!

By : Dunhamzzz

Put parentheses around your if-else statements. I have a feeling the person who edited your code may have "fixed" a potential problem there.

This video can help you solving your question :)
By: admin