ShaolinF Posted February 1, 2008 Share Posted February 1, 2008 Hi Guys, I have a form and a php script which updates the DB when the approapriate fields are filled in. Now before I added javascript it was working fine. Now that I have added JS, the form will submit but the values in the DB will not change. See code below: <form action="update.htm?id=<?php include("rand.htm"); ?>" name="event" method="post"> <select name="menu" onChange="window.location=this.options[this.selectedIndex].value;">; Select Event to Edit: <option value="">-Select Event-</option> <? $count = 0; // Output dropdown list Data //echo "<select name=\"menu\" onChange="window.location=this.options[this.selectedIndex].value;"> "; while ($row = mysql_fetch_assoc($result)) { $count++; echo "<option value=\"".'home.htm?en='.$row['eventName'].'&ts='.$row['TicketsOnSale'].'&sp='.$row['TicketPrice'] ."\">".$count." ".$row['eventName']."</option>" . "\n\t\t"; } echo "</select>"; ?><br /> <label for="eventnm">Event Name:</label> <input type="text" name="eventnm" value="<? echo $_GET['en']; ?>" /><br /> <label for="tickno">Number of tickets on sale:</label> <input type="text" name="tickno" value="<? echo $_GET['ts']; ?>" /><br /> <label for="tickprice">Single ticket price:</label> <input type="text" name="tickprice" value="<? echo $_GET['sp']; ?>" /><br /> <input type="submit" value=" Update >>"/></p> </form> //Add DB so we can use the usernames include('db_connect.php'); $tickp = $_POST['tickprice']; $ticknum = $_POST['tickno']; $eventn = $_POST['eventnm']; $menu = $_POST['menu']; //UPDATE Data $result = mysql_query("UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'"); Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/ Share on other sites More sharing options...
pocobueno1388 Posted February 1, 2008 Share Posted February 1, 2008 Put a die statement on the query. $result = mysql_query("UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/#findComment-454908 Share on other sites More sharing options...
ShaolinF Posted February 1, 2008 Author Share Posted February 1, 2008 Done. It didn't output any errors. Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/#findComment-454911 Share on other sites More sharing options...
pocobueno1388 Posted February 1, 2008 Share Posted February 1, 2008 Okay, try this and make sure the variables are coming out right. <?php $query = "UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'"; $result = mysql_query($query)or die(mysql_error() . "<p>With Query:<br>$query"); echo "<p>$query"; ?> Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/#findComment-454927 Share on other sites More sharing options...
revraz Posted February 1, 2008 Share Posted February 1, 2008 This is the same troubleshooting steps I told you to do earlier when you had the wrong query. You would think you would also apply those steps here. Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/#findComment-454935 Share on other sites More sharing options...
ShaolinF Posted February 1, 2008 Author Share Posted February 1, 2008 Sorry, Im brain dead at the moment. Been on the comp for over a day. Think it is time I get off! Link to comment https://forums.phpfreaks.com/topic/88819-solved-db-not-updating/#findComment-454954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.