Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

[PHP]Script Error


kieranFMT2

Question

Hey Guys i have this error can anyone help me?

Capture.png

Found This today:

 

 


Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:xampphtdocsMetin2Medevilinchead.inc.php on line 14

 

login.php

<div class="content_top"><h2>Login</h2></div>
<div class="content_main">
<div class="con-wrapper">
<?PHP
  if(isset($_POST['submit2'])) 
  {
    if(!empty($_POST['userid2']) && !empty($_POST['userpass2']) && checkAnum($_POST['userid2']) && checkAnum($_POST['userpass2'])) 
    {
      $sqlCmd = "SELECT id,login,coins,web_admin,email 
      FROM account.account 
      WHERE login 
      LIKE '".mysql_real_escape_string($_POST['userid2'])."' 
      AND password=PASSWORD('".mysql_real_escape_string($_POST['userpass2'])."') 
      LIMIT 1";
      $sqlQry = mysql_query($sqlCmd,$sqlServ);
   if(mysql_num_rows($sqlQry)>0) 
 
      {
        $getAdmin = mysql_fetch_object($sqlQry);
        $_SESSION['user_id'] = $getAdmin->id;
        $_SESSION['user_name'] = $getAdmin->login;
        $_SESSION['user_admin'] = $getAdmin->web_admin;
        $_SESSION['user_coins'] = $getAdmin->coins;
        $_SESSION['user_email'] = $getAdmin->email;
        $updateIP = mysql_query("UPDATE account.account SET web_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."' WHERE id='".mysql_real_escape_string($getAdmin->id)."'",$sqlServ);
        
      }
    }
  }
  if(isset($_GET['do']) && $_GET['do']=="aktivieren" && isset($_GET['hash']) && !empty($_GET['hash'])) {
    if(strlen($_GET['hash'])==32 && $_GET['hash']!=1 && checkAnum($_GET['hash'])) {
      $cmdHash = "SELECT id,web_aktiviert FROM account.account WHERE web_aktiviert='".$_GET['hash']."' AND web_aktiviert!='1' LIMIT 1;";
      $qryHash = mysql_query($cmdHash,$sqlServ);
      
      if(mysql_num_rows($qryHash)) {
      
        $getData = mysql_fetch_object($qryHash);
        $userUpdate = "UPDATE account.account SET web_aktiviert='1',status='OK' WHERE id='".$getData->id."' LIMIT 1;";
        $updateQry = mysql_query($userUpdate,$sqlServ);
        
        if($updateQry) {
          echo'<p class="meldung">Your account has been successfully activated . You can log in now .</p>';
          echo'<meta http-equiv="refresh" content="1; URL=index.php?s=login"> ';
        }
        else {
          echo'<p class="meldung">Query failed. Please contact an admin !</p>';
        }
        
      }
      else {
        echo'<p class="meldung">There was no match found . activation Failed.</p>';
      }
      
    }
    else {
      echo'<p class="meldung">No valid hash!</p>';
    }
  }
 
  if(!empty($_SESSION['user_id'])) 
  {
    echo'<div style="float:left;margin-left:30px;">';
    echo'<ul class="menue">';
    if($_SESSION['user_admin']>0) {
      echo'<li><a href="index.php?s=admin">Admin Panel</a></li>';
    }
    if($_SESSION['user_admin']>=0) {
      echo'<li><a href="index.php?s=itemshop">Itemhop</a></li>';
      echo'<li><a href="index.php?s=spenden">Donate</a></li>';
      echo'<li><a href="index.php?s=charaktere">Character</a></li>';
      echo'<li><a href="index.php?s=passwort">Data Editing</a></li>';
    }
    echo'</div>';
    echo'<div style="float:right;margin-right:30px;">';
    
    $cmdStats = "SELECT SUM( player.playtime ) AS ges_spielzeit, COUNT( * ) AS ges_chars, player_index.empire
    FROM player.player
    INNER JOIN player.player_index ON player_index.id = player.account_id
    WHERE player.account_id = '".$_SESSION['user_id']."'
    LIMIT 1";
    
    $qryStats = mysql_query($cmdStats,$sqlServ);
    $getStats = mysql_fetch_object($qryStats);
    
    if(!empty($getStats->empire)) {
      $reich = '<img src="img/reiche/'.$getStats->empire.'.png" title="Reich" alt="Reich"/>';
    }
    else {
      $reich='No Empire Picked';
    }
    
    
    echo'<table>
      <tr>
        <th class="topLine">Account:</th>
        <td class="tdunkel">'.$_SESSION['user_name'].'</td>
      </tr>
      <tr>
        <th class="topLine">Reich:</th>
        <td class="thell">'.$reich.'</td>
      </tr>
      <tr>
        <th class="topLine">Charaktere:</th>
        <td class="tdunkel">'.$getStats->ges_chars.'</td>
      </tr>
      <tr>
        <th class="topLine">Gesamte Spielzeit:</th>
        <td class="thell">'.$getStats->ges_spielzeit.' Minuten</td>
      </tr>';
    $sqlAcc = "SELECT account.social_id AS loeschcode, safebox.password AS lagerpw
    FROM account.account 
    LEFT JOIN player.safebox 
    ON account.id=safebox.account_id 
    WHERE account.id='".$_SESSION['user_id']."'";
 
    $qryAcc = mysql_query($sqlAcc) or die(mysql_error());
    $getAcc = mysql_fetch_object($qryAcc);
    
    if(empty($getAcc->lagerpw)) $getAcc->lagerpw = '000000';
      
      echo'<tr>
        <th class="topLine">Delete Code:</th>
        <td class="tdunkel">'.$getAcc->loeschcode.'</td>
      </tr>
    </table>';
    
    echo'</div><div class="clear"></div>';
  }
  else 
  {
  ?>
<form action="index.php?s=login" method="POST">
  <table>
    <tr>
      <th class="topLine">User ID:</th>
      <td class="tdunkel"><input type="text" name="userid2" maxlength="16" size="20"/></td>
    </tr>
    <tr>
      <th class="topLine">Password:</th>
      <td class="thell"><input type="password" name="userpass2" maxlength="16" size="20"/></td>
    </tr>
    <tr>
      <td class="topLine" style="text-align:center;" colspan="2"><input type="submit" name="submit2" value="login"/></td>
    </tr>
  </table>
  <p><a href="index.php?s=register">Register</a> &bull; <a href="index.php?s=lostpw">Forgot Password?</a></p>
</form>
  <?PHP
  }
  ?>
</div>
</div>

 

<div class="content_footer"></div>  
Edited by kieranFMT2
Link to comment

14 answers to this question

Recommended Posts

  • 0
  • Premium

because you do not ask the simple solution for that which you bought?

#PD: display errors (warnings, news) is lack of seriousness.

#PD2: sorry for my bad english.

regards

  • Love 1

// ¹Ý-_-»ç

Link to comment
  • 0

Hey, looks like some of mysql queries returns no any results.

Try to debug queries.

Show each query with echo, add next lines after $sqlCmd and $cmdHash

echo $sqlCmd;

echo $cmdHash;

And execute them directly in Mysql command prompt.

Link to comment
  • 0

Don't need files :P

As I've told you, some of queries in script doesn't work, the ones which are used in mysql_num_rows function.

To find out which query doesn't work I suggest you to show them with echo command.

Change code to this:

$sqlCmd = "SELECT id,login,coins,web_admin,email

FROM account.account

WHERE login

LIKE '".mysql_real_escape_string($_POST['userid2'])."'

AND password=PASSWORD('".mysql_real_escape_string($_POST['userpass2'])."')

LIMIT 1";

$sqlQry = mysql_query($sqlCmd,$sqlServ);

echo $sqlCmd; //should show the query without variables

and also add echo here:

$cmdHash = "SELECT id,web_aktiviert FROM account.account WHERE web_aktiviert='".$_GET['hash']."' AND web_aktiviert!='1' LIMIT 1;";

echo $cmdHash; //should show the query without variables

Then go in navicat -&gt; account database -&gt; open console, and run in console this queries.

Link to comment
  • 0

Well I have two things to say:

1) If you're using default metin2 account.account database for your script it doesn't has necessary columns (it's only guess from reading the code of login.php)

2) I advice you to know what's mysql query and go ahead with learning ;)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 7

      PHOENIX2 !OLDSCHOOL SERVER, PAYTOWIN REMOVED!

    2. 0

      special_item_group and chest apprentice

    3. 2

      Alternative Alternative Zodiac Suit - Ninja M

    4. 0

      character details negative bonus

    5. 0

      Questlib mysql_query function problem

  • Recently Browsing

    • No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.