Jump to content

BlackKite

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by BlackKite

  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."; ?>
  12. Nah, I want to be able to pull by its ID and put certain ID's in certain spots. However, this still might help. Haha, thanks.
  13. Ok, so basically designing myself a management system for my one site so that its easier for me and the people that help me to upload pages. I've been doing good with it until now. What i'm trying to do is get my navigation links so print themselves in their correct categories. I've been able to call them from SQL and be turned into links, but I can't seem to figure out how to sort them into the categories. In MySQL I have three pages; one, two, and main. One and Two have an ID_CAT of 2 and Main has and ID_CAT of 1. My goal is to list them in order of ID_CAT 1 then 2 on my navigation, but without having to actually state 1 and 2. For example, and if statement of "if ID_CAT = 1 echo". <- thats what I don't want to have to do because I'm trying to make this so that I don't have to go into my actual files ever again, and everything can be done via a nice neat control panel. Here's my navigation code so far. $query = "SELECT * FROM pages"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<a href=\"http://www.neohound.com/sms/ver1/index.php?id=1&url="; echo $row['url']; echo "\">"; echo $row['name']; echo "</a>"; echo "<br />"; } If anyone can be kind enough to at least point me in the right direction, i would greatly appreciate it. Thanks so much! :'( I'm a complete n00b at this SQL stuff, haha.
  14. Free cookies and internets if you can solve my problem. XD
  15. I ask alot of questions... I have another error that i dont understand. Actually... i do but i dont know how to fix it because all this code is starting to confuse me. :-\ Im pretty sure its refering to the temp file becuase I have yet to see it in my file directory, but im not sure becuase if it is creating it then unlink is deleteing it.. right? ??? [b]Error:[/b] [quote]Warning: ftp_fput() [function.ftp-fput]: Rename/move failure: No such file or directory in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52[/quote] [u][b]Line 52:[/b][/u] [code=php:0]ftp_fput($connection, $tempfile, $bandle, FTP_ASCII);[/code] [u][b]My Code:[/b][/u] [code=php:0]<?php         //Check for file existence; $ourFile = $_POST['title']; $filename = "/home/jaboo12/public_html/$ourFile"; if (file_exists("$filename")) {   echo "The file $filename already exists. Please hit the back button and choose a new one";   exit(); } else {   echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>"; }         //If it doesn't exist, login to FTP and chmod; ########################### # ftp settings            # $ftpServer='ftp.neohound.com'; //ftp server, without ftp:// $ftpPort=21;                //the ftp port (don't change if you don't know what it is) $ftpUser='XXXXXX';        //ftp username $ftpPass='XXXXXX';        //ftp password # end ftp settings        # ########################### ########################### # file settings          # $tempfile = '/home/jaboo12/public_html/temp.php'; $ftpdir = 'public_html'; $nav = 'public_html/index.php'; $file = '/home/jaboo12/public_html/$ourFile'; # end file settings      # ########################### //connect to server $connection = ftp_connect($ftpServer, $ftpPort); ftp_login($connection, $ftpUser, $ftpPass); //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $ftpdir); //make temporary file $handle = fopen("$tempfile", 'w'); fclose($handle); //upload file using ftp $bandle = fopen("$file", 'w'); ftp_fput($connection, $tempfile, $bandle, FTP_ASCII); fclose($bandle); //delete temporary file unlink($tempfile); $ourFileName = $_POST['name']; $ourLinkName = $_POST['link'];         //Post content feild to the file created; $myFile = "/home/jaboo12/public_html/$ourFile"; $fh = fopen("$myFile", 'w') or die("can't open file"); $content = $_POST['content']; $help = stripslashes ($content); $newcontent = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>'); fwrite ($fh, $newcontent); fclose($fh); //reset directory permissions ftp_chmod($connection, 0750, $ftpdir);         //Post navigation link on index; //chmod directory so that the server can create a file ftp_chmod($connection, 0777, $nav); $newLink = "<br> ยป <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a> <!-- game -->"; $data = file_get_contents('/home/jaboo12/public_html/index.php'); $data = str_replace ('<!-- game -->', $newLink, $data); $fp = fopen ("/home/jaboo12/public_html/index.php", 'w'); fwrite ($fp, $data); fclose ($fp); //reset directory permissions ftp_chmod($connection, 0644, $nav); //close connection ftp_close($connection);  ?>[/code]
  16. Ugh, im not getting any more help am i?
×
×
  • 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.