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

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.