I'm a noob at PHP, MYSQL, and PHPADMIN.. But I am learning a lot. So far, I have successfully installed all of the componts on one test server. I can display data from the database using PHP scripts without any problem. Now, I would like to try to add the ability for editing data in the database through a web page. I have a basic script that I was wondering if you experts could help me troubleshoot... Sorry for the long post, but I wanted to give all the information I could.......
**************************
**********
**********
**********
**********
*********
UpdateScheduleForm.html
~~~~This is the start of my project... Here, a user will enter a server name in the form. The server name will be saved in a variable and be used later to present some of the information related to the server name in the MYSQL database. Note: This part works fine.
**************************
**********
**********
**********
**********
*********
<form action="updateSchedule.php
" method="post">
You are about to alter the Deployment Schedule. Enter the Server Name for which you require the deployment schedule change: <input type="text" name="svrinput" value= ServerName><br>
<input type="Submit">
</form>
**************************
**********
**********
**********
**********
**********
*******
updateschedule.php
~~~~ After the user enters a servername, this script will present related server information from the database. In addition, another form will be presented for the three fields that they can modify: deployment schedule, Name, and Change Notes. Note: This part works fine...
**************************
**********
**********
**********
**********
**********
*******
<?
$svrinput=$_POST['svrinput
'];
include("dbinfo.inc.php");
mysql_connect($server,$use
rname,$pas
sword);
@mysql_select_db($database
) or die( "Error! Unable to select $database database from server $server");
$query="SELECT * FROM allserverdata WHERE DeviceName='$svrinput'";
$result=mysql_query($query
);
$num=mysql_numrows($result
);
mysql_close();
echo "<b><center>All Hosted Servers Database Output</center></b><br><br
>";
/* Setting the Output Table format */
?>
<table border="5" cellspacing="8" cellpadding="8">
<tr>
<th><font face="Arial, Helvetica, sans-serif">DeviceName</fo
nt></th>
<th><font face="Arial, Helvetica, sans-serif">Deployment Date</font></th>
<th><font face="Arial, Helvetica, sans-serif">Name of Person Requesting Change</font></th>
<th><font face="Arial, Helvetica, sans-serif">Deployment Change Notes</font></th>
<th><font face="Arial, Helvetica, sans-serif">IP Address</font></th>
<th><font face="Arial, Helvetica, sans-serif">Business Unit</font></th>
<th><font face="Arial, Helvetica, sans-serif">Primary Application Contact</font></th>
<th><font face="Arial, Helvetica, sans-serif">Secondary Application Contact</font></th>
<th><font face="Arial, Helvetica, sans-serif">Primary Technical Contact</font></th>
<th><font face="Arial, Helvetica, sans-serif">Secondary Technical Contact</font></th>
<th><font face="Arial, Helvetica, sans-serif">Product Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Application</f
ont></th>
<th><font face="Arial, Helvetica, sans-serif">Reboot Instructions</font></th>
<th><font face="Arial, Helvetica, sans-serif">Grid Location</font></th>
<th><font face="Arial, Helvetica, sans-serif">Installed Site Code</font></th>
<th><font face="Arial, Helvetica, sans-serif">Site</font></t
h>
</tr>
<?
/* Gathering data from MYSQL database */
$i=0;
while ($i < $num) {
$DeviceName=mysql_result($
result,$i,
"DeviceNam
e");
$DeploymentDate1=mysql_res
ult($resul
t,$i,"Depl
oyment Date 1");
$ChangeRequestor=mysql_res
ult($resul
t,$i,"Chan
ge Requestor");
$ChangeNotes=mysql_result(
$result,$i
,"Change Notes");
$IPAddress=mysql_result($r
esult,$i,"
IPAddress"
);
$BU=mysql_result($result,$
i,"BU");
$PrimaryAppContact=mysql_r
esult($res
ult,$i,"Pr
imary App Contact");
$SecondaryAppContact=mysql
_result($r
esult,$i,"
Secondary App Contact");
$PrimaryTechnicalContact=m
ysql_resul
t($result,
$i,"Primar
y Technical Contact");
$SecondaryTechnicalContact
=mysql_res
ult($resul
t,$i,"Seco
ndary Technical Contact");
$ProductName=mysql_result(
$result,$i
,"Product Name");
$Application=mysql_result(
$result,$i
,"Applicat
ion");
$RebootInstructions=mysql_
result($re
sult,$i,"R
eboot Instructions");
$GridLocation=mysql_result
($result,$
i,"Grid Location");
$InstalledSiteCode=mysql_r
esult($res
ult,$i,"In
stalled Site Code");
$Site=mysql_result($result
,$i,"Site"
);
/* Printing data to output table */
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$DeviceName"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$DeploymentDate1"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$ChangeRequestor"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$ChangeNotes"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$IPAddress"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$BU"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$PrimaryAppContact"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$SecondaryAppContact"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$PrimaryTechnicalContact"
; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$SecondaryTechnicalContac
t"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$ProductName"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$Application"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$RebootInstructions"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$GridLocation"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$InstalledSiteCode"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$Site"; ?></font></td>
</tr>
<?
++$i;
}
echo "</table>";
?>
<form action="UpScheduleupdated.
php" method="post">
Enter the Server NAme for the Schedule You Want to Modify: <input type="text" name="ud_svrinput" value="<? echo "$svrinput"?>"><br>
Enter New Deployment Day: <input type="text" name="ud_DeploymentDate1" value="<? echo "$DeploymentDate1"?>"><br>
Enter Your First and Last Name: <input type="text" name="ud_ChangeRequestor">
<br>
Enter Reason for Schedule Day Change: <input type="text" name="ud_ChangeNotes"><br>
<input type="Submit" value="Update">
</form>
**************************
**********
**********
**********
**********
*********
UpScheduleupdated.php
~~~~ This script actually tries to update the database. I am only trying to modify one field at the moment for a test. My database name is TEST, my table is called allserverdata and the field is called BU. However, the database never gets modified and there is no error presented. Note: This part of the script is NOT working....and I don't know why????
**************************
**********
**********
**********
**********
*********
<?
$ud_DeploymentDate1=$_POST
['ud_Deplo
ymentDate1
'];
$ud_ChangeRequestor=$_POST
['ud_Chang
eRequestor
'];
$ud_ChangeNotes=$_POST['ud
_ChangeNot
es'];
$ud_svrinput=$_POST['ud_sv
rinput'];
print($ud_DeploymentDate1)
; <-- just printing these out so, I know I am passing them from the form correctly
print($ud_ChangeRequestor)
; <-- just printing these out so, I know I am passing them from the form correctly
print($ud_ChangeNotes); <-- just printing these out so, I know I am passing them from the form correctly I AM ONLY REALLY USING THIS VAR AT THE MOMENT
print($ud_svrinput); <-- just printing these out so, I know I am passing them from the form correctly
include("dbinfo.inc.php");
mysql_connect($server,$use
rname,$pas
sword);
@mysql_select_db($database
) or die( "Error! Unable to select $database database from server $server");
$query="UPDATE allserverdata SET BU='$ud_ChangeNotes', WHERE ID=1065";
mysql_query($query);
echo "Record Updated";
mysql_close();
?>
**************************
**********
**********
**********
**********
**********
**
dbinfo.inc.php
~~~ This is just my connection to the database as ROOT.
**************************
**********
**********
**********
**********
**********
**
<?
$username="root";
$password="Password123";
$database="test";
$server="localhost";
?>
Any help would be greatly appreciated....
Start Free Trial