Hello Everyone,

I'm very new to php and MySQL. I have dabled with some code but have any major scripts done for me by a contract programmer who has found full time work and is no longer available to me.

I have a form that should update the database however it doesn't work and I can't figure out why. Any help would be greatly appreciated.

Form on first page looks like this Form on first page looks like this
<form name="form1" method="post" action="updatelink.php">
<input type="text" name="linktext" value="<? echo $row['itemtext'];?>"> <br>
<input name="linkurl" type="text" size="45" maxlength="255" value="<? echo $row['itemurl'];?>"> <br>
<input type="radio" name="opennewwindow" value="Yes" <? if($row['itemnewwindow']) echo "checked"?>> Yes
<input name="opennewwindow" type="radio" value="radiobutton" <? if(!$row['itemnewwindow']) echo "checked"?>>
No <br>
<input type="radio" name="boldlink" value="Yes" <? if($row['itembold']) echo "checked"?>>
Yes
<input name="boldlink" type="radio" value="No" <? if(!$row['itembold']) echo "checked"?>>
No <br>
<input type="hidden" name="item" value="<? echo $_GET['link']; ?>">
<input type="submit" name="Submit" value="Submit">
</form>

Code on second page looks like this

<?
include("common.inc.php");

$itemtext=$POST['linktext'];
$itemurl=$
POST['linkurl'];
if($POST['opennewwindow'] == "Yes") { $newwindow=1; } else { $newwindow=0; }
if($
POST['boldlink'] == "Yes") { $boldlink=1; } else { $boldlink=0; }
$query = "UPDATE ic_leftmenu SET itemtext='".$POST['linktext']."', itemurl='".$itemurl."', itemnewwindow='".$newwindow."', itembold='".$boldlink."'"
." WHERE itemrank=".$
POST['item'];
//echo $query;
$result = @($query);
header("location: managelink.php");
?>

the include("common.inc.php"); is a file that connects to the db

I have absolutely no clue what's wrong. I've tried a few things I've picked up from this forum but nothing works. I don't get an error however the information does not change in the database.
I use phpMy Admin to view the datbase!

Thanks in advance for any help.

    Change the line

    $result = @mysql_query($query);

    to

    $result = mysql_query($query) or die(mysql_error());

    if there's no error, then the SQL statement is valid but no rows are affected. Echo the query string to the screen to see if the vairables have all been set correctly

    hth, njm

      Can't see anything obviously wrong.

      Just for testing, on the second page (I assume it's 'updatelink.php') do the following ...

      Swap what's there at the end already ...

      //echo $query;
      $result = @($query);
      header("location: managelink.php");

      ... with ...

      echo $query;
      //$result = @($query);
      //header("location: managelink.php");

      ... and see what get's printed to the window. Post it back if it doesn't give you any more ideas.

        Thanks, guys!

        It was something really simple that was displayed when I viewed the errors! The itembold field had a spelling error!

          Write a Reply...