Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am new to PHP and web development in general. I wrote a simple PHP script based on my knowledge so far. Here it what it looks like, along with the HTML:

<!DOCTYPE HTML>
<html>
    <title>Retrieve Users</title>
    <meta charset="utf-8">
    <body>
        <p> List of Subscribers </p>
        <?php
            $query = "select * from subscribers";
            $con = mysqli_connect("localhost","root","","subscribers");
            $result;
            if(mysqli_connect_errno()){
                header("Location: unavailable.html");
                exit;
            }else{
                $result = mysqli_query($con,$query);
            }
        ?>
        <table>
            <?php 
                global $result;
                while( $row = mysqli_fetch_array($result) ){
                    $email = $row['email'];
                    echo "<tr>";
                    echo "<td>"  $email  "</td>";
                    echo "</tr>";
                }
            ?>
        </table>
    </body>
</html>  

However, I get this in my webpage :

List of Subscribers

"; echo ""; echo ""; } ?>
" $email "  

What changes do I need to make here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
134 views
Welcome To Ask or Share your Answers For Others

1 Answer

You forgot to concate

echo "<td>".$email."</td>";

UPDATE

The concate was not alone the issue, the file name was having wrong extension.

This kind of situation may happen in following cases

  1. No PHP installed, in this it is most likely you may get php file getting downloaded intead of executing.
  2. Wrong file extension
  3. Using php short tag <? where in php.ini its not enable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...