Jump to content

Recommended Posts

I am desperately trying to figure out what is wrong with this code i have written, but can't for the life of me work it out.

 

Help please..

 

The problem is with line 11 - An error keeps popping up, saying:

 

"Parse error, unexpected T_variable on line 11" and i cannot see it.

 

Here is the code below:

 

 

<?php

      function confirm_query($result_set){

  if (!$result_set) {

    die("Database query failed: " . mysql_error());

}

}

function get_all_subjects() {

        $query = "SELECT *

          FROM first_table

          ORDER BY position ASC"

      $subject_set = mysql_query($query, $connection);

 

confirm_query($subject_set);

 

      return $subject_set;

}

 

function get_pages_for_subject($subject_id) {

 

   

$query1 = "SELECT * FROM tablepages

              WHERE subject_id = {$subjects_id}

      ORDER BY position ASC";

      $page_set = mysql_query($query1, $connection);

    confirm_query($page_set);

    return $page_set;

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/180197-syntax-t_variable-error/
Share on other sites

1. Welcome to PHPFreaks  :hail_freaks:

2. please use code tags (#)

3. See comment

<?php
      function confirm_query($result_set){
        if (!$result_set) {
              die("Database query failed: " . mysql_error());
               }
    }
       function get_all_subjects() {
         $query = "SELECT *
                FROM first_table
                ORDER BY position ASC" //<-- MISSING ;
      $subject_set = mysql_query($query, $connection);
                        
             confirm_query($subject_set);
             
                  return $subject_set;
    }
   
    function get_pages_for_subject($subject_id) {
      
     
       $query1 = "SELECT * FROM tablepages
                     WHERE subject_id = {$subjects_id}
                      ORDER BY position ASC";
                         $page_set = mysql_query($query1, $connection);
                            confirm_query($page_set);
                               return $page_set;
    }
   
    ?>

 

4. TIP: always check the lines above and below the error line

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.