[SOLVED] cant figure out error T_CONSTANT_ENCAPSED_STRING

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
netooi
Forum Newbie
Posts: 6
Joined: Thu Nov 13, 2003 3:38 pm

[SOLVED] cant figure out error T_CONSTANT_ENCAPSED_STRING

Post by netooi »

Code: Select all

// If the user did better this time, record the better grade.
    if ($mygrade&#1111;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&#1111;0] < 75)
    &#123;
      
      // 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)
      &#123;
        //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);
      &#125;
      // else increment the quiznumber
      else
      &#123;
        $quiz++;
        $result = mysql_query("UPDATE userquizlesson SET quiznumber = '$quiz' where name = '$name' and pword = '$pword'", $link_id);              
      &#125;
    &#125;

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
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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); 
?>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

look at this string:
$result = mysql_query("SELECT quiznumber from lessonquiz where lessonnumber = '$lesson"', $link_id);
Last edited by Weirdan on Thu Nov 13, 2003 3:45 pm, edited 1 time in total.
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post 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
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

lol we all posted at the same time
netooi
Forum Newbie
Posts: 6
Joined: Thu Nov 13, 2003 3:38 pm

Post by netooi »

thank you thank you thank you

Sometimes its easy to go blind when looking at your own code:)
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Get yourself a teddy bear and explain your code to it. You are bound to see the problem then. :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

Paddy wrote:Get yourself a teddy bear and explain your code to it. You are bound to see the problem then. :)
:lol:
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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. ;)
Post Reply