Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old March 11th, 2006, 04:53 PM
Registered User
Join Date: Mar 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

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.



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);

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

include "conn1.inc.php";

$q1 = "SELECT FaultID, AdminID, StaffID, Location, Problem_Desc,
              Date, Technician_Comment, Progress, Complete
       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;

<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">
    <th>Problem Description</th>
    <th>Technician Comment</th>


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
      <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>
      <td><select name="Progress">
    <option value="" SELECTED>Select Progress...</option>
    <option value="Ongoing">Ongoing</option>
    <option value="Complete">Complete</option>

$progress_table_info .=<<<EOD

  <td> </td>


$progress_table_end ="</table>";
$progress =<<<PROGRESS
echo $progress;
<input type="submit" name="submit" value="Submit">
<input type="reset" value="Clear">


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.


Reply With Quote
  #12 (permalink)  
Old March 11th, 2006, 05:41 PM
Friend of Wrox
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts

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..

$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))
     @$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 ..
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 10:03 AM.

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