Jump to content

[SOLVED] unexpected '{',


jeff5656

Recommended Posts

I get this error: syntax error, unexpected '{', expecting ';' in C:\wamp\www\warren\billing\editdos.php on line 24

 

<?php	

do {
echo $row['patient'];
}
while ($row = mysql_fetch_assoc ($result)) {	
echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
echo "</tr>";

}


}	
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/
Share on other sites

you are using do/while wrong it should probably be:

 

<?php   
while ($row = mysql_fetch_assoc ($result)) {   
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713658
Share on other sites

Then how do I echo $row['patient'] BEFORE the while loop (because it is the same in every row)?  If I echo it before then the first record gets skipped when I do the while loop.

 

See this output, patient is same so I want to put patient as a header before the table:

 

Patient	MRN	Billing date	Billing level	Diagnoses
brooks, jeffrey	8001188971	0000-00-00	hpl	khkh, khkh, khkjh, jhkh, , , , , , 
brooks, jeffrey	8001188971	2008-12-09	consm	copd, copd, chf, pneumonia, , , , , , 
brooks, jeffrey	8001188971	2008-12-10	hph	, , , , , , , , , 
brooks, jeffrey	8001188971	2008-12-11	consl	, , , , , , , , , 

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713665
Share on other sites

<?php   
while ($row = mysql_fetch_assoc ($result)) {   
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

 

You're echoing $row['patient'] within the loop?

 

A

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713669
Share on other sites

<?php
for($n=0;$row = mysql_fetch_assoc ($result);$n++) {
   if(!$n){
      echo $row['patient'];
   }
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713671
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.