Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 PHP won't mix HTML in properly
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HyperFlexed




PostPosted: Thu Jul 19, 2007 10:45 pm   Post subject: PHP won't mix HTML in properly

I have the following on my server as "showItem.php"

code:

<html>
        <head>
                <title>Item Display Utility</title>
        </head>
        <body>
                <table>
                        <tr>
                                <td>Item_ID</td>
                                <td>Name</td>
                                <td>Description</td>
                                <td>Parent</td>
                                <td>Primary Key</td>
                                <td>Unique Key</td>
                        </tr>
                        <?php
                                $con = mysql_connect("localhost","********","********");
                                if (!$con){
                                die('Could not connect: ' . mysql_error());
                                }

                                mysql_select_db("sid", $con);

                                $result = mysql_query("SELECT * FROM Item");


                                while($row = mysql_fetch_array($result)){
                                  echo "<tr>";
                                        echo "<td>" . $row['Item_ID'] . "</td>";
                                        echo "<td>" . $row['Name'] . "</td>";
                                        echo "<td>" . $row['Description'] . "</td>";
                                        echo "<td>" . $row['Parent'] . "</td>";
                                        echo "<td>" . $row['PRIMARY KEY'] . "</td>";
                                        echo "<td>" . $row['UNIQUE KEY'] . "</td>";
                                        echo "</tr>";
                                        }

                                mysql_close($con);
                        ?>
                </table>
        </body>
</html>


Upon execution the following source code is generated:

code:

<html>
        <head>
                <title>Item Display Utility</title>
        </head>
        <body>
                <table>
                        <tr>
                                <td>Item_ID</td>
                                <td>Name</td>
                                <td>Description</td>
                                <td>Parent</td>
                                <td>Primary Key</td>
                                <td>Unique Key</td>
                        </tr>



It seems as though it hits the php block and just stops. I am willing to accept that this could be an error on the part of PHP itself. If anyone needs some info from the php.info() that might help, just let me know.

This is extremely frustrating.
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: Thu Jul 19, 2007 11:30 pm   Post subject: RE:PHP won\'t mix HTML in properly

Complete stab in the dark here, but does that database exist and does the user have permission to access it? Also, are errors turned on for PHP?
HyperFlexed




PostPosted: Thu Jul 19, 2007 11:38 pm   Post subject: RE:PHP won\'t mix HTML in properly

Interesting, errors are turned off. DO I change this by editing the php.ini file? The database does exist. I can log in to it using SSH.
HyperFlexed




PostPosted: Thu Jul 19, 2007 11:57 pm   Post subject: Re: PHP won't mix HTML in properly

display_errors = On, now.

FATAL ERROR: Call to undefined function : mysql_connect in ... on line 16

I installed PHP with the yum package manager. How would I go about recompiling/reconfiguring with mysql support?
HyperFlexed




PostPosted: Fri Jul 20, 2007 12:14 am   Post subject: RE:PHP won\'t mix HTML in properly

Okay, got it.

Just had to:
sudo yum install php-mysql

THANKS!
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: