Page 1 of 1
[SOLVED] cant figure out error T_CONSTANT_ENCAPSED_STRING
Posted: Thu Nov 13, 2003 3:38 pm
by netooi
Code: Select all
// If the user did better this time, record the better grade.
if ($mygradeї0] < $score)
$result = mysql_query("UPDATE userquizlesson SET grade = '$score' where name = '$name' and pword = '$pword' and lessonnumber = '$lesson' and quiznumber = '$quiz'", $link_id);
// If the user made >= 75 for the first time, mark them as passing, and let them take the next lesson.
if ($score >= 75 && $mygradeї0] < 75)
{
// update lessonnumber or quiznumber.
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson"', $link_id);
$num_quizzes = mysql_num_rows($result);
// if this is the last quiz in the lesson, increment the lessonnumber
if ($quiz == $num_quizzes)
{
//will have to add check later to see if its the final lesson.
$lesson = $lesson + 1;
$result = mysql_query("UPDATE userquizlesson SET lessonnumber = '$lesson' where name = '$name' and pword = '$pword'", $link_id);
}
// else increment the quiznumber
else
{
$quiz++;
$result = mysql_query("UPDATE userquizlesson SET quiznumber = '$quiz' where name = '$name' and pword = '$pword'", $link_id);
}
}
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in c:\webpages\dbaccess.inc on line 163
Line 163 is the sql query inside the if ($quiz == $num_quizzes) block
Thanks for any help
Posted: Thu Nov 13, 2003 3:43 pm
by Cruzado_Mainfrm
take a deep look here, and see that the string there starts with " quotes and ends prematurely at $lesson" and after that there's another quote ('), fix that and problem solved
Code: Select all
<?php
// update lessonnumber or quiznumber.
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson"', $link_id);
?>
Posted: Thu Nov 13, 2003 3:44 pm
by Weirdan
look at this string:
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson"', $link_id);
Posted: Thu Nov 13, 2003 3:44 pm
by matthiasone
well you have
Code: Select all
// update lessonnumber or quiznumber.
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson"', $link_id);
Should be
Code: Select all
// update lessonnumber or quiznumber.
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson'", $link_id);
The double quote and the single quote are in the wrong order
Posted: Thu Nov 13, 2003 3:45 pm
by Cruzado_Mainfrm
lol we all posted at the same time
Posted: Thu Nov 13, 2003 3:57 pm
by netooi
thank you thank you thank you
Sometimes its easy to go blind when looking at your own code:)
Posted: Thu Nov 13, 2003 4:21 pm
by Paddy
Get yourself a teddy bear and explain your code to it. You are bound to see the problem then.

Posted: Fri Nov 14, 2003 3:09 am
by twigletmac
Paddy wrote:Get yourself a teddy bear and explain your code to it. You are bound to see the problem then.

This really made me laugh - it's a fantastic idea.
Mac
Posted: Fri Nov 14, 2003 6:03 am
by devork
Paddy wrote:Get yourself a teddy bear and explain your code to it. You are bound to see the problem then.


Posted: Fri Nov 14, 2003 4:04 pm
by Paddy
twigletmac wrote:Paddy wrote:Get yourself a teddy bear and explain your code to it. You are bound to see the problem then.

This really made me laugh - it's a fantastic idea.
Mac
Yeah, it was actually taught to us by a lecturer. Saves the humiliation of asking a human cos as soon as you start explaining what you are trying to do to someone you see the error of your ways. Teddy bears don't laugh at you. Coffee mugs work as well.
