During production the generated HTML by the PHP was not disp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rozvinbm_jp
Forum Commoner
Posts: 43
Joined: Thu Jun 14, 2007 8:36 pm
Location: Fuji-shi, Shizuoka-ken, Japan

During production the generated HTML by the PHP was not disp

Post 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;
}
?>
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post by Steve Mellor »

Are you getting any errors at all? Also, when it has been parsed, what does the source code show if anything?
rozvinbm_jp
Forum Commoner
Posts: 43
Joined: Thu Jun 14, 2007 8:36 pm
Location: Fuji-shi, Shizuoka-ken, Japan

Post 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.
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post 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';
}
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

This may sound silly, but are you sure the databases both have the same data?
Post Reply