简体   繁体   中英

PHP code displayed in browser

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.

Your web server is not aware of PHP, which may not even be installed. Therefore, php code is just treated as normal text. Please update your post to tell what server you're using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM