psychowolvesbane Posted December 31, 2007 Share Posted December 31, 2007 Hello I've been trying to get this to work for a few days but it still isn't working. I've narrowed the problem down to the If Statement surrounding the MySQL update query and the Query itself as neither seem to work with or without each other. To explain, the form contains an existing value if the form hasn't been posted, if it has then whatever was in that form is kept on for Updating or for validating. The form and all the other parts work great except the previously mentioned sections. Can anyone see where I am going wrong? <?php $Submit = $_POST[submitB]; $ItemType = $_POST[itemType]; $EditThisItemType2 = $_POST[CurItemType]; $NotExec = true; if ($_POST['SubmitB'] != "Submit") { $EditThisItemType = $_GET[EditThisItemType]; } if ($_POST['SubmitB'] == "Submit") { if ($ItemType == "") { ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } elseif($Edited == false) { ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg"><?php echo "Could not be edited, $ItemType may already exist!"; ?></span> </div> <?php } elseif($ItemType != "") { $Valid_form = true; $Valid_ItemType = true; } [b]if($Valid_form == true && $Valid_ItemType == true) { $conn = mysql_connect('host:port',username','password'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType2'"; $rsUpdate = mysql_query($sqlUpdate,$conn); if(mysql_affected_rows($conn) == "1") { $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="-1") { $Edited = false; $NotExec = true; } mysql_close($conn); }[/b] } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc') ?> <?php if($NotExec = false) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=display_item_types.php?Action=Edit&Edited=$Edited&NotExec=$NotExec"> <?php } ?> </head> <body> <?php require('header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:75px; left:200px; width:550px"> <?php if($_POST['SubmitB'] == "Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType2 ?></span> <br> <br> <?php } if($_POST['SubmitB'] !="Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType ?></span> <br> <br> <?php } ?> <form method="post" action='edit_item_type_form.php'/> <?php if($Valid_ItemType == false and $_POST['SubmitB'] == "Submit") { ?> <span class="errmsg">! </span> <?php } ?> Item Type: <input type="text" name="ItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['ItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="hidden" name="CurItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['CurItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> <br> <br> <br> <br> <a href="display_item_types.php?Action=Edit">Back to Edit Item Types List</a> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/ Share on other sites More sharing options...
hitman6003 Posted December 31, 2007 Share Posted December 31, 2007 Show the mysql error and see what you get... change: $rsUpdate = mysql_query($sqlUpdate,$conn); to $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-426938 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 Okay I tried to do that but it didn't even bring up any message at all, with or without the If statements surrounding it or moving the code into the <body> tags to see if it made a difference but it hasn't. I removed the require(head.inc) so that I could see if any errors were hiding behind it, but still nothing. <?php $Submit = $_POST[submitB]; $ItemType = $_POST[itemType]; $EditThisItemType2 = $_POST[CurItemType]; $NotExec = true; if ($_POST['SubmitB'] != "Submit") { $EditThisItemType = $_GET[EditThisItemType]; } if ($_POST['SubmitB'] == "Submit") { if ($ItemType == "") { ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } elseif($Edited == false) { ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg"><?php echo "Could not be edited, $ItemType may already exist!"; ?></span> </div> <?php } elseif($ItemType != "") { $Valid_form = true; $Valid_ItemType = true; } } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc') ?> <?php if($NotExec = false) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=display_item_types.php?Action=Edit&Edited=$Edited&NotExec=$NotExec"> <?php } ?> </head> <body> <?php require('menu.inc') ?> <?php if($Valid_ItemType == true && $Valid_form == true) { $conn = mysql_connect('host:port','username','password'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType2'"; $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); if(mysql_affected_rows($conn) == "1") { $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="-1") { $Edited = false; $NotExec = true; } mysql_close($conn); } ?> <div style="position:absolute; top:75px; left:200px; width:550px"> <?php if($_POST['SubmitB'] == "Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType2 ?></span> <br> <br> <?php } if($_POST['SubmitB'] !="Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType ?></span> <br> <br> <?php } ?> <form method="post" action='edit_item_type_form.php'/> <?php if($Valid_ItemType == false and $_POST['SubmitB'] == "Submit") { ?> <span class="errmsg">! </span> <?php } ?> Item Type: <input type="text" name="ItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['ItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="hidden" name="CurItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['CurItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> <br> <br> <br> <br> <a href="display_item_types.php?Action=Edit">Back to Edit Item Types List</a> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427040 Share on other sites More sharing options...
kjtocool Posted January 1, 2008 Share Posted January 1, 2008 <?php $Submit = $_POST[submitB]; $ItemType = $_POST[itemType]; $EditThisItemType2 = $_POST[CurItemType]; $NotExec = true; if ($_POST['SubmitB'] != "Submit") { $EditThisItemType = $_GET[EditThisItemType]; ?> Shouldn't statements like that contain ' ' wrappers like so: <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; $NotExec = true; if ($_POST['SubmitB'] != "Submit") { $EditThisItemType = $_GET['EditThisItemType']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427051 Share on other sites More sharing options...
remyaarun Posted January 1, 2008 Share Posted January 1, 2008 This was the previous code: ***** $conn = mysql_connect('host:port',username','password'); $db = mysql_select_db('dbname', $conn); May be the problem is for the statement mysql_connect('host:port',username','password'); here the single quotes for username is not corect ..just change it to 'username' and do check it out Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427055 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 Okay I finally got it to update correctly thanks to kjtocool, however it only works without the if statement which is quite necessary: if($Valid_ItemType == true && $Valid_form == true) {} The only problem now is either rearrangement or change the if statements. <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; if ($_POST['SubmitB'] != "Submit") { $EditThisItemType = $_GET['EditThisItemType']; } if ($_POST['SubmitB'] == "Submit") { $Valid_form = true; $Valid_ItemType = true; if ($ItemType == "") { ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } if($Valid_form == "true" && Valid_ItemType == "true") { $conn = mysql_connect('host:port','username','password'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType'"; $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); if(mysql_affected_rows($conn) == 1) { $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) ==-1) { $Edited = false; $NotExec = true; } mysql_close($conn); } if($Edited == false && $NotExec == true) { ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be edited, <?php echo "$ItemType";?> may already exist!</span> </div> <?php } } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc') ?> <?php if($NotExec == false && $Edited == true) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=display_item_types.php?Action=Edit&Edited=$Edited&NotExec=$NotExec"> <?php } ?> </head> <body> <?php require('header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:75px; left:200px; width:550px"> <?php if($_POST['SubmitB'] == "Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType2 ?></span> <br> <br> <?php } if($_POST['SubmitB'] !="Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType ?></span> <br> <br> <?php } ?> <form method="post" action='edit_item_type_form.php'/> <?php if($Valid_ItemType == false and $_POST['SubmitB'] == "Submit") { ?> <span class="errmsg">! </span> <?php } ?> Item Type: <input type="text" name="ItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['ItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="hidden" name="CurItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['CurItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> <br> <br> <br> <br> <a href="display_item_types.php?Action=Edit">Back to Edit Item Types List</a> </div> </body> </html> P.S. I already have a working connection. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427060 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 I still haven't solved this problem. Although I have finally got the right syntax for the Update function I still cannot get the program to get through the If statements correctly to run it. Is there any way to do so from the above code without removing any of the validation used? Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427539 Share on other sites More sharing options...
teng84 Posted January 1, 2008 Share Posted January 1, 2008 maybe you missed something try to check if you really got the values for $ItemType = $_POST['ItemType']; try to echo $ItemType to see if it has a value !! Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427571 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 $ItemType gets displayed back into the form every time it validates it and sees it is wrong, that isn't the problem, Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427575 Share on other sites More sharing options...
teng84 Posted January 1, 2008 Share Posted January 1, 2008 <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; if ($_POST['SubmitB'] == "Submit") { $Valid_form = true; $Valid_ItemType = true; if (empty($ItemType)){ ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } else{ $conn = mysql_connect('host:port','username','password'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType'"; $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); if(mysql_affected_rows($conn) == 1) { $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) ==-1){ $Edited = false; $NotExec = true; ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be edited, <?php echo "$ItemType";?> may already exist!</span> </div> <?php } mysql_close($conn); } } else{ $EditThisItemType = $_GET['EditThisItemType']; } ?> try that .. just reorder your logic and men you should use tab / indent your code properly whoass! Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427585 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 I tried that but it still isn't playing right. When I press submit the info is sent into ItemType for $_POST[itemType] to colelct and is redisplayed back into the text box, but not error message is displayed or MySQL action taken. I did checked to see if it brought up the validation when the form was empty, that was fine. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427596 Share on other sites More sharing options...
teng84 Posted January 1, 2008 Share Posted January 1, 2008 i suggest put an echo on all your ifs to see what part of the if is not working eg.. inside the fist if put echo '1'; then on the next echo '2'; then post here that part that is not functioning and that you need to work. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427600 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 Okay I tried it and here is the code with added echoes <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; if ($_POST['SubmitB'] == "Submit") { echo '1'; $Valid_form = true; $Valid_ItemType = true; if (empty($ItemType)) { echo '2'; ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } else { echo '3'; echo "$EditThisItemType2"; echo "$ItemType"; $conn = mysql_connect('host:port','username','clothingline'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType2'"; $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); if(mysql_affected_rows($conn) == "1") { echo '4'; $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="-1"){ echo '5'; $Edited = false; $NotExec = true; ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be edited, <?php echo "$ItemType";?> may already exist!</span> </div> <?php } mysql_close($conn); } } else { echo '6'; $EditThisItemType = $_GET['EditThisItemType']; } ?> It displays 6 first of all when the page is loaded, fine. It displays only 1 and 2 when the form is blank, fine. It displays 1,3, the correct value of $EditThisItemType2 and $ItemType, fine. However after that it just gives up and 4 and 5 are missed altogether. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427622 Share on other sites More sharing options...
teng84 Posted January 1, 2008 Share Posted January 1, 2008 <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; if ($_POST['SubmitB'] == "Submit") { echo '1'; $Valid_form = true; $Valid_ItemType = true; if (empty($ItemType)) { echo '2'; ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } else { echo '3'; echo "$EditThisItemType2"; echo "$ItemType"; $conn = mysql_connect('host:port','username','clothingline'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType2'"; $rsUpdate = mysql_query($sqlUpdate,$conn) or die(mysql_error()); if($rsUpdate) { echo '4'; $Edited = true; $NotExec = false; } else{ echo '5'; $Edited = false; $NotExec = true; ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be edited, <?php echo "$ItemType";?> may already exist!</span> </div> <?php } mysql_close($conn); } } else { echo '6'; $EditThisItemType = $_GET['EditThisItemType']; } ?> try and i guess you dont need mysl affected rows simply ask if the query failed or succeed Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427633 Share on other sites More sharing options...
psychowolvesbane Posted January 1, 2008 Author Share Posted January 1, 2008 According to my readings rsUpdate seems to equal "1" every time I run it. Here's the code again (without your previous edits, which made it redirect anyway even if it wasn't right) <?php $Submit = $_POST['SubmitB']; $ItemType = $_POST['ItemType']; $EditThisItemType2 = $_POST['CurItemType']; if ($_POST['SubmitB'] == "Submit") { echo '1'; $Valid_form = true; $Valid_ItemType = true; if (empty($ItemType)) { echo '2'; ?> <div style="position:absolute; top:220px; left:200px; width:550px"> <span class="errmsg">Please Enter an Item Type</span> </div> <?php $Valid_form = false; $Valid_ItemType = false; } else { echo '3<br>'; echo "$EditThisItemType2 is Current Item Type<br>"; echo "$ItemType is new Item Type<br>"; $conn = mysql_connect('host:port','username','password'); $db = mysql_select_db('dbname', $conn); $sqlUpdate = "UPDATE ItemType SET ItemType = '$ItemType' WHERE ItemType = '$EditThisItemType2'"; $rsUpdate = mysql_query($sqlUpdate,$conn); $affectedrows = mysql_affected_rows($conn); echo "$sqlUpdate is sqlUpdate<br>"; echo "$rsUpdate is rsUpdate<br>"; echo "$affectedrows is number of affected rows<br>"; if(mysql_affected_rows($conn) == "1") { echo '4'; $Edited = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="0"){ echo '5'; $Edited = false; $NotExec = true; ?> <div style="position:absolute; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be edited, <?php echo "$ItemType";?> may already exist!</span> </div> <?php } mysql_close($conn); } } else { echo '6'; $EditThisItemType = $_GET['EditThisItemType']; } ?> and the results 1 3 "Vests" is Current Item Type "Vest" is new Item Type "UPDATE ItemType SET ItemType = 'Vest' WHERE ItemType = ' Vests'" is sqlUpdate "1" is rsUpdate "0" is number of affected rows 5 Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427662 Share on other sites More sharing options...
teng84 Posted January 2, 2008 Share Posted January 2, 2008 your reading is absolutely correct but mysql query returns true or false so i guess you dont need it you already have the result Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427665 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Author Share Posted January 2, 2008 So can you see what is wrong with the update syntax? I've noticed that after posting the code onto the forum and on the site there is a 1 char space between the ' and the $EditThisItemType within the Update query, is this formatting or the real problem? It doesn't have a space on my source code, so it is weird. Edit: Nevermind it was nothing, didn't fix it. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427673 Share on other sites More sharing options...
teng84 Posted January 2, 2008 Share Posted January 2, 2008 you still use your old code hmm any ways i dont know what is logic with this if(mysql_affected_rows($conn) == "1") { your trying to check if it connect or not? i suppose it should be if(mysql_affected_rows($rsUpdate) == "1") i still suggest use the result form your query instead of affected rows Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427684 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Author Share Posted January 2, 2008 No, it doesn't like if(mysql_affected_rows($rsUpdate) == "1") as it comes up with Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/www/domain/admin/edit_item_type_form.php on line 40 Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/www/domain/admin/edit_item_type_form.php on line 45 5 I also kept with the previous code because rsUpdate always seems to be 1 and still does not update the value of ItemType, which means it thinks it has done it but hasn't. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427690 Share on other sites More sharing options...
teng84 Posted January 2, 2008 Share Posted January 2, 2008 put a die on yur query $rsUpdate = mysql_query($sqlUpdate,$conn) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427707 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Author Share Posted January 2, 2008 I did, still nothing. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-427719 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Author Share Posted January 2, 2008 I actually know what is causing the problem and it wasn't anything we thought it was either! Okay, in my main form I am using a Hidden field (CurItemType) so that I can keep track of the Item Type that already exists (EditThisItemType), and allow it to be transferred correctly when the submit is pressed right? Well it was half doing it because I just changed it from a Hidden field to a Text field and it actually made the entire thing work!! The only problem is that I need it to stay hidden or come up with another method for hiding it. Here is the main body of code for the form: <body> <div style="position:absolute; top:75px; left:200px; width:550px"> <?php if($_POST['SubmitB'] == "Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType2 ?></span> <br> <br> <?php } if($_POST['SubmitB'] !="Submit") { ?> <span class="head3">Edit Form for Item Type: <?php echo $EditThisItemType ?></span> <br> <br> <?php } ?> <form method="post" action='edit_item_type_form.php'/> <?php if($Valid_ItemType == false and $_POST['SubmitB'] == "Submit") { ?> <span class="errmsg">! </span> <?php } ?> Item Type: <input type="text" name="ItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['ItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="hidden" name="CurItemType" value=" <?php if($_POST['SubmitB'] == "Submit") { echo $_POST['CurItemType']?>"/> <?php } if($_POST['SubmitB'] != "Submit") { echo $EditThisItemType ?>"/> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> <br> <br> <br> <br> <a href="display_item_types.php?Action=Edit">Back to Edit Item Types List</a> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-428043 Share on other sites More sharing options...
adam291086 Posted January 2, 2008 Share Posted January 2, 2008 Have you tried echoing the hidden field once submitted. It should work. Why dont you set the item type as a session. Then you can call on it any time. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-428046 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Author Share Posted January 2, 2008 I've never tried Sessions before so I don't know how to use them. I know about the Session Start() function but not about implementing it. Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-428048 Share on other sites More sharing options...
adam291086 Posted January 2, 2008 Share Posted January 2, 2008 ok. This is how to set a session <?php session_start(); // store session data $_SESSION['views']=1; ?> So when the current type is select create a variable that stores this information. Then set a session to = that variable like below <?php session_start(); //get current type selected $a = $_POST['current']; // store session data $_SESSION['views']=$a; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83879-solved-mysql-update-query-problem/#findComment-428050 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.