Problem read and display data from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nma
    New Member
    • Aug 2007
    • 93

    Problem read and display data from database

    Hi
    I'm trying to display data in a table list format but error message like this appear. What is wrong with the code?

    "Parse error: syntax error, unexpected '<' in C:\htdocs\...\M B2movieinfo.php on line 27"

    I'm trying to display data from table in databse in new window and there is a close window button to close the opened window.

    TQ

    [PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Movie Information Details</title>
    <link rel="stylesheet " href="moviebrow ser2.css" type="text/css" title="Default" media="screen"/>
    <style type="text/css">

    </style>
    </head>
    <?PHP

    $dbHost = "localhost" ;
    $dbUser = "*****";
    $dbPass = "****";
    $dbDatabase = "*****";


    $db = mssql_connect(" $dbHost", "$dbUser", "$dbPass") or die ("Error connecting to /database.");

    mssql_select_db ("$dbDatabas e", $db) or die ("Couldn't select the database.");

    $query="select * from Movie where movieID = 1 ";
    $qt=mssql_query ($query);
    while($nt=mssql _fetch_array($q t)){

    <span class="style2"> </span>
    <table width="600" border="0" align="center">
    <tr>
    <td height="20" colspan="2" align="center" valign="middle" bgcolor="#53474 1"><span class="style3"> MOVIE OVERVIEW</span></td>
    </tr>
    <tr>
    <td width="146" valign="top" >DIRECTOR</td>
    <td width="444"><? echo "$nt[movieTitle]"?>;<br /></td>
    </tr>
    <tr>
    <td width="146" valign="top" >WRITER</td>
    <td width="444"><? echo "$nt[writer]"?>;<br /></td>
    </tr>
    <tr>
    <td width="146" valign="top" >GENRE</td>
    <td width="444"><? echo "$nt[genre1]" . "$nt[genre2]". "$nt[genre3]"."$nt[genre4]"."$nt[genre5]"?>;<br /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>
    <form>

    <align="right ">
    <input name="button" type=button onclick="javasc ript:window.clo se();" value="Close Window" />
    </form>
    </td>
    </tr>
    </table>
    }
    ?>
    </body>
    </html>
    [/PHP]
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    The way you have choosen to print the HTML tags is, NOT correct inside the Php codes.
    you Have two Option to solve the Error

    Option 1

    [CODE=php]

    <?Php
    //Php Codings Goes here

    // When Need to Display HTML Close the Php Tags And Re-Open It when HTML part Is Done.
    ?>
    HTML Tagss Goes Here
    <?
    //Re-Open Php again for process Php Data
    ?>
    [/CODE]
    Option 2

    [CODE=php]
    <?Php
    $php_Codings = 'Some Value';
    //Php Codes Here
    // When HTML comes Use The echo String function.
    echo "<span>Any Html Data with $php_Codings </span>";
    ?>
    [/CODE]

    Comment

    • nma
      New Member
      • Aug 2007
      • 93

      #3
      Originally posted by ajaxrand
      The way you have choosen to print the HTML tags is, NOT correct inside the Php codes.
      you Have two Option to solve the Error

      Option 1

      [CODE=php]

      <?Php
      //Php Codings Goes here

      // When Need to Display HTML Close the Php Tags And Re-Open It when HTML part Is Done.
      ?>
      HTML Tagss Goes Here
      <?
      //Re-Open Php again for process Php Data
      ?>
      [/CODE]
      Option 2

      [CODE=php]
      <?Php
      $php_Codings = 'Some Value';
      //Php Codes Here
      // When HTML comes Use The echo String function.
      echo "<span>Any Html Data with $php_Codings </span>";
      ?>
      [/CODE]
      I'm sorry still blurr..
      .... I have rearrange the code but fail. when i remove the all html tag and just disply the data in php only it works without html code. But how to make it display in table form within html code? because I want to use the the color coding etc that I've design in css and etc in html.

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by nma
        I'm sorry still blurr..
        .... I have rearrange the code but fail. when i remove the all html tag and just disply the data in php only it works without html code. But how to make it display in table form within html code? because I want to use the the color coding etc that I've design in css and etc in html.
        Try this way and post back if you couldn't make it to run.
        Thanks


        [PHP]
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Movie Information Details</title>
        <link rel="stylesheet " href="moviebrow ser2.css" type="text/css" title="Default" media="screen"/>
        <style type="text/css">

        </style>
        </head>
        <?Php
        $dbHost = "localhost" ;
        $dbUser = "*****";
        $dbPass = "****";
        $dbDatabase = "*****";


        $db = mssql_connect(" $dbHost", "$dbUser", "$dbPass") or die ("Error connecting to /database.");

        mssql_select_db ("$dbDatabas e", $db) or die ("Couldn't select the database.");

        $query="select * from Movie where movieID = 1 ";
        $qt=mssql_query ($query);
        while($nt=mssql _fetch_array($q t)){
        ?>
        <span class="style2"> </span>
        <table width="600" border="0" align="center">
        <tr>
        <td height="20" colspan="2" align="center" valign="middle" bgcolor="#53474 1"><span class="style3"> MOVIE OVERVIEW</span></td>
        </tr>
        <tr>
        <td width="146" valign="top" >DIRECTOR</td>
        <td width="444"><? echo "$nt[movieTitle]";?><br /></td>
        </tr>
        <tr>
        <td width="146" valign="top" >WRITER</td>
        <td width="444"><? echo "$nt[writer]";?><br /></td>
        </tr>
        <tr>
        <td width="146" valign="top" >GENRE</td>
        <td width="444"><? echo "$nt[genre1]" . "$nt[genre2]". "$nt[genre3]"."$nt[genre4]"."$nt[genre5]"; ?><br /></td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>
        <form>
        <input name="button" type=button onclick="javasc ript:window.clo se();" value="Close Window" />
        </form>
        </td>
        </tr>
        </table>
        <?
        }
        ?>
        </body>
        </html>


        [/PHP]

        Comment

        • nma
          New Member
          • Aug 2007
          • 93

          #5
          Originally posted by ajaxrand
          Try this way and post back if you couldn't make it to run.
          Thanks


          [PHP]
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <title>Movie Information Details</title>
          <link rel="stylesheet " href="moviebrow ser2.css" type="text/css" title="Default" media="screen"/>
          <style type="text/css">

          </style>
          </head>
          <?Php
          $dbHost = "localhost" ;
          $dbUser = "*****";
          $dbPass = "****";
          $dbDatabase = "*****";


          $db = mssql_connect(" $dbHost", "$dbUser", "$dbPass") or die ("Error connecting to /database.");

          mssql_select_db ("$dbDatabas e", $db) or die ("Couldn't select the database.");

          $query="select * from Movie where movieID = 1 ";
          $qt=mssql_query ($query);
          while($nt=mssql _fetch_array($q t)){
          ?>
          <span class="style2"> </span>
          <table width="600" border="0" align="center">
          <tr>
          <td height="20" colspan="2" align="center" valign="middle" bgcolor="#53474 1"><span class="style3"> MOVIE OVERVIEW</span></td>
          </tr>
          <tr>
          <td width="146" valign="top" >DIRECTOR</td>
          <td width="444"><? echo "$nt[movieTitle]";?><br /></td>
          </tr>
          <tr>
          <td width="146" valign="top" >WRITER</td>
          <td width="444"><? echo "$nt[writer]";?><br /></td>
          </tr>
          <tr>
          <td width="146" valign="top" >GENRE</td>
          <td width="444"><? echo "$nt[genre1]" . "$nt[genre2]". "$nt[genre3]"."$nt[genre4]"."$nt[genre5]"; ?><br /></td>
          </tr>
          <tr>
          <td>&nbsp;</td>
          <td>
          <form>
          <input name="button" type=button onclick="javasc ript:window.clo se();" value="Close Window" />
          </form>
          </td>
          </tr>
          </table>
          <?
          }
          ?>
          </body>
          </html>


          [/PHP]
          it's work..thansk a million.

          Comment

          • nma
            New Member
            • Aug 2007
            • 93

            #6
            Just to ask about some concept..
            Is the file like the above code (inside html there is php code)- the file name save can be .php or .html? Is there any different?

            Currently I save it under filename .php and run the file under localhost.
            I'm going to develop a web application using php and read data from sql server.
            There will be a few pages on html interface that I must link together to make it complete application.

            Please let me know as I'm new to this environment (web development application)

            Thanks

            Comment

            • ak1dnar
              Recognized Expert Top Contributor
              • Jan 2007
              • 1584

              #7
              Its a pleasure to help. Good luck.

              Then for Your Next Quiz;

              Originally posted by nma
              Just to ask about some concept..
              Is the file like the above code (inside html there is php code)- the file name save can be .php or .html?
              If you have any Php related data on it you have to use .php extension for the file.By Putting .html/.htm You cannot execute the Php related data.
              Originally posted by nma
              Is there any different?
              Yes. HTML pages Executes on almost All the web Servers by default.
              But to execute a Script like Php,ASP,JSP we need the Supportable Engine for specific script language. for Example to execute the Php page on a web server we need the Php installed on the Machine and It should configured to work with the web server application.
              Php and Apache is Good Example.The Truth is here Php(Server side Scripting language) will Execute in the web server with the support of Php Engine and Produce the HTML Out put to Client Browser.

              Originally posted by nma
              Currently I save it under filename .php and run the file under localhost.
              I'm going to develop a web application using php and read data from sql server.
              There will be a few pages on html interface that I must link together to make it complete application.
              You Can Link .html pages and .php Pages with each other.

              Comment

              • nma
                New Member
                • Aug 2007
                • 93

                #8
                Thank you so much for the explaination.
                Today I learn something new on php from this forum :-)


                Regards,
                -totally beginners

                Comment

                Working...