dannyp100 Posted February 11, 2013 Share Posted February 11, 2013 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! Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 error is on this line <tr><td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$rows['messageID']\"</tr></td> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 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. Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 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> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 The whole point of using heredoc is so you don't have to escape quotes. You ended your heredoc after your closing }. Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 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! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 That doesn't make sense to me. As I said even the original version doesn't have a PHP syntax error. Are you sure it's that file? Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 $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']\"> ? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 That line is missing the closing " and ; If you want help you need to post the actual code. Now you're concatenating the string when before it was one big string. Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 <?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 Quote Link to comment Share on other sites More sharing options...
Barand Posted February 11, 2013 Share Posted February 11, 2013 (edited) Although not always necessary I put array variables in {} when inside strings {$rows['messageID']} Edited February 11, 2013 by Barand Quote Link to comment Share on other sites More sharing options...
dannyp100 Posted February 11, 2013 Author Share Posted February 11, 2013 Thankyou! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.