ridiculous Posted October 2, 2006 Share Posted October 2, 2006 I have to admire anyone who is proficient enough with PHP to render me advice here today, simply because my nascient debugging experiences have nearly driven me to psychotic acts of violence-boy am I frustrated. I've looked over the script inserted below for hours and I can't seem to identify the cause of a parsing error I keep getting Parse error: parse error, unexpected $ in /home/content/s/t/a/starsonline/html/study/u/table.php on line 62.It's probably quite simple but I don't have the expertise to solve the problem. -----------------------------------------------------------------------------------<? session_start(); { $result = mysql_pconnect('localhost', 'password', 'user'); if (!$result) return false; if (!mysql_select_db('db')) return false; return $result;}// Begin your table outside of the array{echo '<table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr> <td width="110"><b>Event Date</b></td> <td><b> Event Title</b></td> </tr>';// Define your colors for the alternating rows$color1 = '#CCFFCC'; $color2 = '#BFD8BC'; $row_count = 0;// Perform an statndard SQL query:$sql_events = mysql_query('SELECT posted, title, location, FROM jobs ORDER BY posted') or die (mysql_error());// We are going to use the '$row' method for this query. This is just my preference.while ($row = mysql_fetch_array($sql_events)) { $event_date = $row['event_date']; $event_title = $row['event_title']; /* Now we do this small line which is basically going to tell PHP to alternate the colors between the two colors we defined above. */ $row_color = ($row_count % 2) ? $color1 : $color2; // Echo your table row and table data that you want to be looped over and over here. echo '<tr> <td width="110" bgcolor="$row_color" nowrap> $article_date</td> <td bgcolor="$row_color"> <a href="articles.php?cmd=full_article&article_id=$article_id">$article_title</a></td> </tr>'; // Add 1 to the row count $row_count++;}// Close out your table.echo '</table>';?> Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/ Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Also, do Dreamweaver or PHP Eclipse have native debugging utilities that automatically resolve or better describe the cause of these kinds of errors? Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102573 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 One other thing, Phil Collins is an animal. A complete animal. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102576 Share on other sites More sharing options...
Hi I Am Timbo Posted October 2, 2006 Share Posted October 2, 2006 The problem is with mismatched brackets. I'm not sure what the random brackets are, like in line 3, but they aren't needed. Remove the { around the echo and you should be fine. There is not closing bracket. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102583 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Thank you, thank you, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102588 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Does the unexpected $ error occur strictly when you've screwed up your brackets? Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102593 Share on other sites More sharing options...
.josh Posted October 2, 2006 Share Posted October 2, 2006 no. the $ is arbitrary and changes depending on the error. it points to the first thing it sees that is unexpected, following something you have done. so when you get an 'unexpected blah' error, look to the previous lines for your error Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102595 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Well, that's both interesting and daunting...because I tend to get these errors directed at the final line of the script. For example:---------------Parse error: parse error, unexpected $ in /home/content/s/t/a/starsonline/html/strippedgirl/u/output_fns.php on line 71----------------<?function do_jobs_header($title){ // print an HTML header?> <html> <head> <title><?=$title?></title> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px } hr { color: #3333cc; width=300; text-align=left} a { color: #000000 } </style> </head> <body> <img src="jobs.gif" alt="Big Ops" border=0 align=left valign=bottom height = 55 width = 57> <h1> Stripped Girl ONline</h1> <hr><? if($title) do_html_heading($title);}function display_job_listings(){?><html><head><title>Displaying MySQL Data</title></head><body>//////connection script<table><?$sql = "SELECT * FROM jobs";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<tr>";echo "<td>".$row['date']."</td>";echo "<td>".$row['title']."</td>";echo "<td>".$row['description']."</td>";echo "<td>".$row['location']."</td>";echo "<td>".$row['compensation']."</td>";echo "<td>".$row['required']."</td>";echo "<td>".$row['preferred']."</td>";echo "<td>".$row['notes']."</td>";echo "</tr>";?></table></body></html>} Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102601 Share on other sites More sharing options...
Hi I Am Timbo Posted October 2, 2006 Share Posted October 2, 2006 That's because the unexpected thing is the ?>It is expecting you to close the brackets before it quits parsing php. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102603 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Wow. That epitomizes somebody that doesn't have a clue what the hell they're doing, doesn't it? Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102604 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 You're awesome. I really, really appreciate the help. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102606 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Alright, I took the hint on the last host and tried to fix my code. I came up with this:<?function do_jobs_header($title){ // print an HTML header?> <html> <head> <title><?=$title?></title> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px } hr { color: #3333cc; width=300; text-align=left} a { color: #000000 } </style> </head> <body> <img src="jobs.gif" alt="Big Ops" border=0 align=left valign=bottom height = 55 width = 57> <h1> Stripped Girl ONline</h1> <hr><? if($title) do_html_heading($title);}function display_job_listings(){?><html><head><title>Displaying MySQL Data</title></head><body>//////connection script<table><?$sql = "SELECT * FROM jobs";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<tr>";echo "<td>".$row['date']."</td>";echo "<td>".$row['title']."</td>";echo "<td>".$row['description']."</td>";echo "<td>".$row['location']."</td>";echo "<td>".$row['compensation']."</td>";echo "<td>".$row['required']."</td>";echo "<td>".$row['preferred']."</td>";echo "<td>".$row['notes']."</td>";echo "</tr>";[color=limegreen]}?></table></body></html>}[/color]Notice how I changed the last few lines of code here to try and compensate for the error I was getting. Apparently, my solution wasn't the right one. Same error. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102614 Share on other sites More sharing options...
Destruction Posted October 2, 2006 Share Posted October 2, 2006 </html>}notice the fact your function closing bracket is outside of php tags? Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102620 Share on other sites More sharing options...
Hi I Am Timbo Posted October 2, 2006 Share Posted October 2, 2006 You don't want </table></body></html>inside your loop anyway. Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102623 Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 Granted, you're a hardcore programming maniac...I'll give you that. So I removed the HTML just to be jive...it looked like this-<?function do_jobs_header($title){ // print an HTML header?> <html> <head> <title><?=$title?></title> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 13px } li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px } hr { color: #3333cc; width=300; text-align=left} a { color: #000000 } </style> </head> <body> <img src="jobs.gif" alt="Big Ops" border=0 align=left valign=bottom height = 55 width = 57> <h1> Stripped Girl ONline</h1> <hr>}<?function display_job_listings(){?><html><head><title>Displaying MySQL Data</title></head><body>//////connection script<?$sql = "SELECT * FROM jobs";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<tr>";echo "<td>".$row['date']."</td>";echo "<td>".$row['title']."</td>";echo "<td>".$row['description']."</td>";echo "<td>".$row['location']."</td>";echo "<td>".$row['compensation']."</td>";echo "<td>".$row['required']."</td>";echo "<td>".$row['preferred']."</td>";echo "<td>".$row['notes']."</td>";echo "</tr>";}?>Still, errors on line 58. Jesus, show me the way! Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102631 Share on other sites More sharing options...
sasa Posted October 2, 2006 Share Posted October 2, 2006 you dont end your functions.Move 1st } (just after long line) in php partand in the end add one more } Quote Link to comment https://forums.phpfreaks.com/topic/22782-seeking-your-genius-parse-error-parse-error-unexpected-in/#findComment-102639 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.