Jump to content

Recommended Posts

Hi,

 

I'm new to php, and have copied an execise codes from a tutorial web page. I cannot get the code to run successfully. I don't understand the error and would greatly appreciate any help I can get.

 

here are the tutorial codes that I copied but slight modified to my environment.

 

===================================================================

html>

<head>

<basefont face="Arial">

</head>

<body>

 

<?php

 

// set database server access variables:

$host = "localhost";

$user = "root";

$pass = "password";

$db = "test";

 

// open connection

$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

 

// select database

mysql_select_db($db) or die ("Unable to select database!");

 

// create query

$query = "SELECT * FROM testdb";

 

// execute query

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

 

// see if any rows were returned

if (mysql_num_rows($result) > 0) {

    // yes

    // print them one after another

    echo "<table cellpadding=10 border=1>";

    while($row = mysql_fetch_row($result)) {

        echo "<tr>";

        echo "<td>".$row[0]."</td>";

        echo "<td>" . $row[1]."</td>";

        echo "<td>".$row[2]."</td>";

        echo "</tr>";

    }

    echo "</table>";

}

else {

    // no

    // print status message

    echo "No rows found!";

}

 

// free result set memory

mysql_free_result($result);

 

// close connection

mysql_close($connection);

 

?>

 

</body>

</html>

=======================================================================

 

This is the output that I received from the on the web page;

 

==============================================

"; while($row = mysql_fetch_row($result)) { echo ""; echo "".$row[0].""; echo "" . $row[1].""; echo "".$row[2].""; echo ""; } echo ""; } else { // no // print status message echo "No rows found!"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connection); ?>

 

=================================================

 

Systems installed;

 

Windows XP with IIS 6

php 5.3

mysql

==================

 

The Db is set up correctly with data and I can verify this in MySQL.

 

Can someone please help me?

 

Eam

 

Link to comment
https://forums.phpfreaks.com/topic/182236-understanding-error-from-the-code/
Share on other sites

IIS is not setup to parse php  so instead of actually doing something with it it just spits it out as text.

Here's a site looks like it does a pretty good job walking you through getting it configured

http://www.plus2net.com/php_tutorial/php_iis_installation.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.