Jump to content

Twister1004

Members
  • Posts

    201
  • Joined

  • Last visited

Posts posted by Twister1004

  1. 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

  2. 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>
    

  3. 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)

     

  4. 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.

  5. 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>

  6. 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.

  7. 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.

  8. 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>
    

  9. 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.

  10. 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 :P).

    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 :)

  11. 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");
    

  12. 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!

  13. 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)

×
×
  • 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.