hello,

i'm new in PHP coding. Please help me in solving this error.


Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\testdate.php on line 49

Line 49 is :Valid Oxygen:$oxygenmin-$oxygenmax

I attach together the whole coding for my project:

<?php

require("phpmailer/class.phpmailer.php");

$db_connect=mysql_connect("localhost","root","");
if(!$db_connect)
 {
 	die("Could not connect:".mysql_error()); 
 
 }
mysql_select_db("mpob",$db_connect);

/****2)RETRIEVE DATA FROM VALID PARAMETER****/

$query1="SELECT oxygenmin,oxygenmax,carbondioxsidemin,carbondioxsidemax FROM validparameter";

$result=mysql_query($query1);
list($oxygenmin,$oxygenmax,$carbondioxsidemin,$carbondioxsidemax)=mysql_fetch_row($result);
	
/***RETRIEVE DATA FROM CURRENT PARAMETER****/

$query = "SELECT *FROM currentparameter WHERE oxygen<$oxygenmin OR oxygen >$oxygenmax OR carbondioxside <$carbondioxsidemin OR carbondioxside >$carbondioxsidemax";
//echo $query;
$result2=mysql_query($query);

list($oxygen,$carbondioxside)=mysql_fetch_row($result2);



/***PARAMETER EXCEED***/

while(list($oxygen,$carbondioxside)=mysql_fetch_row($result2))
{

/**** FUNCTION EMAIL & SMS NOTIFICATION***/
//echo $oxygenmin,"---",$oxygenmax,"---",$carbondioxsidemin,"---",$carbondioxsidemax,"---",$oxygen,"---",$carbondioxside;
sendnotification($oxygenmin,$oxygenmax,$carbondioxsidemin,$carbondioxsidemax,$oxygen,$carbondioxside);
$msgText="TISSUE CULTURE PARAMETER EXCEED!!!"

Valid Oxygen:$oxygenmin-$oxygenmax <br>
Valid Carbon Dioxside:$carbondioxsidemin-$carbondioxsidemax <br>

*************************

Current Oxygen : $oxygen  
Current Carbon Dioxside : $carbondioxside

$smsalert="<br><br><br>MPOB SMS ALERT</br>:<br>Valid Parameter Range Of Tissue Culture Exceed!
<br>Kindly please check your sms
<br>**********************************************<br><br>";
SendSMS("127.0.0.1","username","password","+0134632858",$msgText);
 echo $smsalert;

}

/***EMAIL NOTIFICATION***/

function sendnotification($oxygenmin,$oxygenmax,$carbondioxsidemin,$carbondioxsidemax,$oxygen,$carbondioxside) {

//require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer(); 
$mail->IsSMTP(); // send via SMTP
//IsSMTP(); // send via SMTP
$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server
$mail->Port = 465; // set the port to use
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "systemmpob@gmail.com"; // SMTP username
$mail->Password = "mpobsystem"; // SMTP password
$webmaster_email = "systemmpob@gmail.com"; //Reply to this email ID
$email="mpob2011@gmail.com"; // Recipients email ID
$name="mpobuser"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "MPOB ALERT SYSTEM";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"MPOB ALERT SYSTEM");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "GASEOUS ALERT SYSTEM IN MPOB TISSUE CULTURE LAB";
$mail->Body = "<br> Hello,<br>
<br>VALID PARAMETER RANGE OF TISSUE CULTURE HAS EXCEEDED!!!
<br>
############################################################<br>
<br>
	Valid Oxygen	:$oxygenmin-$oxygenmax<br>
	Valid Carbon Dioxside	:$carbondioxsidemin-$carbondioxsidemax<br>
	
	<br>
	
	Current Oxygen :$oxygen <br>
	Current Carbon Dioxside :$carbondioxside<br>
	<br>
	
	Regard,<br>
	<br>MPOB Support Team<br>"; //HTML Body
	
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "<br><br><br>MPOB EMAIL ALERT</b>:<br>Valid Parameter Range Of Tissue Culture Exceeded!!<br>
	Kindly please check your email";
}
}

/***FUNCTION TO SEND SMS NOTIFICATION***/

function SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText) { 

/* Parameters:
    $host - IP address or host name of the NowSMS server
    $port - "Port number for the web interface" of the NowSMS Server
    $username - "SMS Users" account on the NowSMS server
    $password - Password defined for the "SMS Users" account on the NowSMS Server
    $phoneNoRecip - One or more phone numbers (comma delimited) to receive the text message
    $msgText - Text of the message
*/
 
    $fp = fsockopen($host, $port, $errno, $errstr);
    if (!$fp) {
        echo "errno: $errno \n";
        echo "errstr: $errstr\n";
        return $result;
    }
    
    fwrite($fp, "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) . " HTTP/1.0\n");
    if ($username != "") {
       $auth = $username . ":" . $password;
       $auth = base64_encode($auth);
       fwrite($fp, "Authorization: Basic " . $auth . "\n");
    }
    fwrite($fp, "\n");
  
    $res = "";
 
    while(!feof($fp)) {
        $res .= fread($fp,1);
    }
    fclose($fp);
    
 
    return $res;
}

?>

Make sure you properly mark the closing of a statement using semi-colons. In your code, for instance, the following statement needs closing.

$msgText="TISSUE CULTURE PARAMETER EXCEED!!!"; //add semi colon if this is the end of the statement.

If the following lines are a part of this statement, then concatenate the strings using '+' (with out single quotes). While doing so, make sure you enclose the string parts with double quotes.

It is difficult to read your code so please wrap your codes in CODE tags.

Hope this helps.

I just realised a terrible mistake in my explanation. To concatenate use '.' (dot without quotes) not '+'. I hope the earlier explanation did not confuse you since you already have concatenated a few strings. Cheers.

+ also works ;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.