superhoops Posted September 5, 2006 Share Posted September 5, 2006 Here is my code:[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);?>[/code]Error:[b]Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/www/fmprotasy.com/precommentsframe.php on line 115[/b]Line 115 is echo '<table border=1 width=100% id=table2>';Its probably an easy error but just can't find it. Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/ Share on other sites More sharing options...
AndyB Posted September 5, 2006 Share Posted September 5, 2006 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. Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86406 Share on other sites More sharing options...
acdx Posted September 5, 2006 Share Posted September 5, 2006 Your HTML makes my eyes bleed, you should put quotes around all values Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86528 Share on other sites More sharing options...
superhoops Posted September 5, 2006 Author Share Posted September 5, 2006 I had that but if you put them you get errors. Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86678 Share on other sites More sharing options...
superhoops Posted September 5, 2006 Author Share Posted September 5, 2006 [code]<?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())?><?phpmysql_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> </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"> </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"> </td> <td><input type="submit" value="Submit" name="B1"> <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> </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>[/code] Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86685 Share on other sites More sharing options...
roopurt18 Posted September 5, 2006 Share Posted September 5, 2006 [code] echo '<td> <p align=right><font face=Arial size=2><font color=#006666> Chance of Winning: ' . $row['Rating'] . '</font></font></td>';[/code]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. Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86691 Share on other sites More sharing options...
superhoops Posted September 5, 2006 Author Share Posted September 5, 2006 So the correct code for that would be??? Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-86706 Share on other sites More sharing options...
superhoops Posted September 6, 2006 Author Share Posted September 6, 2006 ? Link to comment https://forums.phpfreaks.com/topic/19772-error-selecting-data-from-database/#findComment-87205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.