kenwvs Posted August 18, 2006 Share Posted August 18, 2006 I have a feeling the error listed below is just to frustrate people. I have tried using single quotes, double quotes, no quotes, and also using $Work instead of $Contact (as $Contact=$Work from another page) and I get this same error, regardless of what I am using.The 08194151 is the work order number that I have keyed in on the previous page, to bring up this page. This error is coming up as soon as I hit enter, which directs this page to load, with all the data loaded into it. I don't actually get the page to load with all the data.[quote]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Comment = WHERE Work = '08194151'' at line 1[/quote][code]else{$Purchase = $_POST["Purchase"];$Comment = $_POST["Comment"];$sql ="UPDATE `workorder` set Purchase = '$Purchase', Comment = '$Comment' WHERE Work = '$Contact'";mysql_query($sql)or die(mysql_error());echo $sql;}[/code]I am not sure if the page is loading, or if I am getting an error before it actually loads.... Quote Link to comment Share on other sites More sharing options...
corbin Posted August 18, 2006 Share Posted August 18, 2006 Hmmm try changing it to [code=php:0]else{$Purchase = $_POST["Purchase"];$Comment = $_POST["Comment"];$sql ="UPDATE `workorder` set Purchase = '$Purchase', Comment = '$Comment' WHERE Work = '$Contact'";//mysql_query($sql)or die(mysql_error());echo $sql;}[/code]And see what it says $sql is... Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 18, 2006 Share Posted August 18, 2006 Try:[code]<?php$sql ="UPDATE workorder set Purchase = $Purchase, Comment = $Comment WHERE Work = '$Contact'";?>[/code]Also, make sure you're taking into account case sensitivty. Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 Corbin:When I change it like you suggested, the syntax error dissappears and I get the line below. I still don't have the form appear where i can actually input the information for Purchase and Comment before it updates. Nothing is appearing in the database, so I am assuming nothing is happening as far as updating....[quote]UPDATE `workorder` set Purchase = '', Comment = '' WHERE Work = '08194151'[/quote]Caesar:when I try it like you suggested, I get the same result as above, just without the quotes....where we have removed them.If I change it back to it was to start with, the syntax error is gone, and I get the same result as above. If I key in an invalid work number, then I get the same result as above, with the following line also added..[quote]No rows returned from table workorder using ID = ''[/quote] Quote Link to comment Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 You do already have the Work value of 08194151 in the database, right? Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 yes, that work order number is in the db.... see my note that i typed as you were typing Quote Link to comment Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 Try doing a test insert just to make sure that the $_POST variables are not messing with you.else{$Purchase = $_POST["Purchase"];$Comment = $_POST["Comment"];$sql ="UPDATE `workorder` set Purchase = 'test', Comment = 'test' WHERE Work = '$Contact'";mysql_query($sql)or die(mysql_error());}If that does not work, try replacing $Contact with the actual number, 08194151 ... perhaps the variable is getting lost somewhere. Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 So you are suggesting that instead of using update, change it to insert? Am I not going to run into the same problem, where the form itself won't show up on the screen, so I can't input any data? Right now, when I key in the number, I don't get the form itself, just the comments above.Ken Quote Link to comment Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 Sorry, I meant try doing a test 'update', using the provided code. (e.g. instead of using the Purchase and Comment variables from $_POST, just try entering random samples to make sure that it will actually update) If it does, it's something wrong with your $_POST variables, if it doesn't, it's something wrong with your query and/or database. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 18, 2006 Share Posted August 18, 2006 try this[code=php:0]$sql ="UPDATE `workorder` SET `purchase` = '$purchase', `comment` = '$comment' WHERE `work` = '$contact'";[/code]I tested something just like this and it worked fine. Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 When I replace it with Test, that updates to the DB.So I am thinking that means there is something wrong with the variables, but, the way it is, there is something wrong elsewhere (I think) cause I can't input any data in for the variable to use, as the form fields itself doesn't come on the screen.Would it be a problem with this, seeing as the form isn't coming up?[code]<?php$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG, Safety 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 testingif (mysql_num_rows($query) == 0) { echo "No rows returned from table workorder using ID = '$Work'<br>\n";}?><?phpif (!isset($_POST['Submit'])){?>[/code][b]All the form data[/b][code]else{$Purchase = $_POST["Purchase"];$Comment = $_POST["Comment"];$sql ="UPDATE `workorder` set Purchase = 'test', Comment = 'test' WHERE Work = '$Contact'";mysql_query($sql)or die(mysql_error());echo $sql;}exit();[/code] Quote Link to comment Share on other sites More sharing options...
corbin Posted August 18, 2006 Share Posted August 18, 2006 Ummm where is your form coming from? I havent seen a form yet... Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 Here is how it basically works.An engine fails and a technician completes a workorder (Page A). A Manager is notified of this, and goes to a html page (Page B) where they key in the workorder #, which is suppose to bring up the Manager Form (Page C), which is where he can add comments and a purchase order number, and then update the database.I have the original form working, and the form where the manager calls up Page C, but I can't get Page C to appear on the screen, and then update to the DB. The code I supplied in a post earlier is the info from Page C, minus the form itself. In my editor, if I preview Page C, the form will come up on the screen, but when I try to actually run the codes through, I don't get the form. Where the form should be, that is where I get the UPDATE `workorder` set Purchase = '', Comment = '' WHERE Work = '08194151' statement.Somewhere in this process, the page is coming up properly, and if I do get the page up, and try to input data and then update it, it won't update. Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 This is the complete code, for Page C, which is the form that should come up with the data in it, and then the manager can add comments and a purchase order #[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>GE Jenbacher</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="ge.css" rel="stylesheet" type="text/css"><?phpinclude_once "myconnect.php";$Contact = $_POST['Contact'];// GEWOManager.php?></head><body><div class="clearfix" id="mainbox"><!--Open Mainbox--><div id="header"<!--Open Header--><?phpinclude "header.html"//This is an include for all of the Header?></div> <!--Close Header--><div id="topnav"><!--Open Top Navigation-->Manager Update <span class ="sub"><BR> (Assign a Purchase Order) </span></div><!--Close Top Navigation --><div id="content"><BR><BR><BR> <!--Open Content--><?php$query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG, Safety 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 testingif (mysql_num_rows($query) == 0) { echo "No rows returned from table workorder using ID = '$Work'<br>\n";}?><?phpif (!isset($_POST['Submit'])){?><form action="" method="post" enctype="multipart/form-data"><center><div>Purchase Order #:<input type="text" size="12" maxlength="12" name="Purchase"><BR><BR><div><B>Manager Comments:<BR><textarea rows="4" name="Comment" cols="80"></textarea></div></B><BR><BR><div>Work Order Number:<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="25" id="Name"> <BR><BR>Site:<input type="text" value="<?php echo $workorderInfo['Site']; ?>" size="20" id="Site">Unit Serial Number:<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['Severity']; ?>" size="25" id="Severe"> Safety:<input type="text" value="<?php echo $workorderInfo['Safety']; ?>" size="25" id="Safety"></div> <BR><div><B>Description of Issue</B><BR><textarea id="Issue" rows="4" cols="80"><?php echo mysql_result($query, 0, 'Issue') ?></textarea></div><BR><div><B>Possible Resolution</B><BR><textarea id="Resolve" rows="4" cols="80"><?php echo mysql_result($query, 0, 'Resolution') ?></textarea></div><BR><div><B>List of Parts Required (one part per line)</B>:</div><div><input type="textbox" value="<?php echo $workorderInfo['PartsA']; ?>" size="80" maxlength="80" id="PartsA"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsB']; ?>" size="80" maxlength="80" id="PartsB"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsC']; ?>" size="80" maxlength="80" id="PartsC"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsD']; ?>" size="80" maxlength="80" id="PartsD"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsE']; ?>" size="80" maxlength="80" id="PartsE"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsF']; ?>" size="80" maxlength="80" id="PartsF"><BR><input type="textbox" value="<?php echo $workorderInfo['PartsG']; ?>" size="80" maxlength="80" id="PartsG"><BR></div><BR><div><B>Request for Assistance:<BR><textarea id="Assist" rows="4" cols="80"><?php echo mysql_result($query, 0, 'Assistance') ?></textarea></div><BR><div><center><B>The Following people were advised of this Work Order:<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><BR><BR><div><input type="submit" name="Submit" value="Update Work Order"><BR><BR><BR><BR></center><input type="hidden" name="Contact" value="<?php echo $_POST['Contact']; ?>" /></form></div></div><!--Close Content--><div id="footer"><!--Open Footer--><?phpinclude "footer.html"?> <!-- Close Footer --></div><!-- Close Mainbox --><?php//exit();} else{$Purchase = $_POST["Purchase"];$Comment = $_POST["Comment"];$sql ="UPDATE `workorder` set Purchase = 'test', Comment = 'test' WHERE Work = '$Contact'";mysql_query($sql)or die(mysql_error());echo $sql;}exit();?><?php//echo print_r($_POST)?></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 I think I have determined why the form wasn't showing. I had the !isset() code instead of a isset(). I can get the form to show up, but I still am not getting it to update. If I replace the variable with TEST and it updates to the DB, would that mean i have a problem with the variable statement somewhere in the coding? Quote Link to comment Share on other sites More sharing options...
kenwvs Posted August 18, 2006 Author Share Posted August 18, 2006 When I remove the !isset() and replace it with the isset() the form appears, but it won't update to the DB. When I have the !isset() command, it won't show the form, but the DB will update. Any idea as to what I should start looking at changing to get this working. It appears as if everything is backwards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.