Raised This Month: $ Target: $400
 0% 

help with sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 08-24-2009 , 16:19   help with sql
Reply With Quote #1

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 is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 08-25-2009 , 13:33   Re: help with sql
Reply With Quote #2

arkshine, joa, anybody?
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-25-2009 , 13:54   Re: help with sql
Reply With Quote #3

Quote:
Originally Posted by tuty View Post
arkshine, joa, anybody?
You should know not to bump your thread until 2 weeks have passed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 08-25-2009 , 14:54   Re: help with sql
Reply With Quote #4

Quote:
Originally Posted by Exolent[jNr] View Post
You should know not to bump your thread until 2 weeks have passed.

yes, but i cant wait two weeks :/
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 14:57   Re: help with sql
Reply With Quote #5

Quote:
Originally Posted by tuty View Post
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.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 13:40   Re: help with sql
Reply With Quote #6

Post the code that you are sending to the SQL console.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 08-25-2009 , 13:52   Re: help with sql
Reply With Quote #7

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>
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-25-2009 , 14:48   Re: help with sql
Reply With Quote #8

Quote:
Originally Posted by crazyeffect View Post
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.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 08-26-2009 , 11:05   Re: help with sql
Reply With Quote #9

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
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 08-26-2009 at 11:12.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 08-26-2009 , 11:56   Re: help with sql
Reply With Quote #10

Quote:
Originally Posted by |PJ| Shorty View Post
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).
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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