Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2006, 04:53 PM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mantis, you are the man! Trust me, who the man? You d man. Sorry if your a female, in which case you'd be the woman.:D

That worked a treat m8, thank you very much for all your replies and undoubtedly needed help.

Just so happens, im strugling on another problem regarding updating one of my databases. I update a form, i press submit and I get no errors.

BUT the database wont update. I have not come across a problem like this before as all of my other databases update without fail.

Here's the code, if you don't mind taking a look.

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

<?
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, Technician_Comment, Progress, Complete
       FROM FAULT
       WHERE AdminID= '" . $_SESSION['admin_logged']."'
       AND Progress = 'Ongoing'";

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

?>

<?
// updating the database

include "conn1.inc.php";

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

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

      $result = 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>
  </tr>

EOD;

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

    $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>
    </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>

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

Some of the information is just called via the form and displayed. I then have x2 areas which i want to update, the TECHNICIAN COMMENT, where i select a comment from a drop down menu. And the other is the PROGRESS, where i want to also select either ongoing or complete from the drop down menu.

When i make my selections and press submit, it looks as though it updates the database, but it does not. Although the clear button works.

Anyways, hope you have the same luck with the new problem as the last.

Once again, thank you very much for your help with the last problem, and to anyone else who replied to the original message.

H.


 
Old March 11th, 2006, 05:41 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mysql query .. pfff
I'm rubbish at Mysql query. I have a set of queries that I use and re-use and adapt; thats about it.

From your code above they are like 20 lines I don't understand which obviously doesn't mean they are wrong.. just that I wouldn't have done it that way.

I won't use the $_SESSION or $_POST for anything but carriying the data over from pages to pages.. so I would remove those from the Query and replace them with variables instead.. something stupid in PHP i noticed:
VALUES('" . $_POST['Techncian_Comment'] . "', '" . $_POST['Progress'] . "');";

VALUES('" So ' mean it start and the next ' means it stop ?? right? look in the POST[' <- here we have little bugger which is likely to confuse PHP - thats my opinion .. might be wrong but I had some much crap with PHP that I prefer to play it cool and safe rather than trying to fit it all in 1 line..

$username1=$_SESSION['username1'];
$query = "SELECT * FROM members WHERE database_name LIKE '$username1'";
$result = mysql_query($query) or die ("There was a problem connecting to the database - please press refresh");

while ($row = mysql_fetch_array($result))
  {
     extract($row);
     @$passwordcheck=$database_password; }

Thats how I do my query .. nice and simple (for me!)

Good Luck in any case ^^
If you don't get it working you should try to repost it in the MySQL forum ..





Similar Threads
Thread Thread Starter Forum Replies Last Post
$_SESSION error in login.php Mind Games Beginning PHP 1 June 2nd, 2008 03:43 PM
$_Session cant pass Value kelz84 Beginning PHP 1 March 21st, 2006 09:25 AM
Is it possible to set $_Session Variables in java rinventive Java Basics 1 February 13th, 2006 05:41 AM
Difficulty getting thePhile up and running tkubaska BOOK: ASP.NET Website Programming Problem-Design-Solution 3 April 5th, 2004 12:32 PM
$_SESSION vs. $_GLOBALS Moharo Pro PHP 2 August 18th, 2003 02:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.