Jump to content


Photo

Error selecting Data from database


  • Please log in to reply
7 replies to this topic

#1 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 05 September 2006 - 02:35 PM

Here is my code:

echo '<table border=1 width=100% id=table2>';
while($row = mysql_fetch_array($result)) {
	echo '<tr>';
		echo '<td>
		<p align=left><font face=Arial size=2><font color=#0000FF>
		' . $row['Name'] . '</font> - <font color="#FF0000">' . $row['Team'] . 

'</font></font></td>';
	echo '</tr>';
	echo '<tr>';
		echo '<td>
		<p align=center><font face=Arial size=2>' . $row['Comment'] . 

'</font></td>';
	echo '</tr>';
	echo '<tr>';
		echo '<td>
		<p align=right><font face=Arial size=2><font color=#006666>
		Chance of Winning: ' . $row['Rating'] . '</font></font></td>';
	echo '</tr>';
}
echo '
			</table>
		</td>
	</tr>
</table>';

mysql_close($db);
?>

Error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/www/fmprotasy.com/precommentsframe.php on line 115

Line 115 is echo '<table border=1 width=100% id=table2>';

Its probably an easy error but just can't find it.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 05 September 2006 - 02:43 PM

The php interpreter 'choked' on line 115, but the cause of the error is in some preceding line ... show us some code that comes before what you posted above.
Legend has it that reading the manual never killed anyone.
My site

#3 acdx

acdx
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 05 September 2006 - 05:39 PM

Your HTML makes my eyes bleed, you should put quotes around all values

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


#4 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 05 September 2006 - 09:17 PM

I had that but if you put them you get errors.

#5 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 05 September 2006 - 09:20 PM

<?php

$db = mysql_connect("username", "username", "password") or die("Could not connect.");
if(!$db) 
	die("no db");
if(!mysql_select_db("fmpsite_reg",$db))
 	die("No database selected.");
if(!get_magic_quotes_gpc())
?>
<?php
mysql_select_db('fmprotasy_reg', $db);
$result = mysql_query('SELECT * FROM Pre');

echo '<table border=0 bgcolor=#FF8C00 width=100% cellpadding=10>
	<tr>
		<td width=100% valign=top style=border-style: solid; border-width: 2>
			<p align=left><b><font face=Arial size=2>Pre Match Comments</font></b>
		</td>
	</tr>
</table>

<table border="0" bgcolor="#FF8C00" width="100%" cellpadding="10" height="15">
<tr>

<td width="100%" valign="top" height="1" style="border-style: solid; border-width: 2">
<font face="Arial" size="2">As the manager you need to say the right things to 
win. Here you can rate your chances of success, say a few words to or about the 
opposition and prepare your players for the match.<br>
&nbsp;</font><table border="0" width="100%" id="table1">
	<tr>
		<td width="167"><font face="Arial" size="2">Your Name:</font></td>
		<td><form action="insertpre.php" method="post">
		<input type="text" name="Name" size="32">
		</td>
	</tr>
	<tr>
		<td width="167"><font face="Arial" size="2">Your Team:</font></td>
		<td>
		<select size="1" name="Team">Team
					<optgroup label="Premiership">
					<option value="Arsenal">Arsenal<option>
					<option value="Aston Villa">Aston Villa<option>
					<option value="Birmingham City">Birmingham City<option>
					<option value="Blackburn">Blackburn Rovers<option>
					<option value="Bolton">Bolton Wanderers<option>
					<option value="Charlton">Charlton Athletic<option>
					<option value="Chelsea">Chelsea<option>
					<option value="Everton">Everton<option>
					<option value="Fulham">Fulham<option>
					<option value="Liverpool">Liverpool<option>
					<option value="Manchester City">Manchester City<option>
					<option value="Manchester United">Manchester United<option>
					<option value="Middlesborough">Middlesbrough<option>
					<option value="Newccastle United">Newcastle United<option>
					<option value="Portsmouth">Portsmouth<option>
					<option value="Sunderland">Sunderland<option>
					<option value="Tottenham Hotspur">Tottenham Hotspur<option>
					<option value="West Bromwich Albion">West Bromwich Albion<option>
					<option value="West Ham">West Ham United<option>
					<option value="Wigan Athletic">Wigan Athletic<option>
					<optgroup label="Championship">
					<option value="Burnley">Burnley<option>
					<option value="Cardiff">Cardiff City<option>
					<option value="Coventry">Coventry<option>
					<option value="Crystal Palace">Crystal Palace<option>
					<option value="Derby">Derby<option>
					<option value="Hull">Hull City<option>
					<option value="Ipswich">Ipswich<option>
					<option value="Leeds">Leeds<option>
					<option value="Leicester">Leicester<option>
					<option value="Luton">Luton<option>
					<option value="Norwich">Norwich<option>
					<option value="Plymouth">Plymouth<option>
					<option value="Preston">Preston<option>
					<option value="Queens Park Rangers">Queens Park Rangers<option>
					<option value="Reading">Reading<option>
					<option value="Sheffield United">Sheffield United<option>
					<option value="Southampton">Southampton<option>
					<option value="Stoke">Stoke<option>
					<option value="Watford">Watford<option>
					<option value="Wolves">Wolves<option></select></font><font size="2" face="Arial">
					</font></td>
	</tr>
	<tr>
		<td width="167"><font face="Arial" size="2">Chance of Winning:</font></td>
		<td></font><font size="2" face="Arial">
					&nbsp;</font><select size="1" name="Rating">Rating
					<option value="1">1
					<option value="2">2
					<option value="3">3
					<option value="4">4
					<option value="5">5
					<option value="6">6
					<option value="7">7
					<option value="8">8
					<option value="9">9
					<option value="10">10
					</select><b><font face="Arial">/</font><font face="Arial" size="3">10</font></b></td>
	</tr>
	<tr>
		<td width="167"><font face="Arial" size="2">Comments:</font></td>
		<td>
			<p><textarea rows="5" name="Comment" cols="34"></textarea></p>
		</td>
	</tr>
	<tr>
		<td width="167">&nbsp;</td>
		<td><input type="submit" value="Submit" name="B1">&nbsp;&nbsp;
		<input type="reset" value="Reset" name="B2"></form></td>
	</tr>
</table>
	<p><br>
			<font face="Arial" size="2">Comments by you or other managers:</font><br>
&nbsp;</p>
echo '<table border=1 width=100% id=table2>';
while($row = mysql_fetch_array($result)) {
	echo '<tr>';
		echo '<td>
		<p align=left><font face=Arial size=2><font color=#0000FF>
		' . $row['Name'] . '</font> - <font color="#FF0000">' . $row['Team'] . '</font></font></td>';
	echo '</tr>';
	echo '<tr>';
		echo '<td>
		<p align=center><font face=Arial size=2>' . $row['Comment'] . '</font></td>';
	echo '</tr>';
	echo '<tr>';
		echo '<td>
		<p align=right><font face=Arial size=2><font color=#006666>
		Chance of Winning: ' . $row['Rating'] . '</font></font></td>';
	echo '</tr>';
}
echo '
			</table>
		</td>
	</tr>
</table>';

mysql_close($db);
?>
<p>
<font face="Arial" size="2"></p>

</font>

</body>

</html>


#6 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 09:24 PM

		echo '<td>
		<p align=right><font face=Arial size=2><font color=#006666>
		Chance of Winning: ' . $row['Rating'] . '</font></font></td>';

This is the kind of code that will make your life Hell later.  I guess it's common practice because PHP allows you to do so, but IMO extending a string onto the next line is bad programming practice.  Some editors will treat the third line of that code as if the variable is inside the string, instead of vice versa.  In other words, some editors get confused and totally screw up the syntax coloring of your source code.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#7 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 05 September 2006 - 09:37 PM

So the correct code for that would be???

#8 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 06 September 2006 - 04:06 PM

?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users