elite_prodigy Posted December 2, 2008 Share Posted December 2, 2008 Um, you guys can mob me later. Like I said, I have far too many problems with PHP, and I shouldn't! Okay, so no error is being generated, but one of my tables is not being updated. I checked the form names, they are ok, I checked the table names, they seem fine, I checked the code against both and that seems in order. So, here is the table: pgContent -id -topBar -content -pgId And here be the code that creates the form: <?php include 'config.php'; mysql_select_db('exembar_site'); $query = "SELECT * FROM `navigation` WHERE `id`=".$_GET['id']; $result = mysql_query($query); while($info = mysql_fetch_array($result)){ $editing = $info['display']; } $query = "SELECT * FROM `pages` WHERE `id`=".$_GET['id']; $result = mysql_query($query); while($info = mysql_fetch_array($result)){ $title = $info['title']; } $query = "SELECT * FROM `pgContent` WHERE `id`=".$_GET['id']; $result = mysql_query($query); while($info = mysql_fetch_array($result)){ $top = $info['topBar']; $content = $info['content']; } $topbar = "Editing: ".$editing; $body =' <form name="edit" action="php/edit.php?id='.$_GET['id'].'" method="post"> Page Title: <input type="text" name="title" value="'.$title.'" /> <br /> Nav Text: <input type="text" name="display" value="'.$editing.'" /> <br /> Top Bar Text: <input type="text" name="topbar" value="'.$top.'" /> <br /> Page Content:<br /> <textarea rows="30" cols="50" name="content">'.$content.'</textarea><br /> <input type="submit" value="Save" /> </form> '; ?> And here is the code that updates the table: <?php include 'config.php'; mysql_select_db('exembar_site'); $title = $_POST['title']; $display = $_POST['display']; $top = $_POST['topbar']; $content = $_POST['content']; $id = $_GET['id']; $sql = "UPDATE `navigation` SET `display`='{$display}' WHERE id='{$id}'"; mysql_query($sql) or die(mysql_error()); $sql = "UPDATE `pages` SET `title`='{$title}' WHERE `navId`='{$id}'"; mysql_query($sql) or die(mysql_error()); $SQL = "UPDATE `pgContent` SET `topBar`='{$top} `content`='{$content} WHERE `pageId`='{$id}'"; mysql_query($sql) or die(mysql_error()); ?> I can't figure out the problem, though I' sure I've overlooked something. Your help is always appreciated(and I can't say how much). *grovels* -David Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/ Share on other sites More sharing options...
sKunKbad Posted December 2, 2008 Share Posted December 2, 2008 Have you tried running the update directly within mysql or phpMyAdmin to see if it works there? Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703740 Share on other sites More sharing options...
elite_prodigy Posted December 2, 2008 Author Share Posted December 2, 2008 Yes, there are three tables involved with displaying a page: navigation, pages, pgContent. pgContent is the only one that this script fails to update. I can change the table inside phpMyAdmin, but I need to do it from the Site Control Panel(SCP). Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703743 Share on other sites More sharing options...
Psycho Posted December 2, 2008 Share Posted December 2, 2008 Although I see many things I would change, your problem is on line 11 of the 2nd script you posted $id = $_GET['id']; You are POSTing data to that page, not sending it on the URL. Change that to $id = $_POST['id']; and create a hidden field on the form with the ID. I don't think you can POST and GET data at the same time. I would recommend adding an on die() handler to all of your db calls. I typically have the error echo the full query to the page when it fails. In this case you would have seen that the value for the id was empty. Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703747 Share on other sites More sharing options...
elite_prodigy Posted December 2, 2008 Author Share Posted December 2, 2008 I've appended the I'd to the php/edit.php?id= action in the script that generates the form. If that were the case, none of the tables would have changed because I'm relying on that $id variable to select which row I'm editing, the I'd is the primary key to navigation and the pageId and navId to the others, which I should have named the same, but didn't but they are acting as my foreign keys if you will. I need each row in each of the three tables responsible for page generation to reference the other two. It's not my use of $_GET, I thought about this but if that were the case the other two tables would never be updated. But they are, so the problem lies withing all of the code for the third table pgContent, which is not receiving the information from the form. Good idea, but I don't think that's the problem though. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703760 Share on other sites More sharing options...
Psycho Posted December 2, 2008 Share Posted December 2, 2008 OK, sorry. your problem is that you do not have a single quote mark following the topbar or content values. Add the single quote marks in red below: $SQL = "UPDATE `pgContent` SET `topBar`='{$top}' `content`='{$content}' WHERE `pageId`='{$id}'"; Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703769 Share on other sites More sharing options...
elite_prodigy Posted December 2, 2008 Author Share Posted December 2, 2008 I knew it was something stupid. I am doing this on my blackberry, so, the screen size makes it a little hard to notice things, but I do this all the time. And, normally, it continues to happen, I just end up not seeing what is not there. Thanks! (I'll probably be back in about 3 minutes with something else though, God I feel so amature sometimes ) Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703772 Share on other sites More sharing options...
elite_prodigy Posted December 2, 2008 Author Share Posted December 2, 2008 Okay, scratch that, the table is still not updating Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703775 Share on other sites More sharing options...
elite_prodigy Posted December 2, 2008 Author Share Posted December 2, 2008 I'm not sure if this got lost in the shuffle since I prematurely "solved" it. Sorry if you were getting to it, and a moderator may delete this post if they wish. -David Quote Link to comment https://forums.phpfreaks.com/topic/135109-this-is-weird-a-logic-error-perhaps/#findComment-703787 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.