Twister1004
-
Posts
201 -
Joined
-
Last visited
Posts posted by Twister1004
-
-
Wow O_o, Didn't see that comming. I thought I had fixed that ._. Ok. Its fixed. No errors now, however It still isnt wanting to change the value.
<?php error_reporting(E_ALL); mysql_connect("localhost", "root", "root"); mysql_select_db("fable"); ?> <html> <head> </head> <body> <?php $strength = $_POST['strength']; $magic = $_POST['magic']; $skill = $_POST['skill']; $sql = mysql_query("SELECT `strength`, `magic`, `skill`, `general` FROM `exp` WHERE `ID` = '1'"); $get = mysql_fetch_row($sql); if (!isset($_POST['submit'])){ $replace1 = $strength - $get[0]; $replace2 = $magic - $get[1]; $replace3 = $skill - $get[2]; $update = mysql_query("UPDATE `exp` SET `strength` = $replace1, `magic` = $replace2, `skill` = $replace3 WHERE `ID` = '1' "); } ?> You currently need this much EXP in these stats:<br/> Strength: <?php echo $get[0] ?><br/> Skill: <?php echo $get[2] ?><br/> Magic: <?php echo $get[1] ?><br/> <form method = "POST" action=""> <table> <tr> <td>Strength: </td> <td> <input type ="text" name = "strength" value = "0" id = "strength" /></td> </tr> <tr> <td>Magic: </td> <td><input type ="text" name = "magic" value = "0" id = "magic" /></td> </tr> <tr> <td>Skill:</td> <td><input type ="text" name = "skill" value = "0" id = "skill" /></td> </tr> <tr> <td><input type = "submit" name = "submit" id ="submit" value = "Submit skill stats" /></td> </tr> </table> </form> </body> </html>
-
I would recommend you read the page Crayon Violent wrote.
You will need to know how to do all the MySQL, SQL, and PHP functions with that.
SELECT - Take out out of the database
UPDATE - Update an existing column
ALTER - Change something in the database (Add to or something)
-
Now you will need to get them out of the database and alter them as nessarry.
-
Well First you need to give the a default value of their HP, MP, skill power, and all that junk =)
-
Actually, Gaza, I'm not. xD. Its for a game called Fable. I'm just wanting to make a calculator so I can get the exact about of EXP with out using a RL Calculator.
-
I figured out the hard way, you can't make a game like that if you are new to PHP SQL and MySQL. It will eat you alive! *rawr!*
I would say you need to know how to alter stuff in the database by Update and stuff.
secondly I would go for the train thingy.
thirdly (Lol, I know) I would go for the different kinds of skills.
-
I believe I was correct!
I moved my code around. and I recieved a
Parse error: syntax error, unexpected T_IF in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\fable.php on line 19
This is what I did.
<?php error_reporting(E_ALL); mysql_connect("localhost", "root", "root"); mysql_select_db("fable"); ?> <html> <head> </head> <body> <?php $strength = $_POST['strength']; $magic = $_POST['magic']; $skill = $_POST['skill']; $sql = mysql_query("SELECT `strength`, `magic`, `skill`, `general` FROM `exp` WHERE `ID` = '1'"); $get = mysql_fetch_row($sql) if (isset($_POST['submit'])){ $replace1 = $strength - $get[0]; $replace2 = $magic - $get[1]; $replace3 = $skill - $get[2]; $update = mysql_query("UPDATE `exp` SET `strength` = $replace1, `magic` = $replace2, `skill` = $replace3 WHERE `ID` = '1' "); } ?> You currently need this much EXP in these stats:<br/> Strength: <?php echo $get[0] ?><br/> Skill: <?php echo $get[2] ?><br/> Magic: <?php echo $get[1] ?><br/> <form method = "POST" action=""> <table> <tr> <td>Strength: </td> <td> <input type ="text" name = "strength" value = "0" id = "strength" /></td> </tr> <tr> <td>Magic: </td> <td><input type ="text" name = "magic" value = "0" id = "magic" /></td> </tr> <tr> <td>Skill:</td> <td><input type ="text" name = "skill" value = "0" id = "skill" /></td> </tr> <tr> <td><input type = "submit" name = "submit" id ="submit" value = "Submit skill stats" /></td> </tr> </table> </form> </body> </html>
-
I've tried them both, and Its still not getting anywhere.
Also, Violent, The reason I had it as
if (!isset($_POST['submit']))
Is because I ran into a lot of problems where it would just automatically visit the site it would just post what was on the page already. But if you left the page, it would just come out blank.
I think it might be the IF statement.
-
Its not even echoing. I think it might not be going through the if statement then O_o. Give me a min. Ill try to re write it.
-
Figured out something. No matter what I've been typing in, it will not go into the database at all. It acts like it doesnt do anything.
-
Well, you will have to create a drop down menu in a form and when it is selected, you click on go. and it brings up the articles within that value.
-
Else $CustID = rand(1, 9999999999); $MemStat = JJ; // This is not formed right. //your code : $testID = "SELECT * FROM primary WHERE (CustID) = '$CustID'"; // Correct way : $testID = mysql_query("SELECT * FROM `primary` WHERE [column name] = '$CrustID'"; $testID = mysql_query("SELECT * FROM `primary` WHERE [column name] = '$CrustID'"; $IDresult = mysql_query($testID) or die(mysql_error()); ; If (mysql_num_rows($IDresult)) { die("That Customer ID Already Exhists."); }
You didn't define what you wanted to do with that query.
-
Nothing happend, However, when I did change it to that, the rest of my code after that query went all screwy like. It acted like it was all still in PHP.
What i mean by screwy was the ending with </html> was not highlighed like it was supposed to be.
<?php error_reporting(E_ALL); mysql_connect("localhost", "root", "root"); mysql_select_db("fable"); ?> <html> <head> </head> <body> <?php $strength = $_POST['strength']; $magic = $_POST['magic']; $skill = $_POST['skill']; $sql = mysql_query("SELECT `strength`, `magic`, `skill`, `general` FROM `exp` WHERE `ID` = '1'"); $get = mysql_fetch_row($sql) ?> You currently need this much EXP in these stats:<br/> Strength: <?php echo $get[0] ?><br/> Skill: <?php echo $get[2] ?><br/> Magic: <?php echo $get[1] ?><br/> <form method = "POST" action=""> <table> <tr> <td>Strength: </td> <td> <input type ="text" name = "strength" value = "0" id = "strength" /></td> </tr> <tr> <td>Magic: </td> <td><input type ="text" name = "magic" value = "0" id = "magic" /></td> </tr> <tr> <td>Skill:</td> <td><input type ="text" name = "skill" value = "0" id = "skill" /></td> </tr> <tr> <td><input type = "submit" name = "submit" value = "Submit skill stats" /></td> </tr> </table> <?php if (!isset($_POST['submit'])){ $replace1 = $strength - $get[0]; $replace2 = $magic - $get[1]; $replace3 = $skill - $get[2]; $update = mysql_query("UPDATE `exp` SET `strength` = '.$replace1.', `magic` = '.$replace2.', `skill` = '.$replace3.' WHERE `ID` = '1' "); } ?> </form> </body> </html>
-
Never mind that AGAIN! XD lol. You making it die at one spot even if it is correct or wrong.
$username = $_POST['username']; $password = $_POST['password']; $md5pass = md5($password); $login_check = mysql_query("SELECT * FROM students WHERE `Username` = '$username' AND `Password` = '$md5pass'"); $login_rows = mysql_num_rows($login_check); if($login_rows == 0){ $login_check_t = mysql_query("SELECT * FROM teachers WHERE `Username` = '$username' AND `Password` = '$md5pass'"); $login_rows_t = mysql_num_rows($login_check_t); //This if will always make your page DIE. //Add OR die if($login_rows_t == 0) or die('Login failed</body></html>'); }
I hope this fixes your problem.
-
Hi everyone! Yes, I'm getting more advanced than I was before, and I'm happy. =), I have you all to thank =).
However, I'm here with another problem. This is something I wanted to play around with. I wanted to make a calculator (Somewhat) and I'm using my database to do this.
Objective: I'm trying to make it so that when submit is clicked, it will take the value from the database and subtract it by the number that was entered and the number that was altered back into the database. (Confusing I know, but hey, you're talking to me ).
Ex. Database has a value of 58.
take 58 from the database and subtract it by a variable entered. Lets say 8.
Now take 50 - 8 and make it as another variable.
Now Update the database with the new number.
But I guess I'm kinda stumped.
<?php error_reporting(E_ALL); mysql_connect("localhost", "root", "root"); mysql_select_db("fable"); ?> <html> <head> </head> <body> <?php $strength = $_POST['strength']; $magic = $_POST['magic']; $skill = $_POST['skill']; $sql = mysql_query("SELECT `strength`, `magic`, `skill`, `general` FROM `exp` WHERE `ID` = '1'"); $get = mysql_fetch_row($sql) ?> You currently need this much EXP in these stats:<br/> Strength: <?php echo $get[0] ?><br/> Skill: <?php echo $get[2] ?><br/> Magic: <?php echo $get[1] ?><br/> <form method = "POST" action=""> <table> <tr> <td>Strength: </td> <td> <input type ="text" name = "strength" value = "0" id = "strength" /></td> </tr> <tr> <td>Magic: </td> <td><input type ="text" name = "magic" value = "0" id = "magic" /></td> </tr> <tr> <td>Skill:</td> <td><input type ="text" name = "skill" value = "0" id = "skill" /></td> </tr> <tr> <td><input type = "submit" name = "submit" value = "Submit skill stats" /></td> </tr> </table> <?php if (!isset($_POST['submit'])){ //This isnt finished. It was just as a test. However it doesnt want to work. $replace1 = $strength - $get[0]; $replace2 = $magic - $get[1]; $replace3 = $skill - $get[2]; $update = mysql_query("UPDATE `exp` SET '.$replace1.' = `strength`, '.$replace2.' = `magic`, '.$replace3.' = `skill` WHERE `ID` = '1' "); } ?> </form> </body> </html>
After I wrote this I though, "what if negative was sent into database.... Would it subtract it then?"
Thanks for reading, posting, helping, hinting, etc.
-Twister
-
You need to place session_start(); in every page. If it fixed the error you are getting, then it would be easier to deal with to just put session_start(); in all the pages. (Pain in the butt, I know) but it would cause less problems.
-
Take out the session_start(); in header.php and place it in the index file.
-
Add this to the top of the pages, error_reporting(E_ALL);
-
Ummm from my point of view it seems like the problem is in header.php when you use Session_start();
See if this changes anything.
1. Take out session_start(); from header.php and move it to the VERY top (before <html>) on the index.
2. Add session_start(); to index.php. =)
-
Well, the main problem I see could be the fact the includes are NOT surrounding the file by ().
what i mean is this, (Your code for example)
include("header.php"); echo "<h2>Welcome</h2> <p>Well, i decided that this space earns something better then a white page with links to my other sites, soo here it is! Im not exactly sure how this will turn out, i am also looking for input from others as to what i should put here. Anything is possible!!"; include("footer.php");
-
Thank you mjdamato.
-
Hello everyone! I am fairly new to Javascript, and I obtained this script by w3schools and tweeked it a little to make it a 12 hour clock.
Objective:
1) I can't figure out how to make it list AM or PM by the script. I've tried researching and I really didn't get anywhere.
2) I am trying to make it to where the time is set to the web server's time instead of the users local time. Meaning say if the user lived in EST and the webserver is based on PST, how would i be able to make it show in PST and not EST.
<html> <head> <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); if (h>12){ h=h-12; } if (h == 0){ h=12; } // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=(h+":"+m+":"+s); t=setTimeout('startTime()',500); function checkTime(i) { if (i<10) { i="0" + i; } return i; } } </script> </head> <body onload="startTime()"> <div id="txt"></div> </body> </html>
any help, hints, codes, posting, or reading is appreciated! Thank you!
-
Lol, oooh boy.... Javascript. I normally would go try it out and learn it, but I've got a lot to learn already with 5 different codings =P. Oh well, might as well take a stab at it. Hummmm, Know any really good teachings for javascript? (Besides w3schools)
-
What i mean is make a count down timer from one day(Say like today) til some other day (say like 3 days from now). How would I go about that or is it not possible in PHP?
[SOLVED] A problem in either both MySQL or PHP? =P
in PHP Coding Help
Posted
I fixed the problem. It want the if (!isset($_POST['submit'])){
*however I still believe it fixed part of it?*
It apparently had to do something the math part apparently O_O. Idk what but it did.
*thinks to self positives before negitives this time >=O*
Thanks everyone!
I believe the BIG part was the fact I had it set like this,
Negitive - Positive. Who knows, Thats how it worked for me finally O_o