Jump to content

[SOLVED] DB not updating


ShaolinF

Recommended Posts

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

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";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.