Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-10-14, 01:50 AM
theinfomaster's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 5
theinfomaster is on a distinguished road
Default 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);
?>
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2006-10-14, 02:07 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

take look on string
while($row = mysql_fetch_array($result)
and count "(" and ")"
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #3 (permalink)  
Old 2006-10-14, 03:01 AM
theinfomaster's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 5
theinfomaster is on a distinguished road
Default

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.
Reply With Quote
  #4 (permalink)  
Old 2006-10-14, 03:06 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

ok. so, please, I just ask you count "(" and ")" in line. don't write just count...

ps:
while($row = mysql_fetch_array($result))
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #5 (permalink)  
Old 2006-10-14, 03:15 AM
theinfomaster's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 5
theinfomaster is on a distinguished road
Default

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.
Reply With Quote
  #6 (permalink)  
Old 2006-10-14, 03:20 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

take look lines above "while"
you don't close double quote somewhere.
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #7 (permalink)  
Old 2006-10-14, 03:32 AM
theinfomaster's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 5
theinfomaster is on a distinguished road
Default

Shoot, I cant find a double quote that I dident close off.
Reply With Quote
  #8 (permalink)  
Old 2006-10-14, 12:20 PM
Member
 
Join Date: Oct 2006
Location: London
Posts: 33
JustPHP is on a distinguished road
Send a message via MSN to JustPHP Send a message via Yahoo to JustPHP Send a message via Skype™ to JustPHP
Default

Can't see any double quotes missing either. You have posted only part of the code, whats above it. Have you looked in there.
Reply With Quote
  #9 (permalink)  
Old 2006-10-14, 02:17 PM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

solution: comment strings 87-93. this can help you for locate error.
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #10 (permalink)  
Old 2006-10-14, 07:18 PM
theinfomaster's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 5
theinfomaster is on a distinguished road
Default

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.
Reply With Quote
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.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:33 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.