Page 1 of 1

no errors but not updating

Posted: Tue Jun 17, 2003 4:32 am
by irealms
I have the following code and i am not getting any errors but the information it should update is not being updated.

Code: Select all

<?php
<?
if (isset($_SESSION['valid_user']))
{
	echo '<p>Please change the relevant fields below and submit to update the profile for '.$_GET['select'].'</p>';
	$name = $_GET['select'];
	if (isset($_GET['lvledit']))
	{
		echo '<form method="post" action ="index.php?page=charedit">';
		echo 'Level:<input type="text" name="lvlform" value="'.$_GET['lvledit'].'" style="font-size:10px;border:solid 1px;"><br />';
		echo '<input type="submit" value="Update" style="font-size:10px;color:#FFFFFF;background-color:#9A0602;border: 0px;">';
		echo '</form>';
		if (isset($_POST['lvlform']))
		{
			$lvlupdate = "UPDATE characters SET level='$_POST[lvlform]' WHERE charactername='$name'";
			$lvlresult = mysql_query($lvlupdate, $db_conn) or die("query [$lvlupdate] failed: ".mysql_error());
		}
	}
}
?>
?>

Posted: Tue Jun 17, 2003 4:56 am
by cactus
Can you echo out your query ($lvlupdate) to see what values you are passing to it?

May help us debug the code :)

Regards,

Posted: Tue Jun 17, 2003 5:00 am
by irealms
you mean just echo the variable? if so then it shows nothing.

Posted: Tue Jun 17, 2003 6:52 am
by irealms
tried echo'ing the post variable and using the name variable earlier in the page, both show the right values now, but it is still not updating

Posted: Tue Jun 17, 2003 7:05 am
by irealms
i fixed it by having the query in a seperate file and placing a variable in the form action script.

Posted: Tue Jun 17, 2003 7:14 am
by Wayne
sorry about that, serious lack of sleep, lets get this correct

replace

Code: Select all

$lvlupdate = "UPDATE characters SET level='$_POST&#1111;lvlform]' WHERE charactername='$name'";
with

Code: Select all

$lvlupdate = "UPDATE characters SET level='" . $_POST&#1111;'lvlform'] . "' WHERE charactername='$name'";
that should sort it