Jump to content

Deleting Messages with checkboxes - Error Messages


dannyp100

Recommended Posts

The actual code works fine to display messages to be deleted.

There seems to be this error that pops up:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

Its on the line that i've put in bold

 

<?php
include 'gradnetconn.php';
require_once ('webpage.class.php');
include 'functions.php';
session_start();
require_once ('webpage.class.php');
$page = new webpage( "GradNet", array( "test.css", "style.css" ) );
$messageTo = $_SESSION['userID'];
   if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) {
   $display.= "Log in to send a message" ;
   header ("Location: login.php");
   exit();
  } else {
  $display.= "You aree logged in, please feel free to delete a message ";
 }
  $sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0'
   ORDER BY messageDate DESC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>

<?php

while($rows=mysql_fetch_array($result)) {

$display.="<td><form name=\"form1\" method=\"post\" action=\"deletemessagesprocess.php\">
<table width=\"400\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
<tr>
<td> </td>
<strong>Delete A Message</strong> </td>
</tr>
<tr>
<td> <strong>Message ID</strong></td>
<td> <strong>From</strong></td>
<td> <strong>Subject</strong></td>
<td> <strong>Messge Contents</strong></td>
</tr>
[b]<tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"</tr></td>[/b]
<td>\"$rows['messageID']\"</td>
<td>\"$rows['messageFrom']\"</td>
<td>\"$rows['messageSubject']\"</td>
<td>\"$rows['messageBody']\"</td>
</tr><tr>
<td colspan=\"5\" align=\"center\"<input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\"></td>
</tr></table>
</form>
</td>
</tr>
</table>";
}
$page->addToBody( "
<div id=\"content\">
 $display
 </div>
 ");
echo $page->getPage();
?>

 

Any help would be great!

Besides you missing your closing > in your HTML, it looks fine. If there were a syntax error it should show up in the highlighted code. 

 

You should probably switch to using HEREDOC though, rather than escaping every quote. 

 

I've done a heredoc and an error still appears

 

<?php
include 'gradnetconn.php';
require_once ('webpage.class.php');
include 'functions.php';
session_start();
require_once ('webpage.class.php');
$page = new webpage( "GradNet", array( "test.css", "style.css" ) );
$messageTo = $_SESSION['userID'];
   if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) {
   $display.= "Log in to send a message" ;
   header ("Location: login.php");
   exit();
  } else {
  $display.= "You aree logged in, please feel free to delete a message ";
 }
  $sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0'
   ORDER BY messageDate DESC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>

<?php

while($rows=mysql_fetch_array($result)) {

$displayform =<<<deleteform
<td><form name=\"form1\" method=\"post\" action=\"deletemessagesprocess.php\">
<table width=\"400\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
<tr>
<td> </td>
<strong>Delete A Message</strong> </td>
</tr>
<tr>
<td> <strong>Message ID</strong></td>
<td> <strong>From</strong></td>
<td> <strong>Subject</strong></td>
<td> <strong>Messge Contents</strong></td>
</tr>
<tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"></td></tr>
<td>\"$rows['messageID']\"</td>
<td>\"$rows['messageFrom']\"</td>
<td>\"$rows['messageSubject']\"</td>
<td>\"$rows['messageBody']\"</td>
</tr><tr>
<td colspan=\"5\" align=\"center\"<input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\"></td>
</tr></table>
</form>
</td>
</tr>
</table>
}
deleteform;

$page->addToBody( "
<div id=\"content\">
 $displayform
 </div>
 ");
echo $page->getPage();
?>

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in on line 47

on this line <tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"></td></tr>

Took the escape quotes etc and there still an error on the same line

 

<?php
include 'gradnetconn.php';
require_once ('webpage.class.php');
include 'functions.php';
session_start();
require_once ('webpage.class.php');
$page = new webpage( "GradNet", array( "test.css", "style.css" ) );
$messageTo = $_SESSION['userID'];
   if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) {
   $display.= "Log in to send a message" ;
   header ("Location: login.php");
   exit();
  } else {
  $display.= "You aree logged in, please feel free to delete a message ";
 }
  $sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0'
   ORDER BY messageDate DESC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>

<?php

while($rows=mysql_fetch_array($result)) {

$displayform.=<<<deleteform
<td><form name="form1" method="post" action="deletemessagesprocess.php">
<table width="400" border="0" cellpadding="3" cellspacing="1">
<tr>
<td> </td>
<strong>Delete A Message</strong> </td>
</tr>
<tr>
<td> <strong>Message ID</strong></td>
<td> <strong>From</strong></td>
<td> <strong>Subject</strong></td>
<td> <strong>Messge Contents</strong></td>
</tr>
<tr><td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="$rows['messageID']"></td></tr>
<td>$rows['messageID']</td>
<td>$rows['messageFrom']</td>
<td>$rows['messageSubject']</td>
<td>$rows['messageBody']</td>
</tr><tr>
<td colspan="5" align="center"<input name="delete" type="submit" id="delete" value="Delete"></td>
</tr></table>
</form>
</td>
</tr>
</table>

deleteform;
}

$page->addToBody( "
<div id=\"content\">
 $displayform
 $display
 </div>
 ");
echo $page->getPage();
?>

 

so confusing!

$display.="<tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"></tr></td>

 

this is the line that the error is on. is it something to do with this part

value=\"$rows['messageID']\">

 

?

<?php
include 'gradnetconn.php';
require_once ('webpage.class.php');
include 'functions.php';
session_start();
require_once ('webpage.class.php');
$page = new webpage( "GradNet", array( "test.css", "style.css" ) );
$messageTo = $_SESSION['userID'];
if (!(isset($_SESSION['userID']) && $_SESSION['userID'] != '')) {
$display.= "Log in to send a message" ;
header ("Location: login.php");
exit();
} else {
$display.= "You aree logged in, please feel free to delete a message ";
}
$sql="SELECT * FROM gn_messages WHERE messageTo = $messageTo AND messageDeleted = '0'
    ORDER BY messageDate DESC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<?php
while($rows=mysql_fetch_array($result)) {
$display.="<td><form name=\"form1\" method=\"post\" action=\"deletemessagesprocess.php\">
<table width=\"400\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
<tr>
<td> </td>
<strong>Delete A Message</strong> </td>
</tr>
<tr>
<td> <strong>Message ID</strong></td>
<td> <strong>From</strong></td>
<td> <strong>Subject</strong></td>
<td> <strong>Messge Contents</strong></td>
</tr>";

$display.="<tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"></tr></td>
<td>\"$rows['messageID']\"</td>
<td>\"$rows['messageFrom']\"</td>
<td>\"$rows['messageSubject']\"</td>
<td>\"$rows['messageBody']\"</td>
</tr><tr>
<td colspan=\"5\" align=\"center\"<input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\"></td>
</tr></table>
</form>
</td>
</tr>
</table>";
}
$page->addToBody( "
<div id=\"content\">
 $display
 </div>
 ");
echo $page->getPage();
?>

 

Thats the code, the line the error is on is:

 

$display.="<tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"></tr></td>

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.