Hello I am really new at this and are having trouble with MySQL updating .php files in the database program I am using. This used to work until I changed some of the .php file. I only changed the front end of these files and cannot see why what used to update from MySQL is now not working. Any help in regards to this would be appreciated.

Thanks

Mica

Recommended Answers

All 7 Replies

Welcome to Daniweb! Can you show us your script so that we can make out where you are going wrong ?

Hello and thank you.

Here is the .php file:

<HTML>
<head>
<title>Chained Selects</title>
<script language="javascript" src="chainedmenu.js">

/***********************************************
* Chained Select Menu- By Xin Yang ([url]http://www.yxscripts.com/[/url]) Dynamic
Drive ([url]http://dynamicdrive.com[/url])
* Script featured on/available at [url]http://www.dynamicdrive.com/[/url]
* Visit Dynamic Drive at [url]http://www.dynamicdrive.com/[/url] for full source code
* This notice must stay intact for legal use!
***********************************************/

</script>
<script language="javascript" src="config.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
    background-image: url(electronics.gif);
    background-repeat: repeat;
}
.style5 {
    color: #000080;
    font-size: 18px;
}
.style6 {color: #000080; font-size: 36px;}
.style7 {color: #000080; font-size: 18px; font-weight: bold; }
.style8 {font-size: 40px}
-->
</style></head>

<BODY TEXT="GREEN" LINK="BLUE" ALINK="LIGHTGREEN" VLINK="DARKGREEN"
bgcolor="beige">

<body onload="initListGroup('chainedmenu', document.listmenu0.firstlevel,
document.listmenu0.secondlevel, document.listmenu0.thirdlevel,
'savestate')">

<H1 ALIGN="center" class="style6"><span class="style8">DJ Electronics Brown Goods Portal</span><br>
    <br>
  <br>
</H1>
<FORM action="../query/addrecord1.php" method="post" name="listmenu0">
<P ALIGN="left">
<div align="left">
  <table>
    <td class="style5">
      <LABEL for="database"><strong>Product Database:</strong> </LABEL>
      <INPUT type="text" name="database" value="incoming" readonly>      </td>
       <td class="style5">
         <LABEL for="client" class="style7">Client: </LABEL>
         <select name="client">
           <option value="Amerge" >Amerge</option>
           <option value="Base" >Base</option>
           <option value="BigW" >Big W</option>
           <option value="Buy'N'Save" >Buy'N'Save</option>
           <option value="Daewoo" >Daewoo</option>
           <option value="DJ Electronics" >DJ Electronics</option>
           <option value="LG" >LG Electronics</option>
           <option value="Mistral" selected>Mistral</option>
           <option value="Myer" >Myer</option>
           <option value="Omni" >Omni</option>
           <option value="PYE" >PYE</option>
           <option value="Sonashi" >Sonashi</option>
           <option value="Sunfire" >Sunfire</option>
           <option value="Supacity" >Supacity Discounts</option>
           <option value="Target" >Target</option>
           <option value="Zanussi" >Zanussi</option>
         </select>        </td>
    </table>
  <br>
    <br>
  <table width="917">
    <tr>
      <td width="217" class="style5"><LABEL for="model"><strong>Model:</strong> </LABEL>
          <INPUT type="text" name="model" value="">
      </td>
      <td width="205" class="style5"><LABEL for="batch"><strong>Batch No.:</strong> </LABEL>
          <INPUT type="text" name="batch" value="" size="14">
      </td>
      <td width="222" class="style5"><LABEL for="chassis"><strong>Serial 1:</strong></LABEL>
          <INPUT type="text" name="chassis" value="">
      </td>
      <td width="253" class="style5"><label for="serial"><strong>Serial 2:</strong></label>
          <input type="text" name="serial" value="">
      </td>
    </tr>
  </table>  
  <br>
  <br>
  <table width="913" height="30" border="0">
    <tr>
      <td width="124"><strong class="style7">Reported fault:</strong></td>
      <td width="388"><span class="style5">
        <INPUT type="text" name="fault" value="" size="60">
        <LABEL for="prefault"></LABEL>
      </span></td>
      <td width="116"><span class="style5">
        <LABEL for="prefault"><strong>Initially faulty:</strong> </LABEL>
      </span></td>
      <td width="267"><span class="style5">
        <select name="prefault">
          <option value="Y">Yes</option>
          <option value="N">No</option>
        </select>
      </span></td>
    </tr>
  </table>
  <br>
  <br>
  <table align="left">
    <tr>
      <td><div align="left" class="style7">Diagnosis: </div></td>
      <td><div align="left"> <span class="style5">
          <select name="firstlevel" style="width:180px;">
          </select>
      </span></div></td>
      <td><div align="left"> <span class="style5">
          <select name="secondlevel" style="width:160px;">
          </select>
      </span></div></td>
      <td><div align="left"> <span class="style5">
          <select name="thirdlevel" style="width:160px;">
          </select>
        </span></div>
      </tr>
  </table>
  <p><br>
      <br>
      <br>
  </p>
  <table width="611" height="33" border="0">
    <tr>
      <td width="160"><strong class="style7">Remarks/Comments:</strong></td>
      <td width="441"><span class="style5">
        <input type="text" name="misc" value="" size="60">
      </span></td>
    </tr>
  </table>
  <br>
  <br>
  <table>
  <td class="style5"><label for="status"><strong>Status?</strong></label>
          <select name="status">
            <option value="OK">Completed</option>
            <option value="F">Disposed</option>
          </select>
  </td>
      <td class="style5"><label for="soak"><strong>Soak:</strong> </label>
          <select name="soak">
            <option value="3 hours">3 Hours</option>
            <option value="Overnight">Overnight</option>
            <option value="Weekend">Weekend</option>
            <option value="As per schedule" selected>As per schedule</option>
          </select>
      </td>
  </table>
  <br>
  <br>
  <div align="left" class="style5"><strong>Tech:</strong>
      <select name="tech">
        <option value="A1P" >Alex Parail</option>
        <option value="AP" >Alvin Pratap</option>
        <option value="CD" >Colin D'lima</option>
        <option value="EB" >Eleazar Baylosis</option>
        <option value="JP" >Jason Prescott</option>
        <option value="LF" >Leonardo Faustino</option>
        <option value="RB" >Ray Brooker</option>
        <option value="RF" >Richard Fox</option>
        <option value="RM" >Robert Moonen</option>
        <option value="SA" >Sharaaj Ali</option>
        <option value="SP" >Surinder Pannu</option>
        <option value="SR" >Senthil Rajendran</option>
      </select>
  </div>
  <p><br>
      <span class="style5">        </span></p>
  <span class="style5">
  <LABEL for="fault"></LABEL>
  <LABEL for="prefault"></LABEL>
  </span><span class="style5">
  <LABEL for="misc"><br>
    </LABEL>
  </span></div>
<div align="left"><span class="style5">
<input type="hidden" name="job_type" value="Refurbish">
<br>
</span>
  <INPUT type="submit" value="Add Record"> 
  <INPUT type="reset">
  </P>
</div>
</FORM>

This is the page for the user input. Show us addrecord1.php. And, if you have the action file in the same folder, its not required to give the whole path (/query/addrecord1.php). You can directly give addrecord1.php. Please show us addrecord1.php. And, please, while posting your code, put it within [/code ] tags. :)[code ] [/code ] tags. :)

Hello nav33n
Sorry as I said I am new at this

Is this what you needed?

Also thank you for this:

<?php
$client = $_POST['client'];
$model = $_POST['model'];
$batch = $_POST['batch'];
$chassis = $_POST['chassis'];
$serial = $_POST['serial'];
$fault = $_POST['fault'];
$prefault = $_POST['prefault'];
$first = $_POST['firstlevel'];
$second = $_POST['secondlevel'];
$third = $_POST['thirdlevel'];
$misc = $_POST['misc'];
$remote = $_POST['remote'];
$status = $_POST['status'];
$soak = $_POST['soak'];
$job_type = $_POST['job_type'];
$tech = $_POST['tech'];
$t1 = $tech;
$date = date("Y-m-d");

if ($third != "")
{$remedy = $first." ".$second." ".$third.", ".$misc;}
elseif ($second != "" and $third == "")
{$remedy = $first." ".$second.", ".$misc;}
else
{$remedy = $first." ".$second." ".$misc;}

$query = "INSERT INTO repairs (date, client, model, batch, chassis, serial, fault, prefault, remedy, status, remote,  soak, job_type, tech) VALUES (".'"'.$d$
$connectID = mysql_connect("127.0.0.1", "root", "ratman");
mysql_select_db("incoming", $connectID);
$result = mysql_query($query, $connectID);
// print $query;
if ($result == TRUE)
{
        print "The record was added successfully.<p>";
}
else
{
        print "The record could not be added.<p>";
}

$query = "SELECT id, client, model, batch, chassis, fault, prefault, remedy, status, soak, tech FROM repairs WHERE date=".'"'.$date.'"'." AND job_type=".'"'$

$resultID = mysql_query($query, $connectID);
print "<table border=1><tr><th>id</th><th>Client</th><th>Model</th><th>Batch</th><th>Chassis</th><th>Fault</th><th>Existing Fault</th><th>Remedy</th><th>Sta$

while ($row = mysql_fetch_row($resultID))
{
        print "<tr>";
        foreach ($row as $field)
        {
                print "<td>$field</td>";
        }
        print "</tr>";
}
print "</table>";
mysql_close($connectID);
print "Is this record correct?";
?>
<FORM method = "post" action = "deleterecord.php">
<LABEL for="id" size = "5">Record Id?</LABEL>
<INPUT type = "text" name = "id">
<input type = "hidden" name = "t1v" value = "<? echo $t1; ?>">
<INPUT type = "submit" value = "Delete Record"></FORM>
<form method = "get" action = "../tech/product.php">
<input type = "hidden" name = "t1v" value = "<? echo $t1; ?>">
<input type = "submit" value = "Return to entry"></form>

$query = "INSERT INTO repairs (date, client, model, batch, chassis, serial, fault, prefault, remedy, status, remote, soak, job_type, tech) VALUES (".'"'.$d$

and

$query = "SELECT id, client, model, batch, chassis, fault, prefault, remedy, status, soak, tech FROM repairs WHERE date=".'"'.$date.'"'." AND job_type=".'"'$

and

print "<table border=1><tr><th>id</th><th>Client</th><th>Model</th><th>Batch</th><th>Chassis</th><th>Fault</th><th>Existing Fault</th><th>Remedy</th><th>Sta$

is not closed.

The query should be something like this, $query="INSERT INTO TABLENAME (COL1,COL2,COL3,COL4) VALUES ('VAL1','VAL2','VAL3','VAL4')"; :)

hello again all this is starting to get frustrating now. I think I am in over my head. All I am trying to do is update a drop down text field in a php file and the field is located on my MySQL database.

Where did you get this script from ? Its incomplete. I hope you know the basics of sql(select, insert, update and delete). Check this below script. Enter the details and click on submit. On top, it shows all the form data that has been sent. Populating a dropdown box is not a difficult thing.

<?php print_r($_POST); ?>
<HTML>
<head>
<title>Chained Selects</title>
<script language="javascript" src="chainedmenu.js">

/***********************************************
* Chained Select Menu- By Xin Yang (http://www.yxscripts.com/) Dynamic
Drive (http://dynamicdrive.com)
* Script featured on/available at http://www.dynamicdrive.com/
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for legal use!
***********************************************/

</script>
<script language="javascript" src="config.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-image: url(electronics.gif);
background-repeat: repeat;
}
.style5 {
color: #000080;
font-size: 18px;
}
.style6 {color: #000080; font-size: 36px;}
.style7 {color: #000080; font-size: 18px; font-weight: bold; }
.style8 {font-size: 40px}
-->
</style></head>

<BODY TEXT="GREEN" LINK="BLUE" ALINK="LIGHTGREEN" VLINK="DARKGREEN"
bgcolor="beige">

<body onload="initListGroup('chainedmenu', document.listmenu0.firstlevel,
document.listmenu0.secondlevel, document.listmenu0.thirdlevel,
'savestate')">

<H1 ALIGN="center" class="style6"><span class="style8">DJ Electronics Brown Goods Portal</span><br>
<br>
<br>
</H1>
<FORM action="test.php" method="post" name="listmenu0">
<P ALIGN="left">
<div align="left">
<table>
<td class="style5">
<LABEL for="database"><strong>Product Database:</strong> </LABEL>
<INPUT type="text" name="database" value="incoming" readonly> </td>
<td class="style5">
<LABEL for="client" class="style7">Client: </LABEL>
<select name="client">
<option value="Amerge" >Amerge</option>
<option value="Base" >Base</option>
<option value="BigW" >Big W</option>
<option value="Buy'N'Save" >Buy'N'Save</option>
<option value="Daewoo" >Daewoo</option>
<option value="DJ Electronics" >DJ Electronics</option>
<option value="LG" >LG Electronics</option>
<option value="Mistral" selected>Mistral</option>
<option value="Myer" >Myer</option>
<option value="Omni" >Omni</option>
<option value="PYE" >PYE</option>
<option value="Sonashi" >Sonashi</option>
<option value="Sunfire" >Sunfire</option>
<option value="Supacity" >Supacity Discounts</option>
<option value="Target" >Target</option>
<option value="Zanussi" >Zanussi</option>
</select> </td>
</table>
<br>
<br>
<table width="917">
<tr>
<td width="217" class="style5"><LABEL for="model"><strong>Model:</strong> </LABEL>
<INPUT type="text" name="model" value="">
</td>
<td width="205" class="style5"><LABEL for="batch"><strong>Batch No.:</strong> </LABEL>
<INPUT type="text" name="batch" value="" size="14">
</td>
<td width="222" class="style5"><LABEL for="chassis"><strong>Serial 1:</strong></LABEL>
<INPUT type="text" name="chassis" value="">
</td>
<td width="253" class="style5"><label for="serial"><strong>Serial 2:</strong></label>
<input type="text" name="serial" value="">
</td>
</tr>
</table>
<br>
<br>
<table width="913" height="30" border="0">
<tr>
<td width="124"><strong class="style7">Reported fault:</strong></td>
<td width="388"><span class="style5">
<INPUT type="text" name="fault" value="" size="60">
<LABEL for="prefault"></LABEL>
</span></td>
<td width="116"><span class="style5">
<LABEL for="prefault"><strong>Initially faulty:</strong> </LABEL>
</span></td>
<td width="267"><span class="style5">
<select name="prefault">
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
</span></td>
</tr>
</table>
<br>
<br>
<table align="left">
<tr>
<td><div align="left" class="style7">Diagnosis: </div></td>
<td><div align="left"> <span class="style5">
<select name="firstlevel" style="width:180px;">
</select>
</span></div></td>
<td><div align="left"> <span class="style5">
<select name="secondlevel" style="width:160px;">
</select>
</span></div></td>
<td><div align="left"> <span class="style5">
<select name="thirdlevel" style="width:160px;">
</select>
</span></div>
</tr>
</table>
<p><br>
<br>
<br>
</p>
<table width="611" height="33" border="0">
<tr>
<td width="160"><strong class="style7">Remarks/Comments:</strong></td>
<td width="441"><span class="style5">
<input type="text" name="misc" value="" size="60">
</span></td>
</tr>
</table>
<br>
<br>
<table>
<td class="style5"><label for="status"><strong>Status?</strong></label>
<select name="status">
<option value="OK">Completed</option>
<option value="F">Disposed</option>
</select>
</td>
<td class="style5"><label for="soak"><strong>Soak:</strong> </label>
<select name="soak">
<option value="3 hours">3 Hours</option>
<option value="Overnight">Overnight</option>
<option value="Weekend">Weekend</option>
<option value="As per schedule" selected>As per schedule</option>
</select>
</td>
</table>
<br>
<br>
<div align="left" class="style5"><strong>Tech:</strong>
<select name="tech">
<option value="A1P" >Alex Parail</option>
<option value="AP" >Alvin Pratap</option>
<option value="CD" >Colin D'lima</option>
<option value="EB" >Eleazar Baylosis</option>
<option value="JP" >Jason Prescott</option>
<option value="LF" >Leonardo Faustino</option>
<option value="RB" >Ray Brooker</option>
<option value="RF" >Richard Fox</option>
<option value="RM" >Robert Moonen</option>
<option value="SA" >Sharaaj Ali</option>
<option value="SP" >Surinder Pannu</option>
<option value="SR" >Senthil Rajendran</option>
</select>
</div>
<p><br>
<span class="style5"> </span></p>
<span class="style5">
<LABEL for="fault"></LABEL>
<LABEL for="prefault"></LABEL>
</span><span class="style5">
<LABEL for="misc"><br>
</LABEL>
</span></div>
<div align="left"><span class="style5">
<input type="hidden" name="job_type" value="Refurbish">
<br>
</span>
<INPUT type="submit" value="Add Record">
<INPUT type="reset">
</P>
</div>
</FORM>
</body>
</html>

To get options in a dropdown list, you can run a query, fetch the records between option tag. Eg.

echo "<select name="usernames">";
echo "<option value="">Select a user</option>";
$query="select name from table";//query to select name
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){
$name=$row['name'];
   echo "<option value=$name>$name</option";
}
.....

This will list all the users in the dropdown list.

Cheers,
Nav

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.