View unanswered posts | View active topics It is currently Mon May 23, 2022 1:57 am



Reply to topic  [ 5 posts ] 
 HELP(Writing MySQL databse data to web page) 
Author Message
Junior Member

Joined: Fri Oct 13, 2006 6:43 pm
Posts: 5
Post HELP(Writing MySQL databse data to web page)
Hi,
I have a problem, when I run this script the browser has a problem with the "{" at the bottom of this page. I have changed its color to red. What am I doing wrong?


<?php
$con = mysql_connect("localhost", "******", "******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("theinfo_forum1", $con);
$result = mysql_query("SELECT * FROM person");
echo "<table border='1'>
<tr>
<th>Member#</th>
<th>UserName</th>
</tr>";while($row = mysql_fetch_array($result)
{
echo "<tr>";
echo "<td>" . $row['member_#'] . "</td>";
echo "<td>" . $row['member_name'] . "</td>";
echo "</tr>";
}
echo "</table>";mysql_close($con);
?>


Fri Oct 13, 2006 6:50 pm
Report this post
Profile WWW
Junior Member

Joined: Fri Oct 13, 2006 6:43 pm
Posts: 5
Post 
With that row of code changed I get the error,
Parse error: syntax error, unexpected '>' in /home/theinfo/public_html/tests/members.php on line 89

Line 89 looks like,
echo "<tr>";

This is what I changed the code to that you told me to,
while($row = mysql_fetch_array($result) and count "and"


There is still something wrong.


Fri Oct 13, 2006 8:01 pm
Report this post
Profile WWW
Junior Member

Joined: Fri Oct 13, 2006 6:43 pm
Posts: 5
Post 
Sorry about that(Im not to bright for my knowledge).
Ok now a new problem has occured. When I testes it the error msg,
Parse error: syntax error, unexpected '>' in /home/theinfo/public_html/tests/members.php on line 89

Now I dont understand what its problem is now.(I wrote the line # in red)

87.while($row = mysql_fetch_array($result))
88. {
89.echo "<tr>";
90.echo "<td>" . $row['member_#'] . "</td>";
91.echo "<td>" . $row['member_name'] . "</td>";
92.echo "</tr>";
93.}

Im sorry for all the questions.


Fri Oct 13, 2006 8:15 pm
Report this post
Profile WWW
Junior Member

Joined: Fri Oct 13, 2006 6:43 pm
Posts: 5
Post 
Shoot, I cant find a double quote that I dident close off.


Fri Oct 13, 2006 8:32 pm
Report this post
Profile WWW
Junior Member

Joined: Fri Oct 13, 2006 6:43 pm
Posts: 5
Post 
Lets see, That bit of code on the first post of this thread is the only part of the web page that has any PHP or MySQL code in it. I checked to see if I did something wrong in the HTML by copying and pasting it into an HTML document. Wonce I did that my software I use would have presented me with the error. Due to finding non I put comments around the strings 87-93 and tested this. All it did was change the line of code that had the error.
Here is the updated code to what I was told to do,
<?php
$con = mysql_connect("localhost", "******", "******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("theinfo_forum1", $con);

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

echo "<table border='1'>
<tr>
<th>Member Email</th>
<th>UserName</th>
</tr>
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['UserName'] . "</td>";
echo "<td>" . $row['Email'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>


I still dont see any thing wrong with it. I guess I dont really understand. It has a problem with the "<>" on the tags were the Echo "<>" are.


Sat Oct 14, 2006 12:18 pm
Report this post
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.