473,549 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem read and display data from database

93 New Member
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]
Aug 20 '07 #1
7 1936
ak1dnar
1,584 Recognized Expert Top Contributor
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?Php
  3. //Php Codings Goes here
  4.  
  5. // When Need to Display HTML Close the Php Tags And Re-Open It when HTML part Is Done.
  6. ?>
  7. HTML Tagss Goes Here
  8. <?
  9. //Re-Open Php again for process Php Data
  10. ?>
  11.  
Option 2

Expand|Select|Wrap|Line Numbers
  1. <?Php
  2. $php_Codings = 'Some Value';
  3. //Php Codes Here
  4. // When HTML comes Use The echo String function.
  5. echo "<span>Any Html Data with $php_Codings </span>";
  6. ?>
  7.  
Aug 20 '07 #2
nma
93 New Member
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?Php
  3. //Php Codings Goes here
  4.  
  5. // When Need to Display HTML Close the Php Tags And Re-Open It when HTML part Is Done.
  6. ?>
  7. HTML Tagss Goes Here
  8. <?
  9. //Re-Open Php again for process Php Data
  10. ?>
  11.  
Option 2

Expand|Select|Wrap|Line Numbers
  1. <?Php
  2. $php_Codings = 'Some Value';
  3. //Php Codes Here
  4. // When HTML comes Use The echo String function.
  5. echo "<span>Any Html Data with $php_Codings </span>";
  6. ?>
  7.  
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.
Aug 21 '07 #3
ak1dnar
1,584 Recognized Expert Top Contributor
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]
Aug 21 '07 #4
nma
93 New Member
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.
Aug 21 '07 #5
nma
93 New Member
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
Aug 21 '07 #6
ak1dnar
1,584 Recognized Expert Top Contributor
Its a pleasure to help. Good luck.

Then for Your Next Quiz;

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.
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.

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.
Aug 21 '07 #7
nma
93 New Member
Thank you so much for the explaination.
Today I learn something new on php from this forum :-)


Regards,
-totally beginners
Aug 21 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3017
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem when reading out the data into the PHP variables / array. It should be displaying the information out in the following way, using the PHP array: ...
11
4400
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user can select the table they want to use. How can I do this? -- ------------------------------------ Wayne Wengert wayne@wengert.org
8
2059
by: Dave | last post by:
Hi all, I've been trying to figure this out for the last day and a half and it has me stumped. I've got a web application that I wrote that keeps track of trading cards I own, and I'm moving it from an Access 2000 database to a SQL Server 2000 database. Everything worked perfectly in Access, but I'm having trouble getting data to display...
7
2905
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of...
4
1850
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
Hey, Well, I have a Problem. I have designed a table which has few fields which are being declared in the database of type .... char of length 10. and other fields with varchar 50 and datetime too. Well, the Problem is I am not able to display the CHAR type FIELDS in the
2
8161
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to display the data to the user. If that form is already open, how do I make it refresh its data source and display the new data. Here is what I am...
5
2601
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.SqlClient" %> <script language="c#" runat="server"> public void Page_Load(object sender,...
8
5257
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. /com/Contacts.cfc <cfcomponent displayname="Contact" output="false" hint="Contact component"> <!--- properties: used for self-documentation...
1
3304
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway (ContactGateway.cfc) - index.cfm - Deals with the business logic - display/form.cfm - Produces the form for both add and edit behaviour
2
2621
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.