bernie.nmsu Posted January 25, 2005 Share Posted January 25, 2005 Any help is appreciated. I have not used dreamweaver in a while and I need some help with some code. I have a registration website, where folks can select a course from a course table. When they select the course, it takes them to a registration page. What I need to do now is not allow registration for a course if the course key is equal to 50. I'm getting the following error - Parse error: parse error, unexpected '?' in c:\program files\apache group\apache\htdocs\training\index.php on line 205 Here is the code I have so far. <?php while (!$Recordset1->EOF) { ?> if ($Recordset1->Fields('CourseKey')=='50') echo $Recordset1->Fields('CourseName'); echo $Recordset1->Fields('CourseDesc'); else <td><a href="indexSelection.php?courseKey=<?php echo $Recordset1->Fields('CourseKey'); ?>"><?php echo $Recordset1->Fields('CourseName'); ?/a></a></td> <td><?php echo $Recordset1->Fields('CourseDesc'); ?></td> </tr> <?php $Recordset1->MoveNext(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/ Share on other sites More sharing options...
wildteen88 Posted January 25, 2005 Share Posted January 25, 2005 Why are you continuing PHP statements in none-php mode! lol! <?php while (!$Recordset1->EOF) { ?> if ($Recordset1->Fields('CourseKey')=='50') echo $Recordset1->Fields('CourseName'); echo $Recordset1->Fields('CourseDesc'); else <td><a href="indexSelection.php?courseKey=<?php echo $Recordset1->Fields('CourseKey'); ?>"><?php echo $Recordset1->Fields('CourseName'); ?></a></a></td> <td><?php echo $Recordset1->Fields('CourseDesc'); ?></td> </tr> <?php $Recordset1->MoveNext(); } ?> change above to: <?php while (!$Recordset1->EOF) { if ($Recordset1->Fields('CourseKey')=='50') { echo $Recordset1->Fields('CourseName'); echo $Recordset1->Fields('CourseDesc'); } else { ?> <td><a href="indexSelection.php?courseKey=<?php echo $Recordset1->Fields('CourseKey'); ?>"><?php echo $Recordset1->Fields('CourseName'); ?></a></a></td> <td><?php echo $Recordset1->Fields('CourseDesc'); ?></td> </tr> <?php $Recordset1->MoveNext(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7042 Share on other sites More sharing options...
bernie.nmsu Posted January 25, 2005 Author Share Posted January 25, 2005 That sends me into an infinite loop. Any other suggestions. Why are you continuing PHP statements in none-php mode! lol! <?php while (!$Recordset1->EOF) { ?> if ($Recordset1->Fields('CourseKey')=='50') echo $Recordset1->Fields('CourseName'); echo $Recordset1->Fields('CourseDesc'); else <td><a href="indexSelection.php?courseKey=<?php echo $Recordset1->Fields('CourseKey'); ?>"><?php echo $Recordset1->Fields('CourseName'); ?></a></a></td> <td><?php echo $Recordset1->Fields('CourseDesc'); ?></td> </tr> <?php $Recordset1->MoveNext(); } ?> change above to: <?php while (!$Recordset1->EOF) { if ($Recordset1->Fields('CourseKey')=='50') { echo $Recordset1->Fields('CourseName'); echo $Recordset1->Fields('CourseDesc'); } else { ?> <td><a href="indexSelection.php?courseKey=<?php echo $Recordset1->Fields('CourseKey'); ?>"><?php echo $Recordset1->Fields('CourseName'); ?></a></a></td> <td><?php echo $Recordset1->Fields('CourseDesc'); ?></td> </tr> <?php $Recordset1->MoveNext(); } } ?> 197547[/snapback] Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7043 Share on other sites More sharing options...
WarpedNoodle Posted January 25, 2005 Share Posted January 25, 2005 Your loop logic is flawed. You have a while statement that says (by pseudo-coding) "So long as I don't have this condition met (while (!$Recordset1->EOF)), do this. Otherwise, do that. The problem is, you don't have any means of terminating the "if not" condition. Usually the "if not" condition is met by incrementing the variable in the "if it does" statement. If this is not practical for your given situation, then the "while" loop is not the way to go. Rather, a nested "if, else" conditional might suit your needs. Good luck, Trev Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7045 Share on other sites More sharing options...
bernie.nmsu Posted January 25, 2005 Author Share Posted January 25, 2005 I need my while statement to loop through, because I'm placing the course's into a field. I'm getting my data from a related table. Any other suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7046 Share on other sites More sharing options...
bernie.nmsu Posted January 25, 2005 Author Share Posted January 25, 2005 **Closed** I was missing some brackets. Quote Link to comment https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7047 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.