...

View Full Version : PHP Code goes Backwards



kenwvs
08-08-2006, 09:01 AM
I have a code that was working (for a short period), but now for some reason, it all seems backwards.... where I am suppose to have ", I need to remove them, and where they shouldn't be, I have to put them. Have you ever heard of this kind of thing happening. I am putting a couple of examples below.....


Site:<input type="text" value=<?php echo mysql_result($query, 0, [CODE]'Site')?> "size="10" id="Site">"
Unit Serial #:<input type="text" value="<? echo mysql_result($query, 0, 'Serial') ?>" size="10" id="Serial">
Unit Hours:<input type="text" value="<? echo mysql_result($query, 0, 'Hours') ?>" size="10" id="Hours">

The first example (site) works as a php code, and the other two don't, based on what the editor shows me. (I am new to this, so am a bit confused.)

I am also getting this error and not sure why it has popped up all of a sudden...

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\wamp\www\BenProject\womanager.php on line 22

It goes with this bit of code. I did have the ending in there about die if not correct, but I was getting an error and the only way to get rid of it was to remove it.


$query=mysql_query('SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Contact=$Work');

Thanks,

Ken

djmonkey1
08-08-2006, 12:09 PM
Your first code snip is garbled but I think you could try this:
Site:<input type="text" value="<?php echo mysql_result($query, 0, 'Site')?>" size="10" id="Site">"

Unit Serial #:<input type="text" value="<?php echo mysql_result($query, 0, 'Serial') ?>" size="10" id="Serial">

Unit Hours:<input type="text" value="<?php echo mysql_result($query, 0, 'Hours') ?>" size="10" id="Hours">


I don't think it's advisable to use <? to open a php tag unless you are certain that short_open_tag is turned on. <? is, generally, reserved for XML. That might be your problem.

Kid Charming
08-08-2006, 04:28 PM
The 'invalid result' problem means your query is failing for some reason. The error you were getting that forced you to remove your die() call was also caused by that, which brings us to an important lesson: removing the notification of an error does not fix the error. ;)

Put your die() back in with a mysql_error() call to see what the server's error message is. Also, echo out your query so you can see exactly what the server's getting. Chances are, something's wrong with the 'WHERE Contact=$Work' part -- $Work isn't set (which will raise a syntax error) or it's a string and needs to be single-quoted (which will raise an unknown column error).

Brokenhope
08-08-2006, 10:40 PM
$query=mysql_query('SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Contact=$Work');

Should be


$query=mysql_query('SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Contact="$Work"');

That should fix the problem, variables always need to be in ' or " in querys. It doesnt matter if its '$Work' or "$Work" [although in this case '$Work' would be invalid beacuse thats what you used to contain the query].

Either way, it needs to be contained, the query is being read as WHERE Contact=Bobby Joe');

You cant have the string uncontained ;).

kenwvs
08-08-2006, 10:52 PM
That solved the problem of it not loading, and causing an error.

Now when the page loads up it gives me the following in all the fields.

<? echo mysql_result($query, 0, 'PartsA') ?>

I know this is the code that I have written for the various fields, but am not sure what would be causing that.

It has been suggested that I need to set the variable..... but I am not sure what that means or how to do it.

Thanks,

Ken

Kid Charming
08-08-2006, 10:57 PM
It doesnt matter if its '$Work' or "$Work"

If your server's running in ANSI mode, it does. For maximum compatibility with other MySQL servers and db's, use the SQL standard single quotes for strings instead of doubles.

For your latest problem, make sure your server supports short tags, and put semicolons at the end of all your PHP statements.

djmonkey1
08-09-2006, 12:21 AM
Kid Charming is right about the semi-colons (and the short tags!). That code I posted before would work better like this:


Site:<input type="text" value="<?php echo mysql_result($query, 0, 'Site'); ?>" size="10" id="Site">"

Unit Serial #:<input type="text" value="<?php echo mysql_result($query, 0, 'Serial'); ?>" size="10" id="Serial">

Unit Hours:<input type="text" value="<?php echo mysql_result($query, 0, 'Hours'); ?>" size="10" id="Hours">

For setting the variable, you need to define the value of "$Work" within the php. For instance you could have something like
<?php $Work = 'sucks'; ?> or
<?php $Work = mysql_result($query, 0, 'Work'); ?>

The second example would probably get you into trouble if you actually used it (I'm not sure how MySQL deals with recursion of that sort) but the point is that you have to define "$Work" somewhere before you use it in "$query".

kenwvs
08-09-2006, 06:40 AM
This Crazy Canadian is about to be admitted to the physciatric unit of the local hospital....

I have adjusted the code and it is now showing up properly as far as the php tags. When i run this program, I am getting a warning, on each line that says



Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4 in C:\wamp\www\BenProject\womanager.php on line 21


The line number increases by one for each line.

Here is the code, as it currently exists....



<form action="" method="post" enctype="multipart/form-data">
<div>Work Order #:<input type="text" value=<?php echo mysql_result($query, 0, 'Work');echo mysql_error() ?> size="10" id="Work">
Date:<input type="text" value=<?php echo mysql_result($query, 0, 'Sched');?> size="10" id="Sched">
Technician:"<input type="text" value=<?php echo mysql_result($query, 0, 'Name'); ?> size="10" id="Name"> <BR><BR>
Site:<input type="text" value=<?php echo mysql_result($query, 0, 'Site'); ?> size="10" id="Site">
Unit Serial #:<input type="text" value=<?php echo mysql_result($query, 0, 'Serial'); ?> size="10" id="Serial">
Unit Hours:<input type="text" value=<?php echo mysql_result($query, 0, 'Hours'); ?> size="10" id="Hours">
<BR></><BR></>


The text that I have put in bold (each line does it) shows up on the page after the text field box. In the text field box there is a <br
The only satisfaction about this is when I put that code into a google page, the first copule pages of results are of pages that have that error on their site..... so I guess it ain't that uncommon, maybe just not that easy to solve.

Fumigator
08-09-2006, 03:54 PM
I'm pretty sure you are getting that error because your query didn't work. Do you have any code that checks to see if the query worked? You do that by saying


$query = mysql_query("query text goes here");
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
}

kenwvs
08-09-2006, 04:29 PM
I put that code in my query and it runs the same as it did before I had it in there. It says it is a warning, not an error, not sure if that makes a difference. I am getting ready to give up and just delete the whole thing off my computer....

If other pages are working, I am assuming it is safe to believe that my WAMP setup is correct.

Does this look like this would be the correct setup for my variable

$Contact = $_POST['Work'];

I am including the code at the beginning of this script, just to be sure that part is right, and then I will move down the script line by line. If I figure out the first line, I will have them all solved.....


<?php
include_once "myconnect.php";
$Contact = $_POST['Work'];
$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work='$Contact'");
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
}
?>
<?php
// WorkOrder.php
if (!isset($_POST['Submit'])){
?>

kenwvs
08-09-2006, 04:32 PM
I should have included this line, although I am almost positive it is correct.....


<form action="" method="post"enctype="multipart/form-data">

I am grasping at straws, but is it possible that in the line below the Input Type is something other than text since it is being called and not something that we are inputting?


<div>Work Order #:<input type="text" value=<?php echo mysql_result($query, 0, 'Work');?> size="10" id="Work">

Sorry to be a pain, but would really love to figured out.

Ken

Fumigator
08-09-2006, 04:45 PM
$Contact = $_POST['Work']; will work fine as long as you have an element in your form named "Work".

So your query is indeed working? You did not get the "ERROR IN QUERY!" message?

Ya know if this were me coding this, I would just add


$workorderInfo = mysql_fetch_assoc($query);

right after you execute the query, then simply use this syntax to imbed the values in your form input elements:


Site:<input type="text" value="<?php echo $workorderInfo['Site']; ?>" size="10" id="Site">


The main reason is, this way you put all your database functions in one spot. You assign the results of your query to an array, then you can just use the array where you need it down the line. But that's just me.

If you want to post your entire code, I can help you with that.

kenwvs
08-09-2006, 04:55 PM
The Work Order #, which is automatically generated by combining the month and time is called Work. It would be 08071515 for August, 7:15:15 in the morning.

Sorry, but no error code came up at all. The page loads, with all that warning stuff.

I will post the entire code, but no laughing as it isn't pretty looking.... I am just starting out.

Here is the entire code. I have a form called workorder.php which is the original form that people fill out. This is the one the manager will look at, and add comments and a purchase order # (these comments and the Purchase Order # don't appear on the original form) Here goes:


<head>
<!--<link href="ge.css" rel="stylesheet" type="text/css"> -->
<title>GE Work Order</title>
</head>
<BODY BGCOLOR="gainsboro">
<?php
include_once "myconnect.php";
$Contact = $_POST['Work'];
$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work='$Contact'");
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
}
$workorderInfo = mysql_fetch_assoc($query);
?>
<?php
// WorkOrder.php
if (!isset($_POST['Submit'])){
?>
<form action="" method="post"enctype="multipart/form-data">
<div>Work Order #:<input type="text" value=<?php echo mysql_result($query, 0, 'Work');?> size="10" id="Work">
Date:<input type="text" value=<?php echo mysql_result($query, 0, 'Sched');?> size="10" id="Sched">
Technician:"<input type="text" value=<?php echo mysql_result($query, 0, 'Name'); ?> size="10" id="Name"> <BR><BR>
Site:<input type="text" value=<?php echo mysql_result($query, 0, 'Site'); ?> size="10" id="Site">
Unit Serial #:<input type="text" value=<?php echo mysql_result($query, 0, 'Serial'); ?> size="10" id="Serial">
Unit Hours:<input type="text" value=<?php echo mysql_result($query, 0, 'Hours'); ?> size="10" id="Hours">
<BR></><BR></>
Unit Starts:<input type="text" value=<?php echo mysql_result($query, 0, 'Starts'); ?> size="10" id="Starts">
Severity:<input type="text" value=<?php echo mysql_result($query, 0, 'Severe'); ?> size="10" id="Severe">
Safety:<input type="text" value=<?php echo mysql_result($query, 0, 'Safety'); ?> size="10" id="Safety">
</div> <BR>
<div><B>Description of Issue:</B><BR><input type="textarea" value=<?php echo mysql_result($query, 0, 'Issue'); ?> size="155" id="Issue">
</div><BR>
<div><B>Possible Resolution</B><BR><input type="textarea" value=<?php echo mysql_result($query, 0, 'Resolve'); ?> size="155" id="Resolve">
</div><BR>
<div><B>List of Parts Required (one part per line)</B>:</div>
<div><input type="textarea" value=<?php echo (mysql_result($query, 0, 'PartsA')); ?> size="155" maxlength="155 id="PartsA"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsB'); ?> size="155" maxlength="155 id="PartsB"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsC'); ?> size="155" maxlength="155 id="PartsC"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsD'); ?> size="155" maxlength="155 id="PartsD"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsE'); ?> size="155" maxlength="155 id="PartsE"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsF'); ?> size="155" maxlength="155 id="PartsF"><BR>
<input type="textarea" value=<?php echo mysql_result($query, 0, 'PartsG'); ?> size="155" maxlength="155 id="PartsG"><BR>
</div><BR>
<div><B>Request for Assistance:<BR><input type="textarea" value=<?php echo mysql_result($query, 0, 'Assist'); ?> size="155" id="Assist">
</div></B><BR><BR>

<div>
<div><center><B>Send this form to:<BR>
<?php
$result = mysql_query("SELECT * FROM employees") or die(mysql_error());
echo "<select name='Tech'multiple>";
while($row=mysql_fetch_array($result))
{
echo"<option>$row[Name]</option>";
}
echo"</select>";
?></select>
<BR><div>Hold The Control Key down to select multiple names</b></div><BR><BR>


<!--Work Order # <?php $_POST["Work"];?> was opened on <?php $_POST["Sched"];?> by
<?php $_POST["Tech"];?>.<br><br>
The Unit is located in<?php $_POST["Site"]?> with serial number <?php $_POST["Serial"]?>
and this unit has <?php $_POST["Hours"]?> Hours on it.
The Reported level of Severity is<?php $_POST["Severe"];?>and the Safety Level is<?php $_POST["Safe"];?>. <BR>

Additional Details on this equipment failure are as follows:<BR><BR>
<B>Description of Issue:</B><BR>
<?php $_POST["Issue"]?><BR><BR>
<B>Possible Resolution</B><BR>
<?php $_POST["Resolve"]?><BR><BR>
<B>Request for Assistance:</B><BR>
<?php $_POST["Assist"]?><BR><BR>
Parts Required: (that the technician is currently aware of)
<?php $_POST["PartsA"]?><BR>
<?php $_POST["PartsB"]?><BR>
<?php $_POST["PartsC"]?><BR>
<?php $_POST["PartsD"]?><BR>
<?php $_POST["PartsE"]?><BR>
<?php $_POST["PartsF"]?><BR>
<?php $_POST["PartsG"]?><BR><BR>
The following images have been uploaded:<BR>
<?php $_FILE["Image1"]?><BR>
<?php $_FILE["Image2"]?><BR>
<?php $_FILE["Image3"]?><BR>
<?php $_FILE["Image4"]?><BR>
-->


</div><BR><BR>

<div><B>Image Name: (Maximum of 4 images)</B>:</div>
<div><input type="text" value=<?php echo mysql_result($query, 0, 'Image1'); ?> size="40" maxlength="40 id="Image1"><BR>
<input type="text" value=<?php echo mysql_result($query, 0, 'Image2'); ?> size="40" maxlength="40 id="Image2"><BR>
<input type="text" value=<?php echo mysql_result($query, 0, 'Image3'); ?> size="40" maxlength="40 id="Image3"><BR>
<input type="text" value=<?php echo mysql_result($query, 0, 'Image4'); ?> size="40" maxlength="40 id="Image4"><BR>
</div>

<BR><BR>
<div><input type="submit" name="Submit" value="Update Work Order"></div>
<input type="hidden" name="doupload" value="Submit">
</form>
<?php
exit();

} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Image1 = $_FILE["Image1"];
$Image2 = $_FILE["Image2"];
$Image3 = $_FILE["Image3"];
$Image4 = $_FILE["Image4"];



mysql_query("INSERT INTO `workorder`(Work, Sched, Name, Site, Serial, Hours, Starts, Issue,
Severity, Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4)
VALUES ('$Work', '$Sched', '$Name', '$Site', '$Serial', '$Hours', '$Starts', '$Issue',
'$Severity', '$Resolution', '$Assistance','$PartsA', '$PartsB', '$PartsC', '$PartsD',
'$PartsE', '$PartsF', '$PartsG', '$Safety','$Image1', '$Image2', '$Image3', '$Image4')")or die(mysql_error());

echo "Your Work Order has been posted successfully";

}
?>
<?php
//echo print_r($_POST)
?>
</BODY>
</HTML>

djmonkey1
08-09-2006, 04:55 PM
You don't need to check in anywhere, probably just a stiff drink.

The problem with the display of the page is because you're getting an error back from your MySQL query.

Once you fix the query the display should look fine.

If it makes you feel any better, I'm getting the same result trying to use mysql_result() to echo values that way.

I came up with this:


<?php
$query = mysql_query("SELECT * FROM workorder WHERE Work='" . $Contact . "'");

if (mysql_num_rows($query) > 0) {
$finished_query = mysql_fetch_array($query, MYSQL_ASSOC);
$Sched = $finished_query['Sched'];

} //end if

?>

It might be overkill, but once you've set this up with a line like
$Sched = $finished_query['Sched']; for each of the entries you want to display, you can just use code like
echo $Sched; and you won't get all the weird characters in your HTML.

kenwvs
08-09-2006, 05:15 PM
I don't actually know if there is an error or a warning. When I run it with the
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
}

code in there, no error comes up. You and me and hald the world have this problem. When I typed it into google, it is amazing how many pages have this error on them, and people either don't know or don't care.

I tried putting a couple of the fields into the code you gave me, but get an error. I am not sure if the code you are talking about and the one fumigator is talking about is the same idea..... It is possible that I don't have te code you suggested in the right place, but I think I do....Here is what i have done...


<?php
include_once "myconnect.php";
$Contact = $_POST['Work'];
$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work='$Contact'");
if (mysql_num_rows($query) > 0) {
$finished_query = mysql_fetch_array($query, MYSQL_ASSOC);
$Sched = $finished_query['Sched'];
$Work = $finished_query['Work'];
} //end if
?>
<?php
// WorkOrder.php
if (!isset($_POST['Submit'])){
?>
<form action="" method="post"enctype="multipart/form-data">
<div>Work Order #:<?php echo ['$Work'];?>size="10" id="Work">
Date:<input type="text" value=<?php echo [$Sched]; ?> size="10" id="Sched">
Technician:"<input type="text" value=<?php echo ['Tech']; ?> size="10" id="Tech"> <BR><BR>

And the Error

Parse error: parse error, unexpected '[' in C:\wamp\www\BenProject\womanager.php on line 23

Fumigator
08-09-2006, 05:25 PM
Well I think you are right on the verge of getting this thing working completely :)

Question-- how is that work order# value getting to this page? You are using the variable $_POST['Work'], but that will be empty until this page is sumitted, which isn't what you want. Unless you are calling this page from another page (via method='post' on that form) with an input element with id='Work', that $_POST variable will be empty.

At any rate, I made some changes to your code here, which will solve the warnings being displayed, but your input fields will be empty still.



<head>
<!--<link href="ge.css" rel="stylesheet" type="text/css"> -->
<title>GE Work Order</title>
</head>
<BODY BGCOLOR="gainsboro">
<?php
include_once "myconnect.php";
$Contact = $_POST['Work'];
$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work='$Contact'");
if (!$query) {
echo "YOU HAVE AN ERROR IN YOUR QUERY!<br>\n";
echo mysql_error();
} else {
$workorderInfo = mysql_fetch_assoc($query);
}

//this is just for testing
if (mysql_num_rows($query) == 0) {
echo "No rows returned from table workorder using ID = $Contact.<br>\n";
}
?>
<?php
// WorkOrder.php
if (!isset($_POST['Submit'])){
?>
<form action="" method="post" enctype="multipart/form-data">
<div>Work Order #:<input type="text" value="<?php echo $workorderInfo['Work']; ?>" size="10" id="Work">
Date:<input type="text" value="<?php echo $workorderInfo['Sched']; ?>" size="10" id="Sched">
Technician:"<input type="text" value="<?php echo $workorderInfo['Name']; ?> " size="10" id="Name"> <BR><BR>
Site:<input type="text" value="<?php echo $workorderInfo['Site']; ?>" size="10" id="Site">
Unit Serial #:<input type="text" value="<?php echo $workorderInfo['Serial']; ?>" size="10" id="Serial">
Unit Hours:<input type="text" value="<?php echo $workorderInfo['Hours']; ?>" size="10" id="Hours">
<BR></><BR></>
Unit Starts:<input type="text" value="<?php echo $workorderInfo['Starts']; ?>" size="10" id="Starts">
Severity:<input type="text" value="<?php echo $workorderInfo['Severe']; ?>" size="10" id="Severe">
Safety:<input type="text" value="<?php echo $workorderInfo['Safety']; ?>" size="10" id="Safety">
</div> <BR>
<div><B>Description of Issue:</B><BR><input type="textarea" value="<?php echo $workorderInfo['Issue']; ?>" size="155" id="Issue">
</div><BR>
<div><B>Possible Resolution</B><BR><input type="textarea" value="<?php echo $workorderInfo['Resolve']; ?>" size="155" id="Resolve">
</div><BR>
<div><B>List of Parts Required (one part per line)</B>:</div>
<div><input type="textarea" value="<?php echo $workorderInfo['PartsA']; ?>" size="155" maxlength="155 id="PartsA"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsB']; ?>" size="155" maxlength="155 id="PartsB"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsC']; ?>" size="155" maxlength="155 id="PartsC"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsD']; ?>" size="155" maxlength="155 id="PartsD"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsE']; ?>" size="155" maxlength="155 id="PartsE"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsF']; ?>" size="155" maxlength="155 id="PartsF"><BR>
<input type="textarea" value="<?php echo $workorderInfo['PartsG']; ?>" size="155" maxlength="155 id="PartsG"><BR>
</div><BR>
<div><B>Request for Assistance:<BR><input type="textarea" value="<?php echo $workorderInfo['Assist']; ?>" size="155" id="Assist">
</div></B><BR><BR>

<div>
<div><center><B>Send this form to:<BR>
<?php
$result = mysql_query("SELECT * FROM employees") or die(mysql_error());
echo "<select name='Tech'multiple>";
while($row=mysql_fetch_array($result))
{
echo"<option>$row[Name]</option>";
}
echo"</select>";
?></select>
<BR><div>Hold The Control Key down to select multiple names</b></div><BR><BR>


<!--Work Order # <?php $_POST["Work"];?> was opened on <?php $_POST["Sched"];?> by
<?php $_POST["Tech"];?>.<br><br>
The Unit is located in<?php $_POST["Site"]?> with serial number <?php $_POST["Serial"]?>
and this unit has <?php $_POST["Hours"]?> Hours on it.
The Reported level of Severity is<?php $_POST["Severe"];?>and the Safety Level is<?php $_POST["Safe"];?>. <BR>

Additional Details on this equipment failure are as follows:<BR><BR>
<B>Description of Issue:</B><BR>
<?php $_POST["Issue"]?><BR><BR>
<B>Possible Resolution</B><BR>
<?php $_POST["Resolve"]?><BR><BR>
<B>Request for Assistance:</B><BR>
<?php $_POST["Assist"]?><BR><BR>
Parts Required: (that the technician is currently aware of)
<?php $_POST["PartsA"]?><BR>
<?php $_POST["PartsB"]?><BR>
<?php $_POST["PartsC"]?><BR>
<?php $_POST["PartsD"]?><BR>
<?php $_POST["PartsE"]?><BR>
<?php $_POST["PartsF"]?><BR>
<?php $_POST["PartsG"]?><BR><BR>
The following images have been uploaded:<BR>
<?php $_FILE["Image1"]?><BR>
<?php $_FILE["Image2"]?><BR>
<?php $_FILE["Image3"]?><BR>
<?php $_FILE["Image4"]?><BR>
-->


</div><BR><BR>

<div><B>Image Name: (Maximum of 4 images)</B>:</div>
<div><input type="text" value="<?php echo $workorderInfo['Image1']; ?>" size="40" maxlength="40 id="Image1"><BR>
<input type="text" value="<?php echo $workorderInfo['Image2']; ?>" size="40" maxlength="40 id="Image2"><BR>
<input type="text" value="<?php echo $workorderInfo['Image3']; ?>" size="40" maxlength="40 id="Image3"><BR>
<input type="text" value="<?php echo $workorderInfo['Image4']; ?>" size="40" maxlength="40 id="Image4"><BR>
</div>

<BR><BR>
<div><input type="submit" name="Submit" value="Update Work Order"></div>
<input type="hidden" name="doupload" value="Submit">
</form>
<?php
exit();

} else
{
$Work = $_POST["Work"];
$Sched = $_POST["Sched"];
$Name = $_POST["Tech"];
$Site = $_POST["Site"];
$Serial = $_POST["Serial"];
$Hours = $_POST["Hours"];
$Starts = $_POST["Starts"];
$Issue = $_POST["Issue"];
$Severity = $_POST["Severe"];
$Resolution = $_POST["Resolve"];
$Assistance = $_POST["Assist"];
$PartsA = $_POST["PartsA"];
$PartsB = $_POST["PartsB"];
$PartsC = $_POST["PartsC"];
$PartsD = $_POST["PartsD"];
$PartsE = $_POST["PartsE"];
$PartsF = $_POST["PartsF"];
$PartsG = $_POST["PartsG"];
$Safety = $_POST["Safe"];
$Image1 = $_FILE["Image1"];
$Image2 = $_FILE["Image2"];
$Image3 = $_FILE["Image3"];
$Image4 = $_FILE["Image4"];



mysql_query("INSERT INTO `workorder`(Work, Sched, Name, Site, Serial, Hours, Starts, Issue,
Severity, Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
Safety, Image1, Image2, Image3, Image4)
VALUES ('$Work', '$Sched', '$Name', '$Site', '$Serial', '$Hours', '$Starts', '$Issue',
'$Severity', '$Resolution', '$Assistance','$PartsA', '$PartsB', '$PartsC', '$PartsD',
'$PartsE', '$PartsF', '$PartsG', '$Safety','$Image1', '$Image2', '$Image3', '$Image4')")or die(mysql_error());

echo "Your Work Order has been posted successfully";

}
?>
<?php
//echo print_r($_POST)
?>
</BODY>
</HTML>

kenwvs
08-09-2006, 05:44 PM
Once it is live, you will type in the URL which will take you to a page where you choose what you want to do. If the manager selects this page, it takes him to a page called womanagerlogin. php where he keys in the work order # and it finds it and loads it in this page. Here is the coding for that page.... I think it works as is.....


<head>
<!--<link href="ge.css" rel="stylesheet" type="text/css"> -->

<title>GE Work Order</title>
</head>
<BODY BGCOLOR="gainsboro">
<form action="womanager.php" method="post">
<center><div>Work Order #:<input type="text" size="10" maxlength="10" name="Contact">
<div><input type="submit" name="Submit" value="Request Work Order"></div>

</BODY>
</HTML>


I have tried several different login scripts to require a password to get to restricted pages. None of them work, and I am wondering if this is because I am on the local server....or should that not make a difference. am trying to use a very basic password system, where you key in the email address and password and it lets you load this page..this is not a high security concern, just stops the employee from adding a Purchase Order........keeping the honest people out.

kenwvs
08-09-2006, 05:50 PM
Well, you are right, the fields are blank, but my login page isn't loading the info up, so I will work on that.

If I want to upload images to the Database, or to a folder and just the filename to the database, at the same time as submitting a form, can I do that....it is like needing two actions with the push of one button.

and last question.....how hard is it to set up the mail() to send the emails to people I select in the form. You will notice on the form a drop down box of names and I want to select multiple names from there to send an email with the information in the body of the email. The images could either go as an attachment, or don't have to go, they can retrieve them through the system.

Back to my login page to make it work.

ken

kenwvs
08-09-2006, 05:54 PM
What did I have wrong on that form that you corrected to get the blank fields.... I looked and looked and looked, and don't know what I was doing wrong, and would like to know how it was done, for future reference.

Fumigator
08-09-2006, 05:55 PM
You have the right idea generally, but you need to use the name of the input field that is on the page that calls your query page.



$Contact = $_POST['Contact'];


The variable $_POST['Contact'] is loaded with the value from this form:



<form action="womanager.php" method="post">
<center><div>Work Order #:<input type="text" size="10" maxlength="10" name="Contact">


By the way you need a </form> tag on that page to close the form.

As for your other questions, one issue at a time :)

kenwvs
08-09-2006, 05:59 PM
Will this work even if Contact is not a field in the database? I guess it is just the field on the login form, not going to the db. When it gets to the other form, it then calls it from the db. On the form you changed, would my variable of

$Contact = $_POST['Work']; be correct?

Do you know of a very basic, good tutorial that deals with variables, and how they work, etc.... I am struggling with this concept.

kenwvs
08-09-2006, 06:02 PM
OK, that loads the page, but I need to fix some errors, as some fields are not working. If I just follow the format for the ones working I should be ok, as I am not sure what you have changed.

Ken

kenwvs
08-09-2006, 06:13 PM
I have it all working the way it is suppose to....Thank You very much for your help..... You made it look so easy......and I struggled for so long.....

Is there a way to have text areas span the 4 rows they do in the original form...as some of the text doesn't show. I tried adding rows="4", but that wasn't the correct change.

Ken

Fumigator
08-09-2006, 06:53 PM
You're welcome! :)

www.w3schools.com (http://www.w3schools.com) has some good tutorials on the ins and outs of using forms with PHP.

One thing I do to keep all the variables straight is name them using prefixes or suffixes that indicate what they are used for. For example my input tags all have a prefix of "i", followed by a capitalized description:

iContact
iWorkorder
iName
iImage1

My database fields all use a suffix "_xx" that describes the data type:

person_nm (a name)
customer_id (an id)
contact_nr (a number)
house_ds (a description)

My database tables have a suffix of "_tbl":

workorder_tbl
customer_tbl

So when you put them all together in the same area, there is no confusion which variable represents what!

In regards to sizing the inputs, ideally you would use CSS to format the <input> tags. That's my recommendation.

In your CSS file:


.areaEntry {
font-size: 12px;
font-family: Verdana, arial;
color: #000;
background: #ddd;
width: 300px;
height: 150px;
}


In your HTML (for example):


<input type="textarea" value="<?php echo $workorderInfo['PartsB']; ?>" class="areaEntry" id="PartsB" />

kenwvs
08-10-2006, 07:52 PM
Thank You for the tip on putting suffixes or prefixes on the names...I can see how that would be of benefit, and I will start to do that, and convert my current pages to that format as well.... this is one of the best suggestions I have read anywhere....Good Job!!

For some reason it appears that my file myconnect.php is not working. it was workign fine, and now it isn't letting anything connect to the DB. It gives an error that there is a call to an undefined function, yet nothing has changed, except I am trying out a new php editor.... Here is what my connecting script looks like, and I have a line in the main script that says include_once "myconnect.php";


<?php

// YOU NEED TO CHANGE THE CONTENTS OF THE values of variables given in single quotes

//CONFIGURATION SECTION STARTS ///

$servername='localhost' ; // Replace this 'localhost' with your server name
$database_username='root'; // Replace this with your username
$database_password=''; // Replace this with your password
$database_name='ge'; // Replace this 'db' with your database name
//$ADMIN[RequirePass] = "No"; // Checks to see if upload has a vaild password
//$ADMIN[Password] = "password"; // This is the password if the above option is Yes
//$ADMIN[UploadNum] = "5"; // Number of upload feilds to put on the html page
//$ADMIN[directory] = "UploadFile"; // The directory the files will be uploaded to (must be chmoded to 777)

// CONFIGURATION SECTION ENDS ////



mysql_connect($servername,$database_username,$database_password);
mysql_select_db($database_name)or die(mysql_error());
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum