Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006
    Posts
    1

    Unanswered: Trouble Updating My Databse

    Hello to everyone reading this.

    Very much to the point, i have a table which i echo information to. Also in this table i have x3 drop down menus consisiting of important selections. I am trying to make appropriate changes via the drop down menus and then submit, at which point the submit button looks as though it's doing something, BUT unfortunately nothing seems to be, and the DB does not update.

    I have had this problem for a while now , and im really not understanding why it isn't updating . If anyone can see a reason as to why my code does not work, i would be so so so glad to hear.

    The only kind of uncertainty i have is that my INSERT query maybe placed in the wrong area of the code, but im not 100% sure.

    And can anyone clarify whether PHP and MySQL allows you echo and modify information in the same form, because at the moment i'm having doubts, which may be false.

    Here is my code

    ----------------------------

    <?
    session_start();
    ?>

    <?
    include "conn.inc.php";
    $query ="SELECT * FROM admin WHERE AdminID= '" . $_SESSION['admin_logged']."'
    AND password =(password('" . $_SESSION['admin_password'] . "'));";
    $result = mysql_query($query) or die(mysql_error());
    $new = mysql_fetch_array($result);
    ?>

    <html>
    <head>
    <title>Fault Reporting System : : Complete A Call</title>
    <body background="h.gif">
    <body>
    <br>
    <div align="center"><h2>Welcome <? echo $new['First_Name']; ?>.<br> Please Select A Call You Would Like To Complete</h2></div>
    <br>

    <?
    include "conn1.inc.php";

    $q1 = "SELECT FaultID, AdminID, StaffID, Location, Problem_Desc, Date
    FROM fault
    WHERE AdminID= '" . $_SESSION['admin_logged']."'
    AND Progress = 'Ongoing'";

    $result1 = mysql_query($q1) or die(mysql_error());
    $ans= mysql_num_rows($result1);

    ?>

    <?

    // updating the database

    include "conn1.inc.php";

    if ($_POST['submit'] == "submit")
    {
    if ($_POST['Technician_Comment'] != "" && $_POST['Progress'] != "" && $_POST['Complete'] != "")

    $q8 = "INSERT INTO fault(Technician_Comment, Progress, Complete)
    VALUES('" . $_POST['Technician_Comment'] . "', '" . $_POST['Progress'] . "',
    '" . $_POST['Complete'] . "');";

    $result2 = mysql_query($q8) or die(mysql_error());
    $_SESSION['admin_logged'] = $_POST['AdminID'];
    $_SESSION['admin_password'] = $_POST['password'];
    }
    ?>

    <?

    //EOD, all table variables held between EOD statements;

    $progress_table=<<<EOD
    <div align="center"><h4>Here Are Your Outstanding Calls</h4></div>
    <form action="Fault_All_My_Completed_Calls.php" method="post">
    <table width="100%" border="5" cellpadding="1" cellspacing="1" align="center">
    <tr>
    <th>FaultID</th>
    <th>AdminID</th>
    <th>StaffID</th>
    <th>Location</th>
    <th>Problem Description</th>
    <th>Technician Comment</th>
    <th>Date</th>
    <th>Progress</th>
    <th>Complete</th>
    </tr>

    EOD;

    while($row = mysql_fetch_array($result1))
    {
    $FaultID = $row['FaultID'];
    $AdminID = $row['AdminID'];
    $StaffID = $row['StaffID'];
    $Location = $row['Location'];
    $Problem_Desc = $row['Problem_Desc'];
    $Date = $row['Date'];

    $progress_table_info .=<<<EOD

    <tr>
    <td>$FaultID</td>
    <td>$AdminID</td>
    <td>$StaffID</td>
    <td>$Location</td>
    <td>$Problem_Desc</td>
    <td><select name="Technician_Comment">
    <option value="" SELECTED>Select Comment...</option>
    <option value="Working fine now">Working fine now</option>
    <option value="Sent back to manufacturer">Sent back to manufacturer</option>
    <option value="3rd party coming in to look at it">3rd party coming in to look at it</option>
    <option value="Need more time">Need more time</option>
    </select></td>
    <td>$Date</td>
    <td><select name="Progress">
    <option value="" SELECTED>Select Progress...</option>
    <option value="Ongoing">Ongoing</option>
    <option value="Complete">Complete</option>
    </select></td>

    <td><select name="Complete">
    <option value="" SELECTED>Complete...</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>

    </tr>

    EOD;
    }
    $progress_table_info .=<<<EOD


    <tr>
    <td></td>

    EOD;

    $progress_table_end ="</table>";
    $progress =<<<PROGRESS
    $progress_table
    $progress_table_info
    $progress_table_end
    PROGRESS;
    echo $progress;
    ?>

    <br>
    <br>
    <input type="submit" name="submit" value="Submit">
    <input type="reset" value="Clear">
    </body>
    </html>

    --------------------

    If anyone can help in anyway, id be very greatful.

    Thankyou.

    H.
    Last edited by mall; 03-15-06 at 16:04.

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    One thing quickly comes to mind:

    PHP Code:
    include "conn1.inc.php";
    ...
    include 
    "conn1.inc.php"
    Try using include_once() instead.

    Also (just for anal-retentiveness) try specifying the resource when using mysql_query() and cleaning up your objects after each query (ie. mysql_free_result()).

    If that doesn't help, try echoing out the INSERT query, and other potential buggy areas to find out if the query is bad, or if the script is getting stuck somewhere. And then maybe post a more readable version of the relevant pieces of code (and debug comments) after you've narrowed it down ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •