marcus Posted December 15, 2006 Share Posted December 15, 2006 Making a view email thingy, just keep getting the same error, can't find the problem.[code]<?phprequire('../header.php');if(!$_SESSION['admin']){header ("Location: login.php");}else { $act = $_GET['act']; $p = $_GET['p']; if(!$act){ echo "Choose: <a href='emails.php?act=view'>View Unread</a> | <a href='emails.php?act=viewall'>View All</a>"; }else if($act == view){ $sql = "SELECT * FROM `contact`"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "There are no pending emails at the moment!"; }else { echo "<table border=0 cellspacing=3 cellpadding=2>\n"; echo "<tr><td style='border:1px solid #CCCCCC;'>ID<td style='border:1px solid #CCCCCC;'>Subject<td style='border:1px solid #CCCCCC;'>From<td style='border:1px solid #CCCCCC;'>Date Sent\n"; while($row = mysql_fetch_assoc($res)){ echo "<tr><td style='border:1px solid #CCCCCC;'>$row[id]<td style='border:1px solid #CCCCCC;'><a href=emails.php?act=view&p=read&id=$row[id]>$row[subject]</a><td style='border:1px solid #CCCCCC;'>$row[from]<td style='border:1px solid #CCCCCC;'>$row[date]\n"; } echo "</table>"; mysql_free_result($res); } } if($act == view && $p == read && isset($_GET['id'])){ $sql = "SELECT * FROM `contact` WHERE id =$_GET['id']"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); if(mysql_num_rows($res) == 0){ echo "This email is not available"; }else { echo "<table border=0 cellspacing=3 cellpadding=2 width=350>\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>From: $row['from']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>Sent: $row['date']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>Email: $row['email']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;' valign=top>Message:<br>$row['body']"; echo "<tr><td style='border: 1px solid #CCCCCC;'>\n <a href=emails.php?act=del&id=$row['id']>Delete</a> | <a href=emails.php?act=reply&id=$row['id']>Reply</a>\n"; echo "</table>"; } }}require('../footer.php');?>[/code]error:[code]Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/marcus/public_html/admin/emails.php on line 35[/code] Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/ Share on other sites More sharing options...
sanfly Posted December 16, 2006 Share Posted December 16, 2006 Well, Line 35 is this one[code=php:0]$sql = "SELECT * FROM `contact` WHERE id =$_GET['id']";[/code]I dont usually use $_GET or $_POST etc as variables in my mysql queries, so not sure on the exact rules.I would try redefining the variable as a more simple one, then use that in the query, eg:[code=php:0]$id = $_GET['id'];$sql = "SELECT * FROM `contact` WHERE id = '$id'";[/code]See if that helps Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142113 Share on other sites More sharing options...
marcus Posted December 16, 2006 Author Share Posted December 16, 2006 now the same error is on line 44 Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142121 Share on other sites More sharing options...
marcus Posted December 16, 2006 Author Share Posted December 16, 2006 [code]<?phprequire('../header.php');if(!$_SESSION['admin']){header ("Location: login.php");}else { $act = $_GET['act']; $p = $_GET['p']; $id = $_GET['id']; if(!$act){ echo "Choose: <a href='emails.php?act=view'>View Unread</a> | <a href='emails.php?act=viewall'>View All</a>"; }else if($act == view){ $sql = "SELECT * FROM `contact`"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "There are no pending emails at the moment!"; }else { echo "<table border=0 cellspacing=3 cellpadding=2>\n"; echo "<tr><td style='border:1px solid #CCCCCC;'>ID<td style='border:1px solid #CCCCCC;'>Subject<td style='border:1px solid #CCCCCC;'>From<td style='border:1px solid #CCCCCC;'>Date Sent\n"; while($row = mysql_fetch_assoc($res)){ echo "<tr><td style='border:1px solid #CCCCCC;'>$row[id]<td style='border:1px solid #CCCCCC;'><a href=emails.php?act=view&p=read&id=$row[id]>$row[subject]</a><td style='border:1px solid #CCCCCC;'>$row[from]<td style='border:1px solid #CCCCCC;'>$row[date]\n"; } echo "</table>"; mysql_free_result($res); } } if($act == view && $p == read && isset($id)){ $sql = "SELECT * FROM `contact` WHERE `id` = $id"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); if(mysql_num_rows($res) == 0){ echo "This email is not available"; }else { echo "<table border=0 cellspacing=3 cellpadding=2 width=350>\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>From: $row['from']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>Sent: $row['date']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;'>Email: $row['email']\n"; echo "<tr><td style='border: 1px solid #CCCCCC;' valign=top>Message:<br>$row['body']"; echo "<tr><td style='border: 1px solid #CCCCCC;'>\n <a href=emails.php?act=del&id=$row['id']>Delete</a> | <a href=emails.php?act=reply&id=$row['id']>Reply</a>\n"; echo "</table>"; } }}require('../footer.php');?>[/code]*on 45 now Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142125 Share on other sites More sharing options...
emehrkay Posted December 16, 2006 Share Posted December 16, 2006 personally i like to concat my variables with stringsso where you have $foo = "this is a string $var, some more...";id do:$foo = "this is a string". $var .", some more...";it makes it a lot easier to see where your vars are and where you've made mistakes atand, you never close your table tags on lines 45 etcyou start off <tr><td> and just end it. they need to close with </td></tr> Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142130 Share on other sites More sharing options...
marcus Posted December 16, 2006 Author Share Posted December 16, 2006 It really wouldn't matter if my table cells/data were closed or not, I'm not testing it in a doctype xhtml strict yet Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142136 Share on other sites More sharing options...
emehrkay Posted December 16, 2006 Share Posted December 16, 2006 [quote author=mgallforever link=topic=118810.msg485840#msg485840 date=1166229196]It really wouldn't matter if my table cells/data were closed or not, I'm not testing it in a doctype xhtml strict yet[/quote]well it doesnt, but its apart of being a good programmer. i doubt that anyone with some experience, while just testing, would leave table tags unclosed. anyway, try concating the vars and see what happens with your errors Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142144 Share on other sites More sharing options...
marcus Posted December 16, 2006 Author Share Posted December 16, 2006 I tried it with the separation and works now, thanks! Link to comment https://forums.phpfreaks.com/topic/30818-help-needed/#findComment-142152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.