2

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
4
  • Are you running this in a website as in localhost/myfile.php, or are you simply browsing out on the file system and opening it? (hint, that second option won't work, and will do exactly what you're describing. You need a web server to parse the PHP and generate html.) Commented Apr 10, 2012 at 17:16
  • 2
    Did you save the file as .php or .html? Commented Apr 10, 2012 at 17:18
  • the server is managed by my school, so i have very limited configuration rights. the php version: 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 os: ubuntu 10.04.03 LTS file saved as .html, but has other html outside the php. Commented Apr 10, 2012 at 17:28
  • jumping frog: what do you mean? I'm accessing the .html file from my laptop, but I am committing all changes as i make them. I view the result in a web browser... Commented Apr 10, 2012 at 17:31

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

4 Comments

you might be right. ive emailed my professor. when i put the bit <?php phpinfo(); ?> in my file, nothing was printed...
@Drake you need to name the file that you upload with the file extension .php, otherwise typically apache will not parse it as php.
np, still a bit of a newbie here. to clarify for anybody looking this up later, it was bc the file did not have a .php filename
@dqhendricks, what do you mean by "PHP is not working"? How to know it is working. I am new with php. I have posted by questing here stackoverflow.com/questions/33409539/…
1

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.

1 Comment

I have similar problem with nginx. Here is my question : stackoverflow.com/questions/33409539/… Can you help me with this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.