sliperypete Posted November 28, 2006 Share Posted November 28, 2006 In this piece of code I am trying to update the ticket table in my mysql database based on the ticketid that is passed in the URL. I am trying to insert data into the solution attribute. For some reason I cant figure out why it is not working maybe a new set of eyes can help me out. Thanks in Advance !<?php session_start();include "level2_check.php";include("config.php");$status = $_POST['status'];$solution = $_POST['solution'];if(isset($_POST['Submit'])){ $res = mysql_query("SELECT * FROM ticket WHERE ticket_id='$ticketid'");if (mysql_num_rows($res) > 0) { // found a match $sql="UPDATE ticket SET solution='$solution' WHERE ticket_id='$ticketid'"; $result = mysql_query($sql) or die(mysql_error()); echo "The ticket is now closed good work!";} else { echo "There was an error trying to close this ticket please try again";}}?><html><head><title>Close Ticket</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="style.css" rel="stylesheet" type="text/css"><?php include ("admin_header.html") ?></head><body><?php echo $ticketid; ?><h3 align="center">Close Ticket</h3><table width="60%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000"><form name="form1" method="post" action="admin_closeticket.php"> <input name="status" type="hidden" id="status" value="0"> <tr> <td nowrap align="right">Solution:</td> <td height="100"><textarea name="solution" id="solution"></textarea></td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </form> </table></body></html> Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/ Share on other sites More sharing options...
corbin Posted November 28, 2006 Share Posted November 28, 2006 Nothing is setting the $ticketid var... Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131385 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 When I do this:<?php echo $ticketid; ?>It outputs the same ticketid that is in the URL Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131391 Share on other sites More sharing options...
corbin Posted November 28, 2006 Share Posted November 28, 2006 Ooo you have register globals on then... Try changing <form name="form1" method="post" action="admin_closeticket.php"> to <form name="form1" method="post" action="admin_closeticket.php?ticketid=<?=$ticketid;?>"> Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131393 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 Can you pls try like this$query="SELECT * FROM ticket WHERE ticket_id='".$ticketid."'"$res = mysql_query($query);if (mysql_num_rows($res) > 0) { // found a match $sql="UPDATE ticket SET solution='".$solution."' WHERE ticket_id='".$ticketid."'"; Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131395 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 [quote author=corbin link=topic=116548.msg474922#msg474922 date=1164690511]Ooo you have register globals on then... Try changing <form name="form1" method="post" action="admin_closeticket.php"> to <form name="form1" method="post" action="admin_closeticket.php?ticketid=<?=$ticketid;?>">[/quote]Yes I haev register globals on...That code didnt work... Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131396 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 Did you try concatination the variables. like this$query="SELECT * FROM ticket WHERE ticket_id='".$ticketid."'"$res = mysql_query($query);if (mysql_num_rows($res) > 0) { // found a match $sql="UPDATE ticket SET solution='".$solution."' WHERE ticket_id='".$ticketid."'"; Can you pls paste the error if any Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131397 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 [quote author=fiddy link=topic=116548.msg474924#msg474924 date=1164690808]Can you pls try like this$query="SELECT * FROM ticket WHERE ticket_id='".$ticketid."'"$res = mysql_query($query);if (mysql_num_rows($res) > 0) { // found a match $sql="UPDATE ticket SET solution='".$solution."' WHERE ticket_id='".$ticketid."'";[/quote]Didn't help still doesnt workKeep the suggestions coming guys I will try anythingI also realize it isnt very secure its for a school project and the thing being graded is the backend database the php front end will get me extra points so I just need it to work and look good.. Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131398 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 [quote author=fiddy link=topic=116548.msg474926#msg474926 date=1164691476]Can you pls paste the error if any[/quote]I dont get any errors returned. Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131399 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 I notice that once I hit the close button that the ticketid in the URL disapears but then it reloads the same closeticket page... Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131400 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 I guess you are not passing the ticketid while clode(submit). Try having a hidden field which has the name as ticketid and value echo in it.<input type="hidden" name="ticketid" value="<?=ticketid?>"> Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131401 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 [quote author=fiddy link=topic=116548.msg474930#msg474930 date=1164692350]I guess you are not passing the ticketid while clode(submit). Try having a hidden field which has the name as ticketid and value echo in it.<input type="hidden" name="ticketid" value="<?=ticketid?>">[/quote]What would this do for me exactly, im confused ? Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131403 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 <?php echo $ticketid; ?> -> Does this displays the ticketid after you submit (clicking the close button)if it does not displays add hidden field like this.So that it will POST you ticket id. <table width="60%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000"><form name="form1" method="post" action="admin_closeticket.php"> <input name="status" type="hidden" id="status" value="0"> <input type="hidden" name="ticketid" value="<?=ticketid?>"> <tr> <td nowrap align="right">Solution:</td> <td height="100"><textarea name="solution" id="solution"></textarea></td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </form> Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131404 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 When I put that code in this happens:before I type in the solution in the text box the ticket ID is displayed because I have this on the page:<?php echo $ticketid; ?>Once I type out the solution and hit close it returns me back to the close ticket page and the ticket id is not in the URL anymore and the code above doesnt display anything.So once I hit close it seems everything is lost.... Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131405 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 can you pls post the code of admin_closeticket.php. I guess this is the page where you are taken when you click the close button Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131408 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 Its the same as above but it has changed alot:<?phpsession_start();include "level2_check.php";include("config.php");$status = $_POST['status'];$solution = $_POST['solution'];if(isset($_POST['Submit'])){ $query="SELECT * FROM ticket WHERE ticket_id='".$ticketid."'"; $res = mysql_query($query); if (mysql_num_rows($res) > 0){ // found a match $sql="UPDATE ticket SET solution='".$solution."' WHERE ticket_id='".$ticketid."'"; $result = mysql_query($sql) or die(mysql_error()); echo "The ticket is now closed good work!";} else{ echo "There was an error trying to close this ticket please try again";}}?><html><head><title>Close Ticket</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="style.css" rel="stylesheet" type="text/css"><?php include ("admin_header.html") ?></head><body><?php echo $ticketid; ?><h3 align="center">Close Ticket</h3><table width="60%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000"><form name="form1" method="post" action="admin_closeticket.php"> <input name="status" type="hidden" id="status" value="0"> <input type="hidden" name="ticketid" value="<?=ticketid?>"> <tr> <td nowrap align="right">Solution:</td> <td height="100"><textarea name="solution" id="solution"></textarea></td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </form></body></html> Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131410 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 if admin_closeticket.php is the same code, it will obviously show the close ticket page only. Please check the DB it its updated. and hope you get the message "The ticket is now closed good work!"Before that please change if(isset($_POST['Submit'])) to if(isset($_POST['submit'])) Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131416 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 still nothing...I changed that piece and I type the solution and hit close and I dont get any of the messages at all and nothing in the DB either.... :-[ Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131419 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 Sorry i cant help more than this from here with out seeing the output or proper files..All the best Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131421 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 Thanks alot for the help it is greatly appreciated.... I will get it soon enough Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131422 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 newest problem with this piece of code:[code]$status = $_POST['status'];$solution = $_POST['solution'];if(isset($_POST['submit'])){ mysql_query ("UPDATE ticket SET status='$status', solution='$solution' WHERE ticket_id='$ticketid'") or die(mysql_error()); echo "The ticket is now closed good work!";} else{ echo "There was an error trying to close this ticket please try again";}?>[/code]When that goes to execute it automaticly puts this on the screen before I even type in the text box and hit submit:There was an error trying to close this ticket please try again Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131435 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 HI i guess you no need else part there, becuse when the page loads for the first time the post values will not be there so the else part is working and you are getting that message Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131441 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 Hi,can you please tell if you get the message "The ticket is now closed good work!"; after clicking the close button. One more in the HTML i dont find the tags for close . Is that located in some other page. Bit confused in this Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131444 Share on other sites More sharing options...
sliperypete Posted November 28, 2006 Author Share Posted November 28, 2006 [quote author=fiddy link=topic=116548.msg474973#msg474973 date=1164699183]Hi,can you please tell if you get the message "The ticket is now closed good work!"; after clicking the close button. One more in the HTML i dont find the tags for close . Is that located in some other page. Bit confused in this[/quote]When I open the admin_closeticket.php page in my web browser it imediatly posts the message:There was an error trying to close this ticket please try again?> Before I even put in a value for solution and hit submit....It looks like it is erroring out before I even hit submit for some reason ...???What do you mean about the html tags for close ? Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131447 Share on other sites More sharing options...
fiddy Posted November 28, 2006 Share Posted November 28, 2006 Posting again my friend:HI i guess you no need else part there, becuse when the page loads for the first time the post values will not be there so the else part is working and you are getting that message. Link to comment https://forums.phpfreaks.com/topic/28703-phpmysql-problem/#findComment-131452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.