Jump to content

iarnazca

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Everything posted by iarnazca

  1. Thanks for the reply. I know what max() does. I was saying that it doesn't do what I want it to and asking for direction on what to use to get what I want.
  2. I want to return the array with the highest value. <?php $vote['john'] = 1 $vote['james'] = 1 $vote['john'] = $vote['john'] + 1 ; $max = max($vote) ; echo " " . $vote['$max'] . " " ; ?> How do I get it to output "john" instead?
  3. firefox crashed without warning when I visited nathanhaze.com
  4. yeah my code would be some "forget everything you've done before" code. You could implement the same things that they are doing. Mines just a Get it working now script I guess. Its all on one page if you just copy and pasted the code and created story.php it should work. The only thing is you need to make sure your calling the correct table when showing the story.
  5. I have kill(); in the script and I ran out of modify time. dont use kill(); use exit();
  6. I didn't protect against sql injection or blank posts.. sorry. =[ there now it has some inject protect and some blank protect
  7. this thread was never solved. I'll try to solve it now. I'm just gonna do a quick script because I cant sleep. I wont look over it too much so if any one see's error correct them please. This code is very similar to the code I use on my site. I assume you have a login you'll need to check that the user is logged in before running this script however your using that. Make the database look like this Name = Comments Fields: (do not include these within name) 1. id (this is primary and auto_inc INT 32) 2. title (VARCHAR 32) 3. msg (LONGTEXT) 4. poster (VARCHAR 32) 5. replyid (INT 32) I have no idea what you want them to be commenting on. I'm going to assume its a story under a different table named "stories" <?php //story.php /* The following is the page where you show the story. This code may be different than yours but the important part is that we find the id from the stories table. I'm also assuming that you've already forwarded to a page showing a specific story using its id and you've put the id in the address bar using a GET form. */ /* we clicked on this link to get us to story.php echo "<a href=story.php?id=$id>Man gets mauled by tiger!</a>"; */ //Just getting information from the address bar $id = $_GET['id']; $action = $_GET['action']; //getting story info $query = "SELECT * FROM stories where id = $id " ; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $row['id']; $title = $row['title']; $body = $row['body']; //printing the story echo "$title<br />"; echo "$body<br />"; echo "Posted by: $poster"; } /*Getting comment info and printing all comments whos replyid is the same as the stories id */ $query = "SELECT * FROM comments where replyid = $id " ; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $commentid = $row['id']; $title = $row['title']; $msg = $row['msg']; $poster = $row['poster']; $replyid = $row['poster']; //Printing the comment echo "$title<br />"; echo "$msg<br />"; echo "<small>Posted by: $poster </small><br /><br />"; } if ($action == 1) { /*here we are inserting a new comment because $action == 1 */ //setting post information in variables $poster = $_POST['poster']; $title = $_POST['title']; $comment = $_POST['comment']; $replyid = $_GET['id']; //here we use the GET id because we want the replyid to be the same as the stories id //allow apostrophes ;] $poster = mysql_real_escape_string($poster); $title = myql_real_escape_string($title); $comment = mysql_real_escape_string($comment); if ($poster == '') { echo "You didn't leave a name!"; kill(); } if ( $title == '' ) { echo "You didn't title your comment!"; kill(); } if ( $comment == '' ) { echo "You left the comment space blank"; kill(); } $query = mysql_query(" INSERT INTO `YOUR_DATABASE_NAME`.`comments` (`id` , `poster` , `title` , `msg`, `replyid` ) VALUES ( NULL , '$poster', '$title', '$comment', '$replyid'; )") or die('Could not insert data because '.mysql_error()) ; echo "Your comment has been posted!"; exit(); //kill the script so the form wont show because they just commented! maybe hinder a little spam } echo "<form action=story.php?action=1&id=$id method=POST>"; echo "Name:<input type=text MAXLENGTH=20 name=poster><br />"; echo "Title:<input type=text MAXLENGTH=20 name=title><br />"; echo "Comment:<br />"; echo "<textarea name=comment rows=10 cols=20>Type your comment here.</textarea><br />"; echo "<input type=submit value=Comment>"; echo "</form>"; ?>
  8. I just edited the post I must have hit previous or next on the bottom right without realizing it.
  9. I just wrote a whole script and it posted in this random thread. Weird. I removed it and am gonna put it in the right place.
  10. iarnazca

    Forum

    no body knows huh? lol time to look at phpbb's code I guess.
  11. iarnazca

    Forum

    no that wont work because all the posts would be 'viewed' when I changed the users date to the forum date. back to square 1.
  12. iarnazca

    Forum

    I'm designing a forum and I want to know how people get the "new posts" to display. usually i'm pretty good at figuring out how to do it but this one is escaping me. It cant be a mysql value on the forum entry's row in the table because that would change for every one as soon as one person viewed it. But I cant imagine that its an entry in the users row because there are SO many posts. maybe a date and time on the user and a date and time updated in the forum entries table? off to code....
  13. it works perfectly now. Thanks gizmola.
  14. okay its fixed what I did was use phpmyadmin to insert into mysql then copied the code it used. I'll post them both here in comarison. Not sure WHY it worked just that it did. I think it was because it defined the database and the table. or declared NULL instead of '', //saders code that helped it return the error. Thanks agains sader. $query = mysql_query("INSERT INTO bugs (id, reporter, title, desc) VALUES ('', '$username', '$title', '$desc')") or die('Could not insert data because '.mysql_error()); //phpmyadmin code that worked for some strange reason. $query = mysql_query(" INSERT INTO `nazca_game`.`bugs` (`id` , `reporter` , `title` , `desc` ) VALUES ( NULL , '$username', '$title', '$desc' )") or die('Could not insert data because '.mysql_error()) ;
  15. thank you sader. I used your line. and now it reports the error. Could not insert data because You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc) VALUES ('', 'nazca', 'test', 'test')' at line 1 Notice how it responded with the variables.
  16. mysql version 5.1.30 this is the query that fails It is mysql_query('INSERT INTO bugs (id, reporter, title, desc) VALUES ('', '$username', '$title', '$desc')') or die('Could not insert data because '.mysql_error()); It does not return an error code. Here is the entire script. <?php session_start(); require_once("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $username = mysql_real_escape_string($_POST['reporter']); // insert the data $title = $_POST['title']; $desc = $_POST['desc']; $query = "mysql_query('INSERT INTO bugs (id, reporter, title, desc) VALUES ('', '$username', '$title', '$desc')') or die('Could not insert data because '.mysql_error())"; echo "Sent..."; ?> I get the "Sent..." output but no error and the info has not been inserted. table structure ************************************** 1. row *********************************** Table: bugs Create Table: CREATE TABLE 'bugs' ( 'id' int(32) NOT NULL AUTO_INCREMENT, 'reporter' varchar(32) COLLATE utf8_unicode_ci NOT NULL, 'title' varchar(32) COLLATE utf8_unicode_ci NOT NULL, 'dec' varchar(32) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY ('id') ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 1 row in set (0.00)
  17. I fairly enjoy the site. I didn't stay very long but only for lack of content not because the site sucked. once more bands are on there i'm sure you can get some people to hang around for a while.
  18. alot has changed and I believe that error has been fixed. I'm running into problems. Being a beginner with not that much time, mysql wont update. I think im gonna need some help.
  19. Right now I'm on a schedule where I get 12 hours off for every 12 hours work. a sweet deal for marines. So yes I do have some time to try and code a little bit see'ing as how I can get a public computer.
  20. Thanks guys. One thing i'd like to state is the way the website looks will be the last thing I smooth out. At least I've planned it that way. Plans change on the fly, right? @corbin I dont know why I didn't auto redirect. I just like to get things working. I consider it to be in the alpha phase right now. when the game runs and you can actually try to achieve a goal, then I will consider it to be in the beta phase and I will smooth out the way EVERYTHING looks. That page could use a little bit of editing. the 2388 is the planet ID of the new planet you have recieved, in its row. I have that in there for my own essay and it will be removed on a later date. @ProjectFear The pages will need to be spiced up. I do agree with that. And I guess i'll have to change up the game screen. Another thing I did was code it while using Firefox to view it. In IE it looks different. Borders. green font. fixed at a later date. I have not written a history for the races. I only have a general concept of what they are in my head. The main thing I know is there will be 3 major races. A militaristic race - Their star fleets have an advantage in combat. A A race that has beautiful attributes. (Sort of derived from elves in most fantasy creations.) They will be good engineers and entrepreneurs. They get a bonus on the recources they gather and money they make. lastly (the race i have so cleverly dubbed humans) will be the average of all things race. they are between the two extremes on each scale. I may not even call them races after this. I may just make them factions of Humans. The images I found on google and are in use until I can get my own photo shopped images. It definately will need a tutorial. I plan on keeping it simple but just the same keeping strategy involved. Cant help that until I get my mind control powers from God. =] (Just kidding) @ILMV I plan on redesigning it completely using css ONCE i get the game mechanics working at least on a beta level. A favicon would be nice. =] @all I am a marine in iraq. I do have little time to edit everything. Thats where my game mechanics takes priority over its good looks comes in. I work hard on it and try to update it at a regular pace, sometimes it just dont work out though. Thanks every one.
  21. The website is www.nazcagame.com It is obviously not finished. i set up a test user username phpfreak Password freaky Using the test user only the first person to use it will get the full effect of my scripts that are running. So, for your own essay, it is better to register. I am also looking for php scripters who are interested in designing a website. I dont care if your a beginner, because so am I. Interested in becoming a dev on this site? Maybe some money making attributes in the future as well. email me iarnazca@gmail.com
×
×
  • 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.