PHP code显示在浏览器 [英] PHP code displayed in browser

查看:121
本文介绍了PHP code显示在浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我工作的一个数据库项目,我试图code递增。问题是,当我去测试在浏览器中的PHP时,我使用后显示的PHP code - >。的HTML打印正确显示,这是后点,其中 - >是

下面是PHP的:

 < PHP
    功能getGraphicNovel(){
        include_once(./ connect.php);
        $ db_connection =新的mysqli($ SERVER,$ USERNAME,$ PASSWORD,$ DATABASE);
        如果(mysqli_connect_errno()){
            回声(无法连接到MySQL服务器错误code:mysqli_connect_error());
            返回null;
        }
        $语句= $ db_connection-> stmt_init();
        $ =的returnValue无效;
        如果($语句。prepare(选择graphic_novel_main自然连接graphic_novel_misc系列)){
        $ stmt->执行();
        $ stmt-> bind_result($系列);
        而($ stmt->取()){
            回声< TR>< TD>中。 $系列。 &所述; / TD>&下; / TR>中;
        }
        $ stmt->关闭();
    }
    $ db_connection->关闭();
}
getGraphicNovel();
?>

下面是该页面的链接。希望它为学校的网络之外的人。

http://plato.cs.virginia.edu/~paw5k/ cainedb / viewall.html

如果有人知道为什么会这样,你的投入将是巨大的!

为每个请求:

PHP -v:

  PHP 5.3.2-1ubuntu4.14用了Suhosin-补丁(CLI)(建:2012年2月11日六时50分46秒)
版权所有(c)1997-2009的PHP集团
Zend引擎V2.3.0,版权所有(C)1998-2010 Zend技术


解决方案

这听起来像PHP是不工作的。你没有看到的第一部分的唯一原因,是因为你的浏览器是解析它,就好像它是一个HTML标签。

so, I'm working on a databases project, and i'm trying to code incrementally. the problem is, when i go to test the php in browser, it displays the php code after my use of "->". the html printing is displayed properly, which is AFTER the point where the -> is.

here is the php:

<?php 
    function getGraphicNovel(){ 
        include_once("./connect.php"); 
        $db_connection = new mysqli($SERVER, $USERNAME, $PASSWORD, $DATABASE); 
        if (mysqli_connect_errno()) { 
            echo("Can't connect to MySQL Server. Error code: " . mysqli_connect_error()); 
            return null; 
        } 
        $stmt = $db_connection->stmt_init(); 
        $returnValue = "invalid"; 
        if($stmt.prepare("select series from graphic_novel_main natural join graphic_novel_misc")) { 
        $stmt->execute(); 
        $stmt->bind_result($series); 
        while ($stmt->fetch()) { 
            echo "<tr><td>" . $series . "</td></tr>";
        }
        $stmt->close(); 
    } 
    $db_connection->close(); 
} 
getGraphicNovel();
?>

here is a link to the page. hopefully it works for people outside the school's network.

http://plato.cs.virginia.edu/~paw5k/cainedb/viewall.html

if anyone knows why this is happening, your input would be great!

as per request:

php -v:

PHP 5.3.2-1ubuntu4.14 with Suhosin-Patch (cli) (built: Feb 11 2012 06:50:46) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

解决方案

It sounds like PHP is not working at all. The only reason you are not seeing the first part, is because your browsers is parsing it as if it were an HTML tag.

这篇关于PHP code显示在浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆