Jump to content

DEVILofDARKNESS

Members
  • Posts

    502
  • Joined

  • Last visited

    Never

Posts posted by DEVILofDARKNESS

  1. First: Please use [ php ] or [ code ] tags.

    Second:  If the balance.php includes a function todo the sql query, you can simply call the function and pass the variable to it

    do_query($memberid);

     

    Although I don't know from where the $memberid is comming..

  2. I have a couple of remarks:

    1. If you insert a invalid username you get a not that beautifull looking page

    2. You show weither the username or the password is wrong, hackers can make easy use of this.

        You should always show: Incorrect username or password

    3. There is nowhere an introduction page that gives you info about the game.

        A user will not sign up quickly if he does not know what the game is about

  3. If you expect that 2.47 billion people will visit your site: No

    you could make this int shorter but it will not affect the speed that much I think

     

    And just because I'm curious: What will idle do?

  4. You will have todo a query like:

    $query = "SELECT * FROM messages WHERE userid='$userid'";
    $res = mysql_query($query);
    while($arr = mysql_fetch_array($res)){
       print $arr['title'] . "\n";
    }

     

    <= will give you a list with all message titles

    is this what you meant?

  5. I have this table(building_lvl):

    lvl | building_id | region_id

    And I want to get the region_id for which building_id=3 has lvl 2 and building_id=2 has lvl 5

     

    Help with Code Tags

    PHP Syntax (Toggle Plain Text)

    SELECT * FROM building_lvl INNER JOIN regions ON regions.region_id = building_lvl.region_id WHERE ((building_lvl.building_id='3') && (building_lvl.lvl > 1)) && ((building_lvl.building_id='2') && (building_lvl.lvl > 4)) && (regions.nation_id = '17');

     

    but this gives an empty set, why?

    (and I'm sure there is a region_id which has this conditions)

  6. some use $_SESSION, some use $_COOKIE

    (I use $_SESSION)

     

    session_start() //has to be the first line of your php code if you need sessions
    $_SESSION['example'] = 'this is an example'; // asigns the string to a session
    print $_SESSION['example']; // prints This is an example
    $example = $_SESSION['example']; //asigns the value of the session to a variable
    

  7. I don't want to go the ajax way because I don't know anything of it,

    so here a last try:

     

    function countdown() {
            	num--;
            	document.getElementById('countdown_ele').innerHTML = num;
            	if(num < 1){
            		clearTimeout(timer);
    			self.location="functions.php?func=updateart";
            	}
          	}

    if($_GET['func']=='updateart'){
    session_start();
    require './checkuserid.php';
    $qry = "SELECT * FROM countdown WHERE (nation_id='$nationid') && (weapbuild='weap')";
    $res = mysql_query($qry);
    $ass = mysql_fetch_assoc($res);
    $qury = "SELECT ammount FROM region_weapons WHERE (weapon_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    $resu = mysql_query($qury);
    if(mysql_num_rows($resu) > 0){
    	$query2 = "UPDATE region_weapons SET ammount = 'ammount + " . $ass['extra'] . "' WHERE (weapon_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    	$res = mysql_query($query2);
    }else{
    	$query3 = "INSERT INTO region_weapons('region_id','weapon_id','ammount') VALUES ('" . $ass['region_id'] . "','" . $ass['wb_id'] . "','" . $ass['extra'] . "')";
    	$res = mysql_query($query3);
    }
    $query4 = "DELETE FROM countdown WHERE (wb_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    $result = mysql_query($query4);
    header('location:./nationoverview.php');
    }

     

    The php is loaded when the timer reaches zero and the script returns to nationoverview because of the header on the last line.  No is there one problem, none of the query's is done:f

  8. I found out, that firebug actually gave me an error:

    updateart is not defined

    functions.php?func=updateart()

    the two brackets: () are not in the javascript but were shown in red by firebug, I can though open functions.php?func=updateart manually...

     

    document.getElementById('countdown_ele').innerHTML = 'FINISHED';
    var head = document.getElementsByTagName('head').item(0);
    var script = document.createElement('script');
    script.setAttribute( 'type', 'text/javascript' );
    script.setAttribute( 'src', './functions.php?func=updateart' );
    head.insertBefore( script, head.firstChild );

     

    So what is the problem?

  9. Okay I solved it without any ajax :P

    I did with javascript:

    document.getElementById('countdown_ele').innerHTML = 'FINISHED';
    			var head = document.getElementsByTagName('head').item(0);
    			var script = document.createElement('script');
    			script.setAttribute( 'type', 'text/javascript' );
    			script.setAttribute( 'src', './functions.php?func=updateart' );
    			head.insertBefore( script, head.firstChild );

     

    I know it calls the functions.php,(saw it in firebug) but somehow it just does the delete query and not the insert or update queries :f what have I done wrong?

     

    if($_GET['func']=='updateart'){
    $qry = "SELECT * FROM countdown WHERE (nation_id='$nationid') && (weapbuild='weap')";
    $res = mysql_query($qry);
    $ass = mysql_fetch_assoc($res);
    $qury = "SELECT ammount FROM region_weapons WHERE (weapon_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    $resu = mysql_query($qury);
    if(mysql_num_rows($resu) > 0){
    	$query2 = "UPDATE region_weapons SET ammount = 'ammount + " . $ass['extra'] . "' WHERE (weapon_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    	$res = mysql_query($query2);
    }else{
    	$query3 = "INSERT INTO region_weapons('region_id','weapon_id','ammount') VALUES ('" . $ass['region_id'] . "','" . $ass['wb_id'] . "','" . $ass['extra'] . "')";
    	$res = mysql_query($query3);
    }
    $query4 = "DELETE FROM countdown WHERE (wb_id='" . $ass['wb_id'] . "') && (region_id='" . $ass['region_id'] . "')";
    $result = mysql_query($query4);
    }

  10. Okay I have this piece of code:

    <script type="text/javascript">
    	num = <?= $ned; ?>
    	var timer;
    	function countdown() {
            	num--;
            	document.getElementById('countdown_ele').innerHTML = num;
            	if(num < 1){
            		clearTimeout(timer);
    			document.getElementById('countdown_ele').innerHTML = 'FINISHED';
    			<?= update(); ?>
            	}
          	}
    	function init() {
            	document.getElementById('countdown_ele').innerHTML = num;
            	timer = setInterval("countdown()",1000);
          	}
    </script>

     

    The js accepts the $ned that is given by php, but does not start the function update();  Is this because js can only accept vars/strings/... from php but not execute a function.?

     

    Or is there an other way that I can solve this?

     

    P.S.: this is a piece of a php script.

  11. For the deleting:

     

    You should add a button on which people can click and if they click you just have to send the post_id with $_POST.

    THen you need to do a query which deletes the actual post.

    $query = "DELETE FROM messages WHERE post_id = '$postid'"
    $result = mysql_query($query)
    

  12. first script:

    //$serial is the output of the form
    $query = "SELECT serial_id FROM serials WHERE serial_key = '$serial'"
    $result = mysql_query($query)
    if(num_rows($result)<0){
    echo "WRONG!"
    }else{
    //actions if you typ the right serial
    }

     

    second script:  Use the mail function

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