www.webdeveloper.com
Results 1 to 2 of 2

Thread: MSSQL Error in homemade script

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    MSSQL Error in homemade script

    Hello people,

    Can anyone help me fixing my script error? It's not working somehow. It would be really great if someone can fix it.

    Vote.php (gives the error: ( ! ) SCREAM: Error suppression ignored for
    ( ! ) Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\flyff\vote\vote.php on line 44
    Call Stack
    # Time Memory Function Location
    1 0.0010 689864 {main}( ) ..\vote.php:0)

    Code:
    <?php
    if(isset($_POST['doVote']))
    {
    	
    	include_once("class/class.vote.php");
    	include_once("inc/inc.class_initiate.php");
    	include_once("inc/inc.config.php");
    	
    	$mssqlcon = mssql_connect($mssqlServer, $mssqlUser, $mssqlPass);
    	
    	$eVoteHEAD = "Error!";
    	
    	if($_POST['etCharacter'] && $eVote->checkIP() && $eVote->checkCharacter($_POST['etCharacter']))
    	{
    		
    		$eVote->removeLog($_POST['etCharacter']);
    		
    		$itemSendResult = $eVote->sendItem($_POST['etCharacter']);
    		
    		if($itemSendResult)
    		{
    			
    			$eVoteHEAD = "Link generated!";
    			$eVoteMSG = "Click <a href=\"javascript:etOpenVoteWindow()\">here</a> to open the vote window.<br/>The reward will be sent to you after you voted.<br/>If it doesn't appear however, try relogging.";
    			
    		}
    		else
    			$eVoteMSG = "The character doesn't exist!<br/>Please refresh the browser and try again.";
    		
    	}
    	else
    		$eVoteMSG = "Either you left the character field blank, or you are trying to vote from the same character more than once within 6 hours.<br/>Please refresh the browser and try again.";
    	
    	echo("<p>{$eVoteHEAD}</p>{$eVoteMSG}");
    	
    }
    else
    {
    	
    	include_once("class/class.vote.php");
    	include_once("inc/inc.class_initiate.php");
    	include_once("inc/inc.config.php");
    	
    	$mssqlcon = mssql_connect($mssqlServer, $mssqlUser, $mssqlPass);
    	
    	if($eVote->checkIP())
    	{
    		
    		?>
    		
    		<script type="text/javascript" src="js/jquery.js"></script>
    		<script type="text/javascript" src="js/vote.js"></script>
    		
    		<div id="et_vbutton" onclick="etLiteGetVoteDialog();" style="background-image: url('images/votenow.png'); text-align: center; width: 250px; height: 150px; position: absolute; top: 0px; right: 20px; cursor: pointer;">
    			
    			<div id="et_vcharenter" style="background-color: #F8F8F8; margin: 10px auto; width: 200px; height: 70px; text-align: center; display: none;">
    				
    				Character Name:<br/>
    				<input type="text" id="etCharField"/><br/>
    				<input type="submit" id="etCharSubmit" onclick="etLiteDoVoteDialog();" value="Vote!"/>
    				
    			</div>
    			
    		</div>
    		
    		<?php
    		
    	}
    	
    }
    
    ?>
    inc.config.php

    Code:
    <?php
    
    //The itemName must be the EXACT same name as the item in-game. itemId is the ID of the item, amount is how many they will be getting.
    $voteReward = array("itemName" => "Happy Money", "itemId" => 26419, "itemAmount" => 300);
    
    $mssqlServer = "MICHAEL\FLYFF";
    $mssqlUser = "sa";
    $mssqlPass = "passwordhere";
    $mssqlAccountDBF = "ACCOUNT_DBF";
    $mssqlCharacterDBF = "CHARACTER_01_DBF";
    
    ?>
    inc.class_initiate.php

    Code:
    <?php
    
    $eVote = new ETUNIA_VOTE_LITE();
    
    ?>
    class.vote.php

    Code:
    <?php
    
    
    class ETUNIA_VOTE_LITE
    {
    	
    	private $mssqlExploitArray = array("0x", "DROP", "SELECT", "'", "FROM", "DELETE", "drop", "select", "from", "delete", "--", "#");
    	
    	private function mssql_escape_string( $inputString )
    	{
    		
    		return str_replace($this->mssqlExploitArray, "", $inputString);
    		
    	}
    	
    	public function checkCharacter( $etCharacter )
    	{
    		
    		global $mssqlAccountDBF;
    		
    		$etCharacter = $this->mssql_escape_string($etCharacter);
    		$currentDate = date("mdHi");
    		
    		mssql_select_db($mssqlAccountDBF);
    		
    		$sql_string = "SELECT time FROM VOTE_TBL WHERE character='{$etCharacter}';";
    		$sql_query = mssql_query($sql_string);
    		
    		if(mssql_num_rows($sql_query) == 0)
    			return true;
    		
    		$sql_row = mssql_fetch_row($sql_query);
    		
    		if(($currentDate - $sql_row[0]) < 600)
    			return false;
    		
    		else
    			return true;
    		
    	}
    	
    	public function checkIP()
    	{
    		
    		global $mssqlAccountDBF;
    		
    		$userIP =  $this->mssql_escape_string($_SERVER['REMOTE_ADDR']);
    		$currentDate = date("mdHi");
    		
    		mssql_select_db($mssqlAccountDBF);
    		
    		$sql_string = "SELECT time FROM VOTE_TBL WHERE ip='{$userIP}';";
    		$sql_query = mssql_query($sql_string);
    		
    		if(mssql_num_rows($sql_query) == 0)
    			return true;
    		
    		$sql_row = mssql_fetch_row($sql_query);
    		
    		if(($currentDate - $sql_row[0]) < 600)
    			return false;
    		
    		else
    			return true;
    		
    	}
    	
    	public function removeLog( $etCharacter )
    	{
    		
    		global $mssqlAccountDBF;
    		
    		$userIP =  $this->mssql_escape_string($_SERVER['REMOTE_ADDR']);
    		$etCharacter = $this->mssql_escape_string($etCharacter);
    		
    		mssql_select_db($mssqlAccountDBF);
    		
    		$sql_string = "DELETE FROM VOTE_TBL WHERE ip='{$userIP}';";
    		$sql_query = mssql_query($sql_string);
    		
    		if($sql_query)
    			return true;
    		
    		else
    			return false;
    		
    	}
    	
    	public function sendItem( $etCharacter )
    	{
    		
    		global $mssqlCharacterDBF;
    		
    		global $voteReward;
    		
    		$rewardId = $voteReward['itemId'];
    		$rewardName = $voteReward['itemName'];
    		$rewardAmount = $voteReward['itemAmount'];
    		$etCharacter = $this->mssql_escape_string($etCharacter);
    		
    		mssql_select_db($mssqlCharacterDBF);
    		
    		$sql_string = "SELECT m_idPlayer FROM CHARACTER_TBL WHERE m_szName = '{$etCharacter}';";
    		$sql_query = mssql_query($sql_string);
    		
    		if(mssql_num_rows($sql_query) == 0)
    			return false;
    		
    		$sql_row = mssql_fetch_row($sql_query);
    		
    		$etCharacterId = $sql_row[0];
    		
    		$sql_string = "INSERT INTO ITEM_SEND_TBL([m_idPlayer], [serverindex], [Item_Name], [Item_count], [idSender], [adwItemId0]) VALUES(N'{$etCharacterId}', N'01', N'{$rewardName}', '{$rewardAmount}', N'0000001', '{$rewardId}');";
    		$sql_query = mssql_query($sql_string);
    		
    		if($sql_query)
    		{
    			
    			$this->logPlayer($etCharacter);
    			
    			return true;
    			
    		}
    		
    		else
    			return false;
    		
    	}
    	
    	private function logPlayer( $etCharacter )
    	{
    		
    		global $mssqlAccountDBF;
    		
    		mssql_select_db($mssqlAccountDBF);
    		
    		$currentTime = date("mdHi");
    		
    		$sql_string = "INSERT INTO VOTE_TBL([character], [ip], [time]) VALUES(N'{$etCharacter}', N'{$_SERVER['REMOTE_ADDR']}', N'{$currentTime}');";
    		$sql_query = mssql_query($sql_string);
    		
    	}
    	
    }
    
    ?>

    I'm sure my MSSQL connection details are right.
    Kind regards,

    Michael

  2. #2
    Join Date
    Oct 2012
    Posts
    42
    As far as I can recall the php MSSQL module isn't included by default - have you enabled the appropriate module in php.ini? have a look at http://php.net/manual/en/book.mssql.php.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles