Page 1 of 1

parse error, unexpected $

Posted: Wed Oct 22, 2008 4:11 pm
by kuhlpal
Hi Everyone,

I am new to PHP and working on table updation. My company has its own style of writing the code. I am getting a blank page on including this file. On using a debugger. i got parse error: unexpected $

Here is the code:

Code: Select all

<?
//////////////////////////////////////////////
// PrintInv Class
// Represents the date of print invoices
/////////////////////////////////////////////
 
require_once ("$inc_path/db/db_record.inc");
require_once ("$inc_path/db/clinic.inc");
require_once ("$inc_path/db/patient.inc");
require_once ("$inc_path/db/purchase.inc");
require_once ("$inc_path/transaction.inc);
 
class PrintInv extends DBRecord {
 
var $patient;
var $clinic;
var $purchase;
var $transaction;
 
  //////////////////////////////////////////
  // CONSTRUCTOR
  // called when new object is instantiated
  /////////////////////////////////////////
 
 
function PrintInv($id=0) {
 
$this->DBRecord('invoice_print', 'inv_id', $id);
 
/////////////////////////////////////////////////////////////////////////////
//where invoice_print is the new table to store current date .
//patient_id, clinic_id and purchase_id are the foreign keys in this table
////////////////////////////////////////////////////////////////////////////
 
//Patient constructor is called 
if ($this->get('patient_id')) {
    $this->patient = new Patient($this->get('patient_id'));
    if (!$this->patient->get('patient_name')) {
      $this->patient = 0;
    }
}
 
//Clinic constructor is called
if ($this->get('clinic_id')) {
    $this->clinic = new Clinic($this->get('clinic_id'));
    if (!$this->clinic->get('clinic_name')) {
      $this->clinic = 0;
    }
}
 
//Purchase constructor is called
if ($this->get('purchase_id')) {
    $this->purchase = new Purchase($this->get('purchase_id'));
    if (!$this->purchase->get('purchase_type')) {
    $this->purchase = 0;
    }
}
 
//Transaction constructor is called
if ($this->get('transaction_no')) {
    $this->transaction = new Transaction($this->get('transaction_no'));
    }
}
 
function storeNew() {
 
$this->set('invoice_no', this->transaction->get('invoice_no'));
$this->set('print_date', date('Y-m-d'));
 
$id = parent::storeNew();
 
return $id;
}
 
}
 
?>
I have no idea what am i doing wrong. Any help will be appreciated.

Thanks

Re: parse error, unexpected $

Posted: Wed Oct 22, 2008 4:35 pm
by jaoudestudios
What line is the error on?

Re: parse error, unexpected $

Posted: Wed Oct 22, 2008 4:43 pm
by requinix

Code: Select all

$this->set('invoice_no', this->transaction->get('invoice_no'));
There's an error, probably unrelated though.

Re: parse error, unexpected $

Posted: Wed Oct 22, 2008 5:21 pm
by kuhlpal
Thanks for the reply.

It says that the error is on last line 77.

I have to access the invoice_no field and transaction class (NOT a database class) is used as a handy container for some of the common fields. That is why i am using an object of transaction class and setting the invoice_no accordingly. Do you think that accessing the invoice_no this way is incorrect. "invoice_no" field is also present in purchase table, Is there any other way to do it.

Once again thanks for the help.

Re: parse error, unexpected $

Posted: Wed Oct 22, 2008 7:35 pm
by requinix
Hey kuhlpal, can you do a favor for me? Go back to your first post and change the [syntax=php]tags to[/syntax][syntax=php].
And post the ENTIRE error message, not just part of it.

With those two things done the problem should become clear.[/syntax]

Re: parse error, unexpected $

Posted: Thu Oct 23, 2008 12:26 am
by jaoudestudios
Plus, the line number you posted, is that reference to your lines in your text editor or the lines in your first post?

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 1:59 pm
by kuhlpal
Thank you tasairis and jaoudestudios for looking at my problem.

The complete error message is
Errors:
Parse error: parse error, unexpected $ in print_inv.inc on line 77

The complete code is here:

Code: Select all

 
   1. <?
   2. //////////////////////////////////////////////
   3. // PrintInv Class
   4. // Represents the date of print invoices
   5. /////////////////////////////////////////////
   6.  
   7. require_once ("$inc_path/db/db_record.inc");
   8. require_once ("$inc_path/db/clinic.inc");
   9. require_once ("$inc_path/db/patient.inc");
  10. require_once ("$inc_path/db/purchase.inc");
  11. require_once ("$inc_path/transaction.inc);
  12.  
  13. class PrintInv extends DBRecord {
  14.  
  15. var $patient;
  16. var $clinic;
  17. var $purchase;
  18. var $transaction;
  19.  
  20.   //////////////////////////////////////////
  21.   // CONSTRUCTOR
  22.   // called when new object is instantiated
  23.   /////////////////////////////////////////
  24.  
  25.  
  26. function PrintInv($id=0) {
  27.  
  28. $this->DBRecord('invoice_print', 'inv_id', $id);
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. //where invoice_print is the new table to store current date .
  32. //patient_id, clinic_id and purchase_id are the foreign keys in this table
  33. ////////////////////////////////////////////////////////////////////////////
  34.  
  35. //Patient constructor is called
  36. if ($this->get('patient_id')) {
  37.     $this->patient = new Patient($this->get('patient_id'));
  38.     if (!$this->patient->get('patient_name')) {
  39.       $this->patient = 0;
  40.     }
  41. }
  42.  
  43. //Clinic constructor is called
  44. if ($this->get('clinic_id')) {
  45.     $this->clinic = new Clinic($this->get('clinic_id'));
  46.     if (!$this->clinic->get('clinic_name')) {
  47.       $this->clinic = 0;
  48.     }
  49. }
  50.  
  51. //Purchase constructor is called
  52. if ($this->get('purchase_id')) {
  53.     $this->purchase = new Purchase($this->get('purchase_id'));
  54.     if (!$this->purchase->get('purchase_type')) {
  55.     $this->purchase = 0;
  56.     }
  57. }
  58.  
  59. //Transaction constructor is called
  60. if ($this->get('transaction_no')) {
  61.     $this->transaction = new Transaction($this->get('transaction_no'));
  62.     }
  63. }
  64.  
  65. function storeNew() {
  66.  
  67. $this->set('invoice_no', this->transaction->get('invoice_no'));
  68. $this->set('print_date', date('Y-m-d'));
  69.  
  70. $id = parent::storeNew();
  71.  
  72. return $id;
  73. }
  74.  
  75. }
  76.  
  77. ?>
 
 
I am stuck at this point and cannot move further in my project. Any help will be appreciated.

Thanks in advance.

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 2:06 pm
by requinix
(sigh)
Unexpected $end on line 77.
Line 11 is missing a quotation mark.

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 3:52 pm
by kuhlpal
Thanks tasairis. I was able to get rid of that problem and you were right about

Code: Select all

 
$this->set('invoice_no', this->transaction->get('invoice_no'));
 
and now i am getting error at this line. I probably need to change this->transaction->get('invoice_no').

Thanks again.

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 3:53 pm
by Syntac

Code: Select all

$this->set('invoice_no', $this->transaction->get('invoice_no'));

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 4:11 pm
by kuhlpal
Thanks Syntac!! There are no more syntax error.

Re: parse error, unexpected $

Posted: Tue Oct 28, 2008 6:46 pm
by kuhlpal
Hi Everyone,

Can anyone tell me what are the reasons of getting a blank page for .php file. I am including one file into existing .php file and due to the new include i am getting a blank page. I have checked that there is no syntax error in the include file. According to me the logic is also correct. Is there any other possible error?

Also, my php.ini file should have following setting:
* error_reporting = E_ALL

* display_errors = on

Thank you for the help.

Re: parse error, unexpected $

Posted: Fri Oct 31, 2008 2:06 pm
by kuhlpal
Hey Guys,

My Mistake!! The problem was with syntax, i was missing the parenthesis in include_once statement. However, the debugger was unable to detect the error. I am not getting that blank page anymore.

Thanks for your help!!

Re: parse error, unexpected $

Posted: Fri Oct 31, 2008 5:46 pm
by Syntac
Include(_once)/require(_once) statements shouldn't need parantheses.