Daveyboy Posted December 28, 2006 Share Posted December 28, 2006 Something that was not quite clear to me. I realize you have to have the html tags outside of the php tags as follows;[sup]<html> <body><?phpecho 'test';?></body></html>[/sup]However, when I have the following I get "Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in C:\wamp\www\alternaterows.php on line 8" , the "100%" "0" are flagged, is this because of a php html conflict? How do I fix?[sup]<html><body><?phperror_reporting(E_ALL);// Begin your table outside of the arrayecho "<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>";include ("./mysql_connect_databasetest.php");// Define your colors for the alternating rows$color1 = "#CCFFCC"; $color2 = "#BFD8BC"; $row_count = 0;// Perform an statndard SQL query:$sql_events = mysql_query("SELECT * FROM info ORDER BY `id` ASC") 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)) { $id = $row["id"]; $firstname = $row["firstname"]; /* 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>";?></body></html>[/sup] Link to comment https://forums.phpfreaks.com/topic/32104-solved-php-with-html/ Share on other sites More sharing options...
kenrbnsn Posted December 28, 2006 Share Posted December 28, 2006 You're getting that error because you have unescaped double quotes inside the string you are echoing that is delimited by double quotes. You can either escape the double quotes or use single quotes to delimite the string.Examples:[code]<?phpecho "This string is ok<br>";echo 'This string is also ok<br>';echo 'This string contains double quotes " " and is ok';echo "This string also contains double quotes \" \" and is ok";echo "This string also contains double quotes " " but is not ok";echo "This string contains single quotes ' ' and is ok";?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/32104-solved-php-with-html/#findComment-148983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.