Jump to content

Archived

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

bernie.nmsu

Query Help

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

Share this post


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

Share this post


Link to post
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]

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

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.