Page 1 of 1

During production the generated HTML by the PHP was not disp

Posted: Tue Aug 28, 2007 5:14 am
by rozvinbm_jp
During development (debugging) the site works well but when I release from the debugging and test into production.. the result from PHP file was not displayed.

test.php

Code: Select all

<a href="proshops01test.php?mode=kensaku&shopname=&#12525;&#12474;&#12499;&#12531;&rowsperpage=5&pageidx=1" >test</a>
proshops01test.php

Code: Select all

<?php
header('Content-Type: text/html; charset=shift_jis');
require_once('../phpbase.php');
include(WORKINGCLASSES .'clssearchindex.php');
session_start();

$mode = $_GET['mode'];
$shopname = iconv("UTF-8", "SJIS", $_GET['shopname']);
$kensakukekka = "";
$rowsperpage = $_GET['rowsperpage'];
$pageidx = $_GET['pageidx'];

$sql = "";
$sql = "SELECT
            distinct sh.shopcd,sh.name,sh.postcode, sh.areanum, sh.othernum
            ,pc.ken, pc.shi, pc.ku, pc.machi
        FROM
            shopcontacts sc LEFT JOIN shops sh
                ON sc.shopcd = sh.shopcd
            LEFT JOIN postcodes as pc
                ON sh.postcode = pc.postcode
        WHERE sh.name like '%". $shopname ."%'";
// created dbconnection
$c_rs = new Recordset();
// fetch all data based on the criteria
$_SESSION['$o_search'] = $c_rs->query($sql);
// get the data tobe displayed based on the rowsperpage
$rows = getDataPage($rowsperpage, $pageidx);

if ( count($rows) > 0 ) {
    // create the list with <a> tag for hyperlink
    foreach ($rows as $row){
        $kensakukekka = $kensakukekka ."<a id='hyouji' name='hyouji'\n";
        $kensakukekka = $kensakukekka ."href=\"\" />\n";
        $kensakukekka = $kensakukekka . $row['name'] . "</a><br/>\n";
        $kensakukekka = $kensakukekka ."<small>&#12306;". $row['postcode'] ."</small><br/><br/>\n";
    }

    $_SESSION['kensakukekka'] = $kensakukekka;
    // generate the HTML code
    print $_SESSION['kensakukekka'];
}else {
    $eof = false;
}

function getDataPage($limit = 5, &$idx = 1) {
    $getDataPage = new ArrayObject();
    $rows = $_SESSION['$o_search'];

    if ( $limit > count($rows) ) {
        $limit = count($rows);
        $idx = 1;
    }

    $rowcount = 0;
    for ($start = 0; $rowcount < $limit; $start++) {
        if ( ! isset($rows[$start]) ) {
            break;
        }

        if ( count($getDataPage) == 0 ) {
            $getDataPage = array(0 => $rows[$start]);
        }else {
            array_push($getDataPage,$rows[$start]);
        }

        $rowcount = $rowcount + 1;
    }

    return $getDataPage;
}
?>

Posted: Tue Aug 28, 2007 6:22 am
by Steve Mellor
Are you getting any errors at all? Also, when it has been parsed, what does the source code show if anything?

Posted: Tue Aug 28, 2007 6:51 am
by rozvinbm_jp
Steve Mellor wrote:Are you getting any errors at all? Also, when it has been parsed, what does the source code show if anything?
Unfortunately there is no any errors displayed.
Note: I configured the php.ini to display all errors

The result is nothing... there is not html code if you view the source right via right click using the mouse.

Posted: Tue Aug 28, 2007 7:01 am
by Steve Mellor
is phpbase.php your database connection?

My initial reaction is to put "session_start();" before you send any headers but that usually throws up an error. Have you tried the page without including your classes?. It won't work but it might show whether it is the include that is causing you problems.

The other thing you can do is just echo "hello world" at the very bottom of the page. That would show if the page is encountering an error and exiting or if it is the script its self causing a problem. It may just be because your SQL query is returning nothing. Try this just to check.

Code: Select all

if ( count($rows) > 0 ) {
    // create the list with <a> tag for hyperlink
    foreach ($rows as $row){
        $kensakukekka = $kensakukekka ."<a id='hyouji' name='hyouji'\n";
        $kensakukekka = $kensakukekka ."href=\"\" />\n";
        $kensakukekka = $kensakukekka . $row['name'] . "</a><br/>\n";
        $kensakukekka = $kensakukekka ."<small>&#12306;". $row['postcode'] ."</small><br/><br/>\n";
    }

    $_SESSION['kensakukekka'] = $kensakukekka;
    // generate the HTML code
    print $_SESSION['kensakukekka'];
}else {
    $eof = false;
    echo 'no results returned';
}

Posted: Tue Aug 28, 2007 12:38 pm
by califdon
When a page is delivered that you expect to contain HTML generated by a PHP script and it does not, it is usually because the PHP contains a syntax error. When that is true, PHP just won't run the script, so it does not generate any HTML. I hate that "feature" of PHP. The question is why it runs okay in the development environment, but not when you go to production. I would still suspect a syntax error, though. Is it at all possible that you made some minor change in the PHP code between the last time you tested it in development and when you put it into production? All it takes is one missing ; or something.

If what you showed us was the complete PHP code, though, as mentioned by Steve, you do need to have a session_start(); statement before you assign or try to read a session variable. But that would not cause the problem you described.

Posted: Tue Aug 28, 2007 4:34 pm
by superdezign
This may sound silly, but are you sure the databases both have the same data?