illuz1on Posted July 31, 2007 Share Posted July 31, 2007 Hey, I have this form that when I add the following bit into the big piece of code at the bottom: Parse error: parse error, unexpected $ in /home/capetown/public_html/patrick/display1.php on line 37 Anyone know why? include("db.php"); $sql = "SELECT * FROM uploaddb"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name1 = $record['name1']; $desc1 = $record['desc1']; $publisher = $record['publisher']; <?php include("db.php"); $sql = "SELECT * FROM uploaddb"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name1 = $record['name1']; $desc1 = $record['desc1']; $publisher = $record['publisher']; $dir = "uploads/"; // Open a known directory, and proceed to read its contents echo "Current Documents:"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file!='.' && $file!='..') { echo "<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\"> <tr> <td width=\"12%\" rowspan=\"2\" valign=\"top\"><img src=\"file.png\" width=\"94\" height=\"78\"></td> <td height=\"64\" colspan=\"2\" valign=\"top\"><strong>$name1</strong><br> $desc1</td> </tr> <tr> <td width=\"75%\" valign=\"top\">Publisher<strong>:</strong> $publisher</td> <td width=\"13%\" valign=\"top\"><a href=\"$file\">Download</a></td> </tr> </table><br>"; } } closedir($dh); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/62644-problem-with-getting-from-database/ Share on other sites More sharing options...
jitesh Posted July 31, 2007 Share Posted July 31, 2007 <?php include("db.php"); $sql = "SELECT * FROM uploaddb"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name1 = $record['name1']; $desc1 = $record['desc1']; $publisher = $record['publisher']; $dir = "uploads/"; // Open a known directory, and proceed to read its contents echo "Current Documents:"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file!='.' && $file!='..') { echo "<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\"> <tr> <td width=\"12%\" rowspan=\"2\" valign=\"top\"><img src=\"file.png\" width=\"94\" height=\"78\"></td> <td height=\"64\" colspan=\"2\" valign=\"top\"><strong>$name1</strong><br> $desc1</td> </tr> <tr> <td width=\"75%\" valign=\"top\">Publisher<strong>:</strong> $publisher</td> <td width=\"13%\" valign=\"top\"><a href=\"$file\">Download</a></td> </tr> </table><br>"; } } closedir($dh); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/62644-problem-with-getting-from-database/#findComment-311805 Share on other sites More sharing options...
illuz1on Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks that worked but now it displays this code like this (4 entries of each record): http://www.capetownalive.co.za/patrick/display1.php Not really displaying properly.. <?php include("db.php"); $sql = "SELECT * FROM uploaddb"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name1 = $record['name1']; $desc1 = $record['desc1']; $publisher = $record['publisher']; $dir = "uploads/"; // Open a known directory, and proceed to read its contents echo "Current Documents:"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file!='.' && $file!='..') { echo "<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\"> <tr> <td width=\"12%\" rowspan=\"2\" valign=\"top\"><img src=\"file.png\" width=\"94\" height=\"78\"></td> <td height=\"64\" colspan=\"2\" valign=\"top\"><strong>$name1</strong> $desc1</td> </tr> <tr> <td width=\"75%\" valign=\"top\">Publisher<strong>:</strong> $publisher</td> <td width=\"13%\" valign=\"top\"><a href=\"$file\">Download</td> </tr> </table> "; } } closedir($dh); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/62644-problem-with-getting-from-database/#findComment-311812 Share on other sites More sharing options...
DeadEvil Posted July 31, 2007 Share Posted July 31, 2007 <?php include("db.php"); $sql = "SELECT * FROM uploaddb"; $data = mysql_query($sql); $content = ""; while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name1 = $record['name1']; $desc1 = $record['desc1']; $publisher = $record['publisher']; } $dir = "uploads/"; $content .= "Current Documents:"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file!='.' && $file!='..') { $content .= "<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#999999\">"; $content .= "<tr>"; $content .= "<td width=\"12%\" rowspan=\"2\" valign=\"top\"><img src=\"file.png\" width=\"94\" height=\"78\"></td>"; $content .= "<td height=\"64\" colspan=\"2\" valign=\"top\"><strong>$name1</strong>$desc1</td>"; $content .= "</tr>"; $content .= "<tr>"; $content .= "<td width=\"75%\" valign=\"top\">Publisher<strong>:</strong>$publisher</td>"; $content .= "<td width=\"13%\" valign=\"top\"><a href=\"$file\">Download</td>"; $content .= "</tr>"; $content .= "</table>"; } } closedir($dh); } } echo $content; ?> Quote Link to comment https://forums.phpfreaks.com/topic/62644-problem-with-getting-from-database/#findComment-311820 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.