Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:21:13+00:00 2026-05-31T03:21:13+00:00

I’ve been trying to fix this problem forever now and its bugging me. the

  • 0

I’ve been trying to fix this problem forever now and its bugging me. the code is to display a table selected from the dropbox which works fine..but when i put it in with my layout/template it throws an error & i have no idea why!

Here’s the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" >
<meta name="description" content="" >
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<title>SNYSB Archive</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" >
<!-- Location of javascript. -->
<script language="javascript" type="text/javascript" src="swfobject.js" ></script>
</head>
    <div id="wrapper">
    <div id="header">
    <!-- KEEP THIS BIT [ITS FORMATTING] --> 
    </div>
    <!-- end #header -->
    <div id="menu">
            <ul>
            <li><a href="Hpage.php">Home</a></li>
            <li><a href="Register.php">Register</a></li>
        </ul>
    </div>
    <!-- end #menu -->
    <div id="page">
    <div id="page-bgtop">
    <div id="page-bgbtm">
    <div id="content">
            <div class="post">
            <div class="post-bgtop">
            <div class="post-bgbtm">
<h1 class="title">PUT HEADING HERE!</h1>
                <div class="entry">
                    <p class="Body">
<?php
$dbname = 'snysbarchive';
$conn= mysql_connect('localhost', 'root', 'usbw');
if (!$conn) {
    echo 'Could not connect to mysql';
    exit;
}

$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);

if (!$result) {
    echo "DB Error, could not list tables\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}
if (mysql_select_db($dbname, $conn))
{
?>
    <form method="post" action="new 2.php">
    <select name="tables">
    <?php
    while ($row = mysql_fetch_row($result)) {
    ?>    
    <?php
        echo '<option value="'.$row[0].'">'.$row[0].'</option>';
    }
    ?>
    </select>
    <input type="submit" value="Show">
</form>
<?php
//mysql_free_result($result);
if (isset($_POST) && isset($_POST['tables']))
{
    $tbl=$_POST['tables'];
    //echo $_POST['tables']."<br />";
    $query="SELECT * from $tbl";
    $res=mysql_query($query);
    echo $query;
    if ($res)
    {
    ?>
    <table border="1">
    <?php
        while ( $row = mysql_fetch_array($res))
        {
            echo "<tr>";
            echo "<td>".$row[0]."</td>";
            echo "<td>".$row[1]."</td>";
            echo "<td>".$row[2]."</td>";
            echo "<td>".$row[3]."</td>";        
            echo "</tr>";
        } ?>
    </table>
    <?php
    }
}
?>
</div>
</div>
            </div>
            </div>

        <div style="clear: both;">&nbsp;</div>
        </div>
        <!-- end #content -->
        <div id="sidebar">
            <ul>
                <li>
                    <h2>Welcome!</h2>
                    <p>Welcome to SNYSBs archive!
                       </p>
                </li>
                <li>
                    <h2>SNYSB</h2>
                    <p>
            <a href="Contact.php">Contact Us!</a>
                    </p>
                </li>
            </ul>
        </div>
        <!-- end #sidebar -->
        <div style="clear: both;">&nbsp;</div>
    </div>
    </div>
    </div>
    <!-- end #page -->
    <div id="footer">
        <p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
    </div>
    <!-- end #footer -->
</div>
</body>
</html>

(Just pasted the entire page’s code from the original with my template at the start and bottom)

This is the line it doesnt like:

if (isset($_POST['tables']))

Thanks

Edit: New error message:
Parse error: syntax error, unexpected $end in FILENAME on line 128

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:21:14+00:00Added an answer on May 31, 2026 at 3:21 am

    The error you’re seeing is likely because $_POST doesn’t have a key called ‘tables’.

    echo"<form method="post" action="show_tabs.php">";
    echo"<select name="tables">";
    

    both produce errors when I run them. Notice the syntax highlighting color changes on SO, indicating that not all is being interpreted as a string literal. You need to either escape the inner quotes or switch the outer ones to single quotes:

    echo '<form method="post" action="show_tabs.php">';
    echo '<select name="tables">';
    

    or

    echo "<form method=\"post\" action=\"show_tabs.php\">";
    echo "<select name=\"tables\">";
    

    The same goes for

    echo"<input type="submit" value="Show">";
    ...
    echo"<table border="1">";
    

    Also,

    if ($res)
    }
    

    should read

    if ($res)
    {
    

    Furthermore, you have an error in your usage of the mysql_* functions. I can see you’re selecting your db only after having run a query, and I don’t see a call to mysql_connect. The order is connect, select_db, query, fetch, free, close as seen in http://www.php.net/manual/en/mysql.examples-basic.php


    (After above code was updated)
    Wrapping the whole thing in a heredoc is clearly the cause, and is very unnecessary. Simply use php open and closing tags to switch between text and code. For instance instead of

    echo <<< TEMPLATE
    <h1 class="title">PUT HEADING HERE!</h1>
    <div class="entry">
    <p class="Body">
    

    use

    ?>
    <h1 class="title">PUT HEADING HERE!</h1>
    <div class="entry">
    <p class="Body">
    <?php
    

    Code inside of a heredoc doesn’t get executed (although variables are substituted), so none of the code from <<< TEMPLATE to TEMPLATE; is being run. Only variables should go inside a heredoc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.