Jump to content

BlackKite

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BlackKite's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ah hah, it works! Thank you all for the help. Ended up learning a lot from this thing.
  2. Woo! It's working, oddly, but its working. I had a few more syntax errors and my loop was a little off but I managed to sort it out. I have one more question though. I'm inserting in a new `order` with a value of 3. Therefore it should be updating the old 3 to 4, 4 to 5, and 5 to 6. However, its decided now that it's going to update the old 3 to 8, and therefore 4 to 9 and 5 to 10. Any ideas? <?php include("../include/session.php"); if($session->logged_in){ $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; $order = $navi + 1; $Update = ">=$order"; $query = "SELECT `order` FROM `pages`"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ mysql_query("UPDATE `pages` SET `order`= (`order`+ 1) WHERE `order` $Update") or die(mysql_error()); } mysql_query("INSERT INTO `pages` (`name`, `ID_CAT`, `order`, `body`) VALUES('$name', '$ID_CAT', '$order', '$body')") or die(mysql_error()); echo "Your page has been successfully uploaded into the database and will now appear on the site."; } ?>
  3. Hm, I ran into another problem. It's now throwing a syntax error at the INSERT INTO area. Not sure what is wrong with my syntax, looks fine to me, but you all know better than I do. Current Code: <?php include("../include/session.php"); if($session->logged_in){ $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; $order = $navi + 1; $Update = ">=$ID_MAIN"; $query = "SELECT * FROM `pages`"; mysql_query($query) or die(mysql_error()); while ( `order` >=$order ) { mysql_query("UPDATE `pages` SET `order`= (order+1) WHERE `order` $Update") or die(mysql_error()); } mysql_query("INSERT INTO `pages` (name, ID_CAT, order, body) VALUES(`$name`, `$ID_CAT`, `$order`, `$body`) ") or die(mysql_error()); echo "Your page has been successfully uploaded into the database and will now appear on the site."; } ?> Error: Please and thanks. :-\
  4. Hm, your right, I probably don't have as much of a grasp on this as I should. Let me just clarify what exactly I'm doing though, and why I am thinking the way I am. I'm making a content management system. This part here is whats creating the new entries in the database to be called as pages on the site. The part I'm having trouble with is the part that is used in creating the navigation list. I'm using ID_MAIN to call upon and also order the list. Being that it has to be in a stated order and it is a list where the user defines the placement of the new link, that is why I need to be able to insert a number into a specific place. Does that make it more clear as to what I'm doing now? Hopefully.
  5. Yeah but I do want it to loop then. That code wouldn't work for what I'm doing because I want the new entry to be inserted in a specific spot, IE between 2 and 3. That would just add it to the end and make an entry of ID 6. Correct me if I'm misunderstanding something. ???
  6. Well, that worked, but only to a point. It was ok with the fact I was adding a new number 2, but threw a fit when trying to make 2 into 3, because there was also already a number 3. If that makes sense? Also, the field is set to auto_increment. I had that from the start, but it was throwing a duplicate entry error, so thats why I came up with all this crap.
  7. :-\ Still received the same duplicate entry error.
  8. Thanks but it didn't work, I got a duplicate entry error. The +1 is "add one" because I'm trying to add 1 to every number after the number I'm updating so I don't get that duplicate entry error.
  9. Hi, I have a database with a table 'pages' in it. Inside pages is the row 'ID_MAIN'. It's got 5 entries in it with values of 1 to 5. I want to create a new entry in between entry 2 and 3 with a value of 3, there by updating 3 to 4 and so on. This is the script I came up with, however I'm completely new with this and... well it didn't work. And info as to how to correct this would be greatly welcomed. Script: $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; $ID_MAIN = $navi + 1; $Update = ">=$ID_MAIN"; mysql_query("UPDATE 'pages' SET 'ID_MAIN'='+1' WHERE 'ID_MAIN'='$Update'") or die(mysql_error()); mysql_query("INSERT INTO pages (name, ID_CAT, ID_MAIN, body) VALUES('$name', '$ID_CAT', '$ID_MAIN', '$body' ) ") or die(mysql_error()); Error:
  10. Oop... now I feel stupid. I've been trying to figure out what the heck was wrong for about 20min now. Haha, thanks.
  11. Not exactly sure why this isn't working. It seems to be having a problem with me closing out the php? Anyone have any idea what's going on? <?php include("../include/session.php"); if($session->logged_in){ $name = $_GET['name']; $ID_CAT = $_GET['ID_CAT']; $navi = $_GET['navi']; $body = $_GET['body']; $ID_MAIN = $navi + 1; mysql_query("INSERT INTO pages (name, ID_CAT, ID_MAIN, body) VALUES('$name', '$ID_CAT', '$ID_MAIN', '$body' ) ") or die(mysql_error()); echo "Your page has been successfully uploaded into the database and will now appear on the site."; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.