opel Posted October 1, 2006 Share Posted October 1, 2006 I have been trying to my update script to post the changes to the Database, but it just is not happening ??? I've read through every book and tutorial I have but can't see where I am going wrong.Could anyone who thinks they can help have a look please. The error I am getting says that I have an undefined index. I have attached the file and update script that I'm using.[b]Update form[/b][code]<?php$id=$_GET['id'];mysql_select_db($dbname, $conn);$query="SELECT * FROM tbl_links, categories WHERE tbl_links.category_id = categories.category_id AND link_id=$id";$result= mysql_query($query) or die("error querying database");$num= mysql_num_rows($result);mysql_close();$i=0;while ($i < $num) {$linkID=mysql_result($result,$i,"link_id");$categoryID=mysql_result($result,$i,"category_id");$linkTitle=mysql_result($result,$i,"link_title");$linkDescription=mysql_result($result,$i,"link_desc");$linkURL=mysql_result($result,$i,"link_url");$linkDisplay=mysql_result($result,$i,"link_display");?><form action="updatescripts/updatelinks.php"><input type="hidden" name="inpID" value="<? echo "$linkID"; ?>"><table cellpadding="5"><tr><th width="120">Field Name</th><th width="378">Field Inputs</th></tr><tr><td width="120"><div align="right"><strong>Category :</strong></div></td><td><select name="inpCat"> <?php mysql_select_db($dbname, $conn);$query_rsLinks = "SELECT * FROM categories ORDER BY category_name ASC";$rsLinks = mysql_query($query_rsLinks, $conn) or die(mysql_error());$row_rsLinks = mysql_fetch_assoc($rsLinks);$totalRows_rsLinks = mysql_num_rows($rsLinks); do { ?> <option value="<?php echo $row_rsLinks['category_id']?>"><?php echo $row_rsLinks['category_name']?></option> <?php} while ($row_rsLinks = mysql_fetch_assoc($rsLinks)); $rows = mysql_num_rows($rsLinks); if($rows > 0) { mysql_data_seek($rsLinks, 0); $row_rsLinks = mysql_fetch_assoc($rsLinks); }include ('../connections/dbclose.php');?></select> </td></tr><tr><td width="120"><div align="right"><strong>Title :</strong></div></td><td><input type="text" name="inpTitle" value="<? echo $linkTitle ?>" class="inputbox" size="72" /></td></tr><tr><td width="120"><div align="right"><strong>Description :</strong></div></td><td><input type="text" name="inpDescription" value="<? echo $linkDescription ?>" class="inputbox" size="72" /></td></tr><tr><td colspan="2"> </td></tr><tr><td width="120"><div align="right"><strong>Link URL <em>('http;//' not required)</em> :</strong></div></td><td><input type="text" name="inpLinkUrl" value="<? echo $linkURL ?>" class="inputbox" size="72" /></td></tr><tr><td colspan="2"> </td></tr><tr><td width="120"><div align="right"><strong>Display Link :</strong></div></td><td><input name="inpDisplay" type="checkbox" value="<? echo $linkDisplay ?>" class="inputbox" checked="CHECKED"/></td></tr><tr><td colspan="2"> </td></tr><tr><td width="120"><div align="right"><strong>Click to submit :</strong></div></td><td><input type="submit" value="Add This Link" name="add" id="add"/></td></tr></table></form><?++$i;} ?>[/code][b]Update Post Script[/b][code]<?include ('../../connections/dbconn.php');$linkID = $_POST['inpID'];$linkTitle = $_POST['inpTitle'];$linkDesc = $_POST['inpDescription'];$linkUrl = $_POST['inpLinkUrl'];$linkCategory = $_POST['inpCat'];$linkDisplay = $_POST['inpDisplay'];$query = "UPDATE tbl_links SET link_title='$linkTitle', link_desc='$linkDesc', link_url='$linkUrl', category_id='$linkCategory', link_display='$linkDisplay' WHERE link_id='$linkID'";mysql_select_db($dbname, $conn) or die( "Unable to select database");mysql_query($query);echo "<p class='message'>You have successfully edited a link, click here to <a href='edit_link.php'>edit another link</a></p>";mysql_close();?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22663-error-updating-info-to-a-database/ Share on other sites More sharing options...
HuggieBear Posted October 1, 2006 Share Posted October 1, 2006 Does it give you a line number? Can you paste the actual error message?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22663-error-updating-info-to-a-database/#findComment-101874 Share on other sites More sharing options...
opel Posted October 1, 2006 Author Share Posted October 1, 2006 I have attached a screen grab and pasted copy of the code. The error appears when I click the submit form and the update script is activated.[code]Notice: Undefined index: inpID in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 4Notice: Undefined index: inpTitle in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 5Notice: Undefined index: inpDescription in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 6Notice: Undefined index: inpLinkUrl in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 7Notice: Undefined index: inpCat in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 8Notice: Undefined index: inpDisplay in /Users/andrewcetnarskyj/Sites/GunkAdmin/central/updatescripts/updatelinks.php on line 9You have successfully edited a link, click here to edit another link[/code][attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/22663-error-updating-info-to-a-database/#findComment-101877 Share on other sites More sharing options...
shivabharat Posted October 1, 2006 Share Posted October 1, 2006 Please refer to this link[url=http://www.phpfreaks.com/forums/index.php/topic,2139.0.html]http://www.phpfreaks.com/forums/index.php/topic,2139.0.html[/url] Quote Link to comment https://forums.phpfreaks.com/topic/22663-error-updating-info-to-a-database/#findComment-101888 Share on other sites More sharing options...
opel Posted October 1, 2006 Author Share Posted October 1, 2006 my problem seems to be that I have not matched a variable to the database set up but I cant see where I have gone wrong? Quote Link to comment https://forums.phpfreaks.com/topic/22663-error-updating-info-to-a-database/#findComment-101994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.