AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with sql (https://forums.alliedmods.net/showthread.php?t=101512)

tuty 08-24-2009 16:19

help with sql
 
Guys, im tryin' to repair that bug from my drshop, but im stucked in sql.
In my drshop, names are repeated and it just floods the database.
I need to repair this. :|. I need to check if player already exists in my db, and return 0, and update only points :)

see bug here http://revo.theupstream.com/DeathrunShop.php

tuty 08-25-2009 13:33

Re: help with sql
 
arkshine, joa, anybody?

ot_207 08-25-2009 13:40

Re: help with sql
 
Post the code that you are sending to the SQL console.

crazyeffect 08-25-2009 13:52

Re: help with sql
 
PHP Code:

<head>
<center>
<body bgcolor="#666666"><font face="Verdana">
<title>Deathrun Shop Stats v3.1.1</title>
<link rel="shortcut icon" href="http://www.crazyeffect.net/tutyX/favicon.ico">
</head>

<?php
    
echo "<div class='center'><img src='http://www.crazyeffect.net/tutyX/drmanager.gif'></div>";

    
$dbUsername "";
    
$dbPassword "";
    
$db "";
    
    
mysql_connect(localhost$dbUsername$dbPassword);
    
mysql_select_db($db) or die("[DrShop] An error has occured!");
    
    
$result mysql_query("SELECT * FROM DeathrunShop_sql");
    
$rcount mysql_num_rows($result);
    
    echo 
"<br><table border='1' cellspacing='0' width='90%' style='text-align: center;'><tr><th>Name</th><th>SteamID</th><th>Shop Points</th></tr>";

    for(
$i=0$i<$rcount$i++)
    {
        
$resultName mysql_result($result$i"name");
        
$resultSteamID mysql_result($result$i"steamid");
        
$resultPoints mysql_result($result$i"points");
        
    
        echo 
"<tr><td><u>$resultName</u></td><td>$resultSteamID</td><td><b>$resultPoints</b></td></tr>";
    }

    echo 
"</table>";
    echo 
"<br><br><br>Deathrun Shop v3.1.1 by tuty (c)";

?>

</center>
</body>
</font>


Exolent[jNr] 08-25-2009 13:54

Re: help with sql
 
Quote:

Originally Posted by tuty (Post 912641)
arkshine, joa, anybody?

You should know not to bump your thread until 2 weeks have passed.

ot_207 08-25-2009 14:48

Re: help with sql
 
Quote:

Originally Posted by crazyeffect (Post 912671)
PHP Code:

<head>
<center>
<body bgcolor="#666666"><font face="Verdana">
<title>Deathrun Shop Stats v3.1.1</title>
<link rel="shortcut icon" href="http://www.crazyeffect.net/tutyX/favicon.ico">
</head>

<?php
    
echo "<div class='center'><img src='http://www.crazyeffect.net/tutyX/drmanager.gif'></div>";

    
$dbUsername "";
    
$dbPassword "";
    
$db "";
    
    
mysql_connect(localhost$dbUsername$dbPassword);
    
mysql_select_db($db) or die("[DrShop] An error has occured!");
    
    
$result mysql_query("SELECT * FROM DeathrunShop_sql");
    
$rcount mysql_num_rows($result);
    
    echo 
"<br><table border='1' cellspacing='0' width='90%' style='text-align: center;'><tr><th>Name</th><th>SteamID</th><th>Shop Points</th></tr>";

    for(
$i=0$i<$rcount$i++)
    {
        
$resultName mysql_result($result$i"name");
        
$resultSteamID mysql_result($result$i"steamid");
        
$resultPoints mysql_result($result$i"points");
        
    
        echo 
"<tr><td><u>$resultName</u></td><td>$resultSteamID</td><td><b>$resultPoints</b></td></tr>";
    }

    echo 
"</table>";
    echo 
"<br><br><br>Deathrun Shop v3.1.1 by tuty (c)";

?>

</center>
</body>
</font>



This looks fine. I think that the plugin has problems.

tuty 08-25-2009 14:54

Re: help with sql
 
Quote:

Originally Posted by Exolent[jNr] (Post 912675)
You should know not to bump your thread until 2 weeks have passed.


yes, but i cant wait two weeks :/

ot_207 08-25-2009 14:57

Re: help with sql
 
Quote:

Originally Posted by tuty (Post 912742)
yes, but i cant wait two weeks :/

There is no need to be desperate. Show the code in your plugin that sends the data in the mysql database. Delete the private information.

|PJ| Shorty 08-26-2009 11:05

Re: help with sql
 
if you are using mysql server >= v4.1 you can do this with one query.
example how i do in my plugins:

create a table with an unique field "name":
Code:

CREATE TABLE `something` (`name` VARCHAR(32), `points` INT NOT NULL, PRIMARY KEY(`name`))
insert a name or if it exists update only the points:
Code:


INSERT INTO `something` (`name`,`points`) VALUES ('player',10) ON DUPLICATE KEY UPDATE `points`=100

run the insert query twice and you will see, first the player is inserted with 10 points and second the points will be set to 100

Xanimos 08-26-2009 11:56

Re: help with sql
 
Quote:

Originally Posted by |PJ| Shorty (Post 913527)
if you are using mysql server >= v4.1 you can do this with one query.
example how i do in my plugins:

create a table with an unique field "name":
Code:

CREATE TABLE `something` (`name` VARCHAR(32),`SteamID` VARCHAR(34), `points` INT NOT NULL, PRIMARY KEY(`SteamID`))
insert a name or if it exists update only the points:
Code:


INSERT INTO `something` (`name`,`SteamID`,`points`) VALUES ('player','STEAM_x:x:xxxxxx',10) ON DUPLICATE KEY UPDATE `points`=100,`name`='player'

run the insert query twice and you will see, first the player is inserted with 10 points and second the points will be set to 100

*fixt
Have it check on steamid and update name based on that. (names can be repeated between players, steamids can't).


All times are GMT -4. The time now is 15:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.