I cannot get this table to work even though i hav eit working PERFECTLY in 3 other instances, now what i dont get is it seems to be a connection issue between the database and the form, now that makes some sense to me. What doesnt make sense is when i do the exact solution to connect it to the database, it doesnt work at all. what gives!

<?php mysql_select_db('numbers', mysql_connect('localhost','root',''))or die(mysql_error());?>

<html>
        <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">

        <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>

<script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>


<form method="post">
<div class="row-fluid">
        <div class="span12">

            <div class="container">
            <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">

            <div class="alert alert-info">

            <center>                  
            <strong><i class="icon-user icon-large"></i>&nbsp;Uploaded Files</strong>
            </center>

            </div>
            <thead>

                <tr>

                  <th>File Name</th>
                  <th>Upload Date</th>
                  <th>Upload Time</th>

                  </tr>
              </thead>
              <tbody>
              <?php 
              $query=mysql_query("select * from upfiles")or die(mysql_error());
              while($row=mysql_fetch_array($query)){
              $id=$row['id'];
              ?>

                    <tr>

                     <td><?php echo $row['filename'] ?></td>
                     <td><?php echo $row['update'] ?></td>
                     <td><?php echo $row['uptime'] ?></td>

                    </tr>

              <?php } ?>
              </tbody>
              </table>
          </div>
      </div>
  </div>
</form>
</html>

here is my table, why isnt it connecting to the database??? why is this different while the others are exactly alike and they work fine?

Dani AI

Generated

Note: this thread was resolved — found the culprit was a double POST on the same page. That symptom (no visible errors but an empty table) is common when a form handler runs twice or when one submission redirects/consumes data before the display logic runs. 's prompt to check for errors and 's note about syntax are useful first steps, but a silent double-submit usually needs a different set of checks.

Quick diagnostic checklist that matches this thread:

  • Inspect the rendered HTML (View Source / Elements) for nested or duplicate <form> tags or a missing closing </form>. Nested forms are invalid and often cause unexpected behavior.
  • Use the browser Network panel while submitting to see whether the browser actually sends one or two POST requests.
  • Turn on PHP error reporting during debugging to reveal hidden warnings or notices.

Small, practical fixes to prevent a repeat:

  • Use the Post/Redirect/Get pattern so a POST never leaves the page in a state that can be accidentally re-submitted:
ini_set('display_errors', 1);
error_reporting(E_ALL);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // process form once
    header('Location: ' . $_SERVER['REQUEST_URI']);
    exit;
}
  • Add a simple one-time token in session and check/unset it on processing to block duplicate submissions:
session_start();
if (empty($_SESSION['form_token'])) { $_SESSION['form_token'] = uniqid('', true); }
// include hidden input with that token in the form
// on POST: compare token, then unset($_SESSION['form_token']) after successful processing

Other best practices: centralize and reuse a single DB connection (avoid multiple implicit connects), enable explicit error handling on queries, and move away from deprecated APIs to PDO or mysqli with prepared statements when refactoring. These steps make a page far easier to debug than hunting silent double-post issues.

Recommended Answers

All 9 Replies

do you get any error messages?

no, no error messages at all, just no result :/

Member Avatar for Member #46692

semicolon missing maybe.

no ive gone over it pretty closely, found nothing missing.

Member Avatar for Member #46692

I can see three missing.

I tried that, putting the three semi Colons at the end of my echo lines but they arent there in my other tables and they work just fine, plus it yielded the same result. I even tried moving some of the html around but NOTHING, its gotta be where it cant access the database, but why cant it? I dont see how this is any different execpt MAYBE where this table is along side another html file for uploading, but that shouldnt make any difference.

Member Avatar for Member #46692

Post the code that works that as you say is exactly the same.

here it is

</head>

    <div class="row-fluid">
        <div class="span12">


            <div class="container">


<br><br>
                            <form method="post">
                        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">

                            <div class="alert alert-info">

                                <strong><i class="icon-user icon-large"></i>&nbsp;Do Not Call Information From User Submitted Data</strong>

                            </div>
                            <thead>

                                <tr>

                                    <th>Employee Name</th>
                                    <th>First Name</th>
                                    <th>Last Name</th>
                                    <th>Email Address</th>
                                    <th>Customer Address</th>
                                    <th>Phone Number</th>
                                    <th>Date Added</th>
                                    <th>Time Added</th>
                                    <th>Accidental Calls</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php 
                            $query=mysql_query("select * from usernumdata")or die(mysql_error());
                            while($row=mysql_fetch_array($query)){
                            $id=$row['id'];
                            ?>

                                        <tr>

                                         <td><?php echo $row['empname'] ?></td>
                                         <td><?php echo $row['firstname'] ?></td>
                                         <td><?php echo $row['lastname'] ?></td>
                                         <td><?php echo $row['email'] ?></td>
                                         <td><?php echo $row['streetadd'], " ", $row['city'], " ", $row['state'], " ", $row['zip'], " ", $row['prov'] ?></td>
                                         <td><?php echo $row['numb'] ?></td>
                                         <td><?php echo $row['date'] ?></td>
                                         <td><?php echo $row['time'] ?></td>
                                         <td><?php echo $row['called'] ?></td>
                                </tr>

                                  <?php } ?>
                            </tbody>
                        </table>

</form>

sadly it is identical, :/

I figured out the issue, i was posting twice on the same page, not allowed so i fixed it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.