ckdoublenecks Posted September 18, 2010 Share Posted September 18, 2010 I get this error Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\hofiles\receipts2.php on line 24 with this code ? <?php $apt=$_POST['apt']; $name=$_POST['name']; $amtpaid=$_POST['amtpaid']; $datepaid=$_POST['datepaid']; $stat = mysql_connect(localhost,root,"") or die('Unable to connect to database: ' . mysql_error()); $stat = mysql_select_db(prerentdb) or die('Unable to select database: ' . mysql_error()); if(!empty($_POST["submit"])) { $apt = $_POST['apt']; $query="SELECT * FROM payments Where apt='$apt'"; $result=mysql_query($query); if(mysql_num_rows($result)) ?> <html><body> <font size=2><b>Hammock Oaks Apartments</font> Rent Receipt<p> <?php { echo "<form action='#' method='post'> while($row = mysql_fetch_assoc($result)) { echo "$name in apartment $apt has paid $amtpaid on this day $datepaid<br />"; } else{echo "No listing for apartment $apt.<br />Please select another."; } $stat = mysql_query($query) or die('Query failed: ' . mysql_error()); mysql_close(); ?> <form method="post" action="#"> <br /> <input type="text" name="apt"/> <p> <input type="submit" name="submit" value="receipt apartment"/> </form> </b></body></html> Link to comment https://forums.phpfreaks.com/topic/213750-having-trouble-understanding-error/ Share on other sites More sharing options...
Alex Posted September 18, 2010 Share Posted September 18, 2010 You have a few problems: 1. You're never closing this echo statement: echo "<form action='#' method='post'> 2. You're attempting to do while() { ... } else { ... } which makes no sense and is invalid. Link to comment https://forums.phpfreaks.com/topic/213750-having-trouble-understanding-error/#findComment-1112543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.