Main Menu |
|
|
 |
Forums |
| |
 |
Programming
Contest |
| |
 |
Documentation
|
| |
 |
Partner
Sites |
|
 |
|
| MySQL Help Post any question relating to MySQL here and hopefully someone can help |

2006-10-14, 01:50 AM
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 5
|
|
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);
?>
|

2006-10-14, 02:07 AM
|
|
Senior Member
|
|
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
|
|
take look on string
while($row = mysql_fetch_array($result)
and count "(" and ")"
|

2006-10-14, 03:01 AM
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 5
|
|
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.
|

2006-10-14, 03:06 AM
|
|
Senior Member
|
|
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
|
|
ok. so, please, I just ask you count "(" and ")" in line. don't write just count...
ps:
while($row = mysql_fetch_array($result))
|

2006-10-14, 03:15 AM
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 5
|
|
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.
|

2006-10-14, 03:20 AM
|
|
Senior Member
|
|
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
|
|
take look lines above "while"
you don't close double quote somewhere.
|

2006-10-14, 03:32 AM
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 5
|
|
Shoot, I cant find a double quote that I dident close off.
|

2006-10-14, 12:20 PM
|
|
Member
|
|
Join Date: Oct 2006
Location: London
Posts: 33
|
|
Can't see any double quotes missing either. You have posted only part of the code, whats above it. Have you looked in there.
|

2006-10-14, 02:17 PM
|
|
Senior Member
|
|
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
|
|
solution: comment strings 87-93. this can help you for locate error.
|

2006-10-14, 07:18 PM
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 5
|
|
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.
Last edited by theinfomaster; 2006-10-14 at 07:41 PM.
|
| Must read Review for Serious PHP Developers |
NuSphere PhpED 5.5
: The Staff of php-editors.com recently spent a few days working with NuSphere
PhpED 5.5
(a popular PHP IDE) and
NuCoder 2.0
(a PHP Encoding Utility), read up on all the details.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 07:33 PM.
|
|