Page 1 of 1

Character Issues [resolved]

Posted: Thu Aug 22, 2013 7:44 am
by Epiales
Hey all! :)

I have followed some of the code for the battle information on fighting the creatures. Based upon the theme of my game, I have changed the creatures to characters. I have the same setup in the database for the characters with the same fields. I have went over and over and over, the code for the creatures, and I cannot get it working. Below is my code... any help would be gracious. Driving me nuts it is :evil:

Code: Select all


<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
    echo "You must be logged in to view this page!";
}else{
   
if (isset($_GET['characters']))
{
	$characters=$_GET['characters'];
	$charactersinfo = "SELECT * from characters where name = '$characters'";
	$charactersinfo2 = mysql_query($charactersinfo) or die ("Could not get the character you were fighting!");
	$charactersinfo3 = mysql_fetch_array($charactersinfo2);

} else {

	$charactersinfo = "SECLECT * from characters order by rand() limit 1";
	$charactersinfo2 = mysql_query($charactersinfo) or die ("Could not get a character!");
	$charactersinfo3 = mysql_fetch_array($charactersinfo2);
	
}
   
	$characters = $charactersinfo3['name'];
	$charactershp = $charactersinfo3['hpoints'];
	$charactersattack = $charactersinfo3['attack'];
	$charactersdefense = $charactersinfo3['defense'];
	
	echo $stats['hpoints']; 
	echo $stats['attack']; 
	echo $stats['defense'];
	
	echo "<u> " . $charactersinfo3['name'] . "</u><br>";
	echo "Hit Points = " . $charactershp . "<br>";
	echo "Attack = " . $charactersattack . "<br>";	   
	echo "Defense = " . $charactersdefense . "<br>"; 
	
	echo "<a href='attack.php?characters=$characters'>Attack!";
   
        output("You have visited this page incorrectly!");
    }

include("footer.php");
?>
This is the error code I get:

Code: Select all

	$charactersinfo2 = mysql_query($charactersinfo) or die ("Could not get a character!");
*EDITED* Go figure... After I post here, I see that I have SELECT all spelled SECLECT all LMAO. Oh well. Code might help someone else LMAO. Thanks

Re: Character Issues

Posted: Thu Aug 22, 2013 8:41 am
by Jackolantern
Hehe, glad you got it solved :)

Re: Character Issues [resolved]

Posted: Thu Aug 22, 2013 10:22 am
by Callan S.
I find sometimes I seem to need to post about a problem in order to refresh my perspective and then find the problem myself! heh!

Re: Character Issues [resolved]

Posted: Thu Aug 22, 2013 6:52 pm
by Jackolantern
Callan S. wrote:I find sometimes I seem to need to post about a problem in order to refresh my perspective and then find the problem myself! heh!
Same here! Sometimes just the activity of explaining the problem to someone else helps you organize it in your own mind :)

Re: Character Issues [resolved]

Posted: Fri Aug 23, 2013 12:33 am
by Epiales
Well, I"m not an expert on coding. What I do know is from years ago when I helped write a few social networking scripts... And that learning was through hands on scripting and not by being taught. I have a lot to learn. First time I've even thought about a game script. Thanks for all the help.

Re: Character Issues [resolved]

Posted: Fri Aug 23, 2013 6:32 am
by Jackolantern
Well, I think the best combination is through hands-on programming and something instructional (either an instructor, book or tutorial). With just the instructional material, you will end up just reading or lecturing into oblivion and then have no idea what to do at the keyboard. With nothing but hands-on coding, you will still probably get there, but so much time will be spent flailing and just trying to figure anything out that it isn't practical.

I first started programming on my neighbor's Apple IIe back when the Internet didn't exist yet (yes, I am getting on up there), and help texts were minimal (a function reference book if you were lucky). You essentially just had to try to figure out how to use the syntax by typing and running code over and over until it stopped giving errors (which were useless for debugging). I was finally able to make some slick text-based RPGs with it, but I can only imagine how much further I could have been in that time had I actually had tutorials or books to read while learning. I spent about 8 hours a day trying to code on that thing. By the end of a couple of months, I probably could have been creating graphical games with sound, file access, etc. Luckily I did have a 90% useless programming class in middle school, and because of that other 10%, I at least knew of IF statements, how to show text, the dreaded GOTO statement, and a little bit more. Without at least that simple bit of instruction, I would have been clueless and probably wouldn't have made it as far as I did. But, man, what I could have done had Stack Overflow been around, etc. :P