Jump to content

Recommended Posts

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();
 }
?>

Link to comment
https://forums.phpfreaks.com/topic/2145-query-help/
Share on other sites

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();
 }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7042
Share on other sites

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]

 

Link to comment
https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7043
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/2145-query-help/#findComment-7045
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.