strings ...
Moderator: General Moderators
strings ...
I have this piece of code:
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid = $this->groupid"; //line 46
and I get this error:
Parse error: parse error in ... .php on line 46
I was under the impression that double quotes is usable for strings, and moreover, required if you want to include a variable name within the quotes.
Whats wrong??
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid = $this->groupid"; //line 46
and I get this error:
Parse error: parse error in ... .php on line 46
I was under the impression that double quotes is usable for strings, and moreover, required if you want to include a variable name within the quotes.
Whats wrong??
Try heredoc
:
Or maybe also:
-Nay
Code: Select all
var $query2 = <<< SQL
SELECT studentid, _uid FROM lw_students WHERE groupid = $this->groupid
SQL;Code: Select all
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid = '" . $this->groupid; . "'";Not Sure....
but wudn't this work like this ??
the second option Nay gave looks like best way to me, but just a thought.
but wudn't this work like this ??
Code: Select all
<?php
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid = '$this->groupid'";
?>Ahh, the Nay is in boldigoy wrote:Not Sure....
but wudn't this work like this ??
the second option Nay gave looks like best way to me, but just a thought.Code: Select all
<?php var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid = '$this->groupid'"; ?>
-Nay
here is the class definition. i've been playing around with the string contatenation but still recieve parse errors ...
-----
class cronTimesheetEmail{
var $ownEntryArray = array();
var $groupStudents = array();
var $groupid;
var $userID;
var $studentID;
var $ownEntry;
var $approvalEntryID;
var $studentApprovalEntryID;
var $entryTime;
var $emailAddress;
var $message = "There are Timesheets that have been pending your review for more than 3 days. Please take care of this soon.";
var $subject = "LUDWING Timesheets awaiting your review";
var $query1 = "SELECT groupid FROM lw_groups";
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid ='".$this->groupid."'";
var $query3 = "SELECT entryid, whensubmitted FROM lw_timesheets WHERE studentid ='".$this->studentID."'";
var $temp1 = 'SELECT lw_timesheetapprovals.entryid, lw_timesheetapprovals.studentid, TO_DAYS(lw_timesheets.whensubmitted) As submitted';
var $temp2 = 'FROM lw_timesheetapprovals, lw_timesheets';
var $temp3 = 'WHERE lw_timesheetapprovals.entryid = lw_timesheets.entryid ';
var $quer4 = $temp1." ".$temp2." ".$temp3;
var $query5 = "SELECT email FROM lw_users WHERE _uid ='".$this->userID."'";
function queryErrorCheck( $result )
{
if (!$result)
{
$msg = 'MySQL error #' . mysql_errno() . ": " . mysql_error();
reportError($msg, __FILE__, __LINE__);
}
}
}
-----
class cronTimesheetEmail{
var $ownEntryArray = array();
var $groupStudents = array();
var $groupid;
var $userID;
var $studentID;
var $ownEntry;
var $approvalEntryID;
var $studentApprovalEntryID;
var $entryTime;
var $emailAddress;
var $message = "There are Timesheets that have been pending your review for more than 3 days. Please take care of this soon.";
var $subject = "LUDWING Timesheets awaiting your review";
var $query1 = "SELECT groupid FROM lw_groups";
var $query2 = "SELECT studentid, _uid FROM lw_students WHERE groupid ='".$this->groupid."'";
var $query3 = "SELECT entryid, whensubmitted FROM lw_timesheets WHERE studentid ='".$this->studentID."'";
var $temp1 = 'SELECT lw_timesheetapprovals.entryid, lw_timesheetapprovals.studentid, TO_DAYS(lw_timesheets.whensubmitted) As submitted';
var $temp2 = 'FROM lw_timesheetapprovals, lw_timesheets';
var $temp3 = 'WHERE lw_timesheetapprovals.entryid = lw_timesheets.entryid ';
var $quer4 = $temp1." ".$temp2." ".$temp3;
var $query5 = "SELECT email FROM lw_users WHERE _uid ='".$this->userID."'";
function queryErrorCheck( $result )
{
if (!$result)
{
$msg = 'MySQL error #' . mysql_errno() . ": " . mysql_error();
reportError($msg, __FILE__, __LINE__);
}
}
}
Ahhh... you have non-constant initializer. You can't do it in PHP4.
use constructor instead:
[edit]
Forgot to add `$this->` before the `$query5`. Just used to use C++
[/edit]
use constructor instead:
Code: Select all
//...skipped....
var $query5;
//....skipped....
function cronTimesheetEmail(){ //constructor
//....skipped....
$this->query5 = "SELECT email FROM lw_users WHERE _uid ='".$this->userID."'";
//...skipped....Forgot to add `$this->` before the `$query5`. Just used to use C++
[/edit]
Last edited by Weirdan on Wed Dec 10, 2003 3:11 pm, edited 1 time in total.