no errors but not updating

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

no errors but not updating

Post 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());
		}
	}
}
?>
?>
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post 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,
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

you mean just echo the variable? if so then it shows nothing.
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post 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
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post by irealms »

i fixed it by having the query in a seperate file and placing a variable in the form action script.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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
Post Reply