Jump to content

Search the Community

Showing results for tags 'sql'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Found 16 results

  1. The title says it all. We're on a 317, that's really in need of someone who does mySQL and all that stuff, Contact us through forums or in game, [URL="http://www.rs3server.org/forum"]www.rs3server.org/forum [/URL] Thanks - X
  2. Got bored and wrote a very secure callback for RuneLocus. Probably a little too secure, but hey, cant ever be secure enough nowadays... If your host supports remote sql, you will need to allow the remote connection via cPanel using the Remote SQL option. You just input your VPS ip. If it does not support remote SQL, such as a free webhost, then gf. First things first, make sure you have a database with a username and password set. If you already have one you want to use, then good deal. Move on to next step: Create a new PHP file and put this in it: <?php define("db_host", "localhost"); // typically localhost unless your database is off-site define("db_user", ""); // database username define("db_pass", ""); // database password define("db_name", ""); // name of the database define("db_tabl", ""); // the name of the table define("runelocus_ip", ""); // IP to runelocus, to prevent injections // here we check if the variable "usr" is set in the url like so: ?usr=someName if (!isset($_GET['usr']) || empty($_GET['usr']) || !is_string($_GET['usr']) && !is_numeric($_GET['usr'])) { echo 'NOPE'; exit; } // then we check the ip address of who is visiting the page. If its not runelocus, NOPE if (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != runelocus_ip) { echo 'NOPE'; exit; } // we then filter the name to prevent non alphanumerical characters $name = cleanString($_GET['usr']); // after that, we make a conection to the database $con = new mysqli(db_host, db_user, db_pass, db_name) or die ($con->$error); // we now query the database to see if the user has any votes $res1 = $con->query("SELECT * FROM ".db_tabl." WHERE username='".$name."'"); // if they do, we check scan thru all the user's votes and see if the last votes was less then 12 hours ago. // if so, the vote is denied. if ($res1) { while ($data = $res1->fetch_assoc()) { $time = $data['timeVoted']; if (time() - $time < 43200) { echo ''.(43200 - (time() - $time)).' seconds remaining until next vote allowed'; exit; } } } // We fetch the IP on the user and store it in a variable $ipAddr = $_SERVER['REMOTE_ADDR']; // then insert the username, claim status (0 to denote it as not being claimed) $res = $con->query("INSERT INTO ".db_tabl." (username, claimed, timeVoted, ipAddr) VALUES ('".$name."', '0', '".time()."', '".$ipAddr."')"); // if connected and inserted, we print Success... if ($con && $res) { echo 'Successfully inserted vote entry for '.$name.''; } else { echo 'Failed inserting vote entry for '.$name.''; } ?>[/CODE] I've provided a few notes in there to show each thing as it's process and what it does. Upload the script to your website's root folder (some hosts use htdocs, wwwroot, or inetpub, depending on the web-server they use) Now that we have a callback, goto RuneLocus and edit the callback url for your server to match your website url and the path you uploaded it to. New votes should be inserted in the database, if not you didnt insert something correctly or you're possibly using wrong version of PHP. This script was written using Php 5.3. SERVER SIDE WOOOOOT First, make a new class called "Database.java" and put it in any desired package. Just remember it cause we'll need it later, and make put this in it: [code] package com.rs.game.mysql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Database { private Connection conn; private Statement stmt; private String host = ""; private String user = ""; private String pass = ""; private String database = ""; public Database(String host, String user, String pass, String data) { this.host = host; this.user = user; this.pass = pass; this.database = data; } public boolean init() { try { this.conn = DriverManager.getConnection("jdbc:mysql://"+host+":3306/"+database, user, pass); return true; } catch (SQLException e) { e.printStackTrace(); return false; } } public int executeUpdate(String query) { try { this.stmt = this.conn.createStatement(1005, 1008); int results = stmt.executeUpdate(query); return results; } catch (SQLException ex) { ex.printStackTrace(); } return -1; } public ResultSet executeQuery(String query) { try { this.stmt = this.conn.createStatement(1005, 1008); ResultSet results = stmt.executeQuery(query); return results; } catch (SQLException ex) { ex.printStackTrace(); } return null; } public void destroyAll() { try { conn.close(); stmt.close(); conn = null; stmt = null; } catch(Exception e) { e.printStackTrace(); } } } Next, make a new class called "Vote.java" and put this in it: package com.rs.game.mysql.impl; import java.sql.ResultSet; import com.rs.game.mysql.Database; import com.rs.game.player.Player; import com.rs.utils.Utils; public class Vote implements Runnable { private static final String databaseTable = "voters"; // change this to your database table private Player player; public Vote(Player player) { this.player = player; } [MENTION=15855]Over[/MENTION]ride public void run() { try { // edit this Database db = new Database("localhost", "db_user", "db_pass", "db_name"); if (!db.init()) { System.err.println("[MySQL] Failed connecting to database."); return; } String username = Utils.formatPlayerNameForDisplay(player.getUsername()); // only pulling one result at a time where they have not claimed. ResultSet rs = db.executeQuery("SELECT * FROM "+databaseTable+" WHERE username='"+username+"' AND claimed=0 LIMIT 1"); if (rs.next()) { int rowId = rs.getInt("id"); int timeVoted = rs.getInt("timeVoted"); int epochTime = (int) (Utils.currentTimeMillis() / 1000); if (epochTime - timeVoted < 43200) { // if the vote was less than 12 hours ago, give reward. if not, make em do it again :I // your rewards go here. // updates the current row to show it's been claimed int results = db.executeUpdate("UPDATE "+databaseTable+" SET claimed=1 WHERE id="+rowId+""); System.out.println("[MySQL] Updated "+results+" database rows"); db.destroyAll(); // destroy connections return; } } db.destroyAll(); // destroy connections } catch (Exception e) { e.printStackTrace(); } } } so now if you've done this correctly, you should have a fairly decent auto vote system and stuff, hopefully. Hopefully i also didnt mess up cause i havent tested server-side, but i have indeed tested website and it works fine :P How to use: new Thread(new Vote(player)).start(); I've made this work on a seperate thread so it doesnt interfere with the main thread of the game. Database structure: CREATE TABLE IF NOT EXISTS `voters` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `claimed` tinyint(1) NOT NULL, `timeVoted` bigint(15) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;[/CODE] To add a runelocus vote form your your website, it's super easy. Just simply add this to your template wherever you wish: [CODE]<form action="http://www.runelocus.com/toplist/index.php" method="GET"> <input type="hidden" name="action" value="vote"> <input type="hidden" name="id" value="38552"> <!--YOUR RUNELOCUS VOTE ID, THIS CAN BE FOUND IN THE VOTING URL --> <input type="text" name="id2" placeholder="Server username" required> <button type="submit">Vote Now</button> </form>[/CODE] And there you have it, pretty sure I've included EVERYTHING for this..but if not just post a reply :P
  3. Googlez

    Rsps php + sql

    I want to have the RSPS Server send a request to my http server that has a php script that will tell it ti or not to shutdown, depending on a db query. I need this for a hosting site i am creating, thanks for the help! This can just be a tutorial, actually i would prefer it to be!
  4. I am on 718 and i want to use this source but it has a sql database and i have commented out most of it but there's 3 i cannot do as you see when you open up compile it tells you. If you can help me then add me on skype. Skype: InsideProjectPS3
  5. The following tutorial teaches you how to perform basic communication tasks to and from a server using the Structured Query Language (SQL) from either your java application, rsps server, or website. Some things this might be useful for: displaying number of players online on your website, sending important player data to an sql server for safe keeping, updating player's ranks on your forum from your server, and even a start to creating your own vote, highscores, or donation system. Pre-Requisites to Reading this thread: [LIST] [*]Know how to create an SQL database on your website or computer. [*]Know how to add a new table to your database along with adding columns to that table. [*][URL="http://echopx.com/how-to/create-mysql-database-in-cpanel"]Here's a link[/URL] incase you don't know how to do either of those. [/LIST] The two languages we'll be working with today are Java and PHP. Both have internal libraries that handle the execution of SQL related processes. [SIZE=4][U][B]PHP Section:[/B][/U][/SIZE] As said above, php offers SQL libraries to help communicate with your chosen database. This is very commonly used for systems such as forums, blogs, keeping user information, ect. [B]Sending Information using PHP: [/B][INDENT]In the below example, we create a php variable named con and apply an sql connection to it using the mysql_connect method provided by PHP. The parameters for this function is (connection IP address, the database username, the database password), which are all strings. Most leave the connection IP as localhost since their database is located on the same server as what they're running the script off of, but some might change it to a different IP depending if their database is external or not. [/INDENT] [code]<?php $con = mysql_connect("localhost", "DATABASE_USERNAME", "DATABASE_PASSWORD"); if (!$con) { die("Could not connect to database: " . mysql_error()); } mysql_select_db("DATABASE_NAME", $con); mysql_query("INSERT INTO people (name, age) VALUES ('Tommy ', 33)"); mysql_close($con); ?> [/code][INDENT]After applying the connection, we check to see if everything is alright. If the connection contains errors, we simply call the die() method, which in other terms 'exists'. By calling the mysql_error() method when calling an exit to the page, we can grab whatever the error was in the connection. Usually, it's because you didn't type the username or password correctly, so make sure all your credientials are correct! Next, we select a database to use from our server. The method mysql_select_db(your database name, the connection variable) selects the chosen database. If all went well, you're 100% connected to your database using SQL. Next, let's say you want to add something to your table in your database. The mysql_query function can be used for many different edits to your database, like editing, retrieving, adding, deleting, ect, but for this tutorial, we're going to cover just inserting and retrieving. [/INDENT] [code] mysql_query("INSERT INTO people (name, age) VALUES ('Tommy ', 33)"); [/code][INDENT]The above code is basic syntax for inserting information into your database table. INSERT INTO is followed by your table name inside your database. Keep in mind that everything is case sensitive. Following your table name is a parameter container for the columns that your table owns. In this example, my table 'people' has 2 columns, which are name and age. The name in my database is a varchar and the age is an integer. Followed by the column names is the keyword VALUES, then a container for the values. Also keep in mind that the values are in order the same as (name, age). Finally, we call mysql_close to exit the connection (although it's not really needed for this small of a script, since the connection automatically ends at the end of a script). [/INDENT] [B]Recieving Information using PHP:[/B] [code]<?php $con = mysql_connect("localhost", "DATABASE_USERNAME", "DATABASE_PASSWORD"); if ([SIZE=2]!$con) { die("Could not connect to database: " . mysql_error()); } [FONT=arial]mysql_select_db("DATABASE_NAME", $con); $data = mysql_query("SELECT * FROM people") or die(mysql_error());[/FONT][/SIZE][FONT=arial] [/FONT] while ($person = mysql_fetch_array($data)) { echo $person['name']; echo $person['age']; } mysql_close($con); ?> [/code][INDENT]The above code connects to the database just like before, but this time we're using the mysql_query in a different way. Following the SELECT keyword, we put a * to indicate grab all. This is then followed by the FROM keyword, then the name of our table. What this does is select all the rows from our table called 'people'. The variable $data now holds all the rows listed in our table (if any). Next, we loop through our data using the mysql_fetch_array($data) method. While inside the loop, we can obtain certain columns from each row recieved. For example, if you just wanted to get the persons age from the row, you would take the iterated variable, which is $person followed by ['column name']; You might be wondering, well what if I don't want to get all the rows, what if I want to search for someone's name? [/INDENT] [code] $data = mysql_query("SELECT * FROM people WHERE name='George'") or die (mysql_error()); [/code][INDENT]Using the above query will select all rows from the table where the column name is equal to "George". It could potentially return n results depending on how many "George" there are in the table. [/INDENT] [SIZE=4][U][B]Java Section: [/B][/U][/SIZE][INDENT]As stated before, Java also contains a set of useful utilities for sending and recieving information to a database using SQL. Below is an example of a Java class that uses SQL functions. [/INDENT] [code] import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class SQL { private static Connection con = null; private static Statement stmt; public static void createConnection() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); String IP="WEB HOST IP"; String DB="DATABASE NAME"; String User="DATABASE USERNAME"; String Pass="DATABASE PASSWORD"; con = DriverManager.getConnection("jdbc:mysql://"+IP+"/"+DB, User, Pass); stmt = con.createStatement(); } catch (Exception e) { e.printStackTrace(); } } public static void process() { createConnection(); ResultSet results = statement.executeQuery("SELECT * FROM people WHERE name='George'"); while(results.next()) { String name = results.get("name"); } statement.executeQuery("DELETE FROM `people` WHERE name='GEORGE'"); destroyConnection(); } private static void destroyConnection() { try { stmt.close(); con.close(); } catch (Exception e) {} } } [/code][INDENT]The above code is very similiar to what I showed you in the PHP section, there's essentially just different names for the functions. Executing a query, as you can see, uses the same concepts from the PHP section. Since they're almost the same, I'm going to let you explore the functions Java has to offer. If you use an IDE (such as eclipse), you can view all the functions in the sql package. Mostly all of them that I know of are well documented on the [URL="http://docs.oracle.com/javase/6/docs/api/java/sql/package-summary.html"]oracle website[/URL] if you want to take a look. [/INDENT] [B]Some Sample Scripts: [/B][SPOILER="Sample Scripts"] The below script recieves the amount of players online stored in a database. It also checks to see if the server is online using fsockopen(); [code] $query = mysql_query ("SELECT * FROM status WHERE world = '1'") or die(mysql_error()); $status = false; $players = 0; while($row = mysql_fetch_array($query)) { $players = $row['players']; $timestamp = $row['timestamp']; //will use in future $host = "SERVER IP"; //only handles world 1 right now, need handle for future worlds. $port = "43594"; $connection = @fsockopen($host, $port); if (is_resource($connection)) { $status = true; //server online fclose($connection); } else { $status = false; //server offline } } [/code] [/SPOILER] Again, this is just a basic coverage of SQL communication, seening as there's a lot more content. I've done a basic version, because I feel like the RSPS community doesn't nessisarily need such advanced SQL material. Most of what you're doing is simply related to easy executions for voting, donations, and keeping small data. If you want to learn more, feel free to check out documentation, or send me a message.
  6. hands

    SQL Auto Voting Help

    I've been trying to figure out how to make an auto voting system through my SQL, but I just started using SQL and I'm completely confused at what to do. TBH, i'm not sure where to start. I have XAMPP on my computer and i use phpmyadmin. I made the database "vote", and I'm not sure where to go from there. I do not need a ::claim command or anything, I just need to see if the player voted or not. Can anybody please make a video on how to help me, or link me to one. Or you could simply reply to this post, thanks. :)
  7. TsScape

    Need help with sql

    Hello, I have a RSPS, and I would like to find out how to do this : When a player logs out, i would like their position on the map, username, password, and character rights saved to a MYSQL database on my website, is this possible? If so, where can i find a tutorial? as i can't find one anywhere.
  8. [code]java.sql.SQLException: Access denied for user 'gpvxguru_hisc'@'168.144.***.***' (using password: YES)[/code] The SQL its trying to connect to my vps ip while im trying to make it connect to my webhost (PAID WEBHOST OK M8?) [CODE]public static Connection con = null; public static Statement stmt; public static boolean connectionMade; public static void createConnection() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://198.15.**.***/gpvx***_***","***","***"); stmt = con.createStatement(); } catch (Exception e) { e.printStackTrace(); } }[/CODE]
  9. so, i need help with my vote system, but my vote.php gives this error: error connecting to mysql server - No connection could be made because the target machine actively refused it. You can check it at [url]http://www.infinity-servers.com/vote/vote.php[/url] the host its set for localhost, password its correct and user its root whats the problem then?
  10. I've always been curious about this but never put any thought into it.. Would the best way about making multiple pages (i.e. a thread with 100 posts) would be to use a GET variable and then time the SQL query limit by that GET? I.e. if the page number when using get was 3 (with $_GET['page']) you could then multiply a LIMIT (say 10) by the page number (in this case it's 3). Obviously some more work would need to be done to eliminate the earlier posts by just making a range or something.. Is this the most efficient way about doing this or is there another, more popular way? ^^may sound messy. Only a quick 2 minute write up.
  11. Yo I am working on a project not really giving details until further progress is made but I need help with a query. So there is a table called friends and in it it hsa these columns id Type - Friend/Ignore Username - Your username FriendName - Friend/Ignore username Using that data I need to make it so only if you are friends it will show up there status which is then stored in the status table I had the idea of having friends in the users table and using arrays where string contains friend name or something Does anyone understand and can help? Imagine it's twitter and only people you are following show up on your feed Thanks in advance. It has me really stumped :@.
  12. Could someone make a tutorial how to integrate SQL Loading/Saving to Project Annihilation [Base: Hyperion].
  13. imtiax

    SQL Commands

    I am using Dementhium 639. I would like to add a report command, the report should go to a table in the database. I have made a table called 'reports' in my database. How would I make the report command put the reports in the database. I know how to use PHP to do this, but I"m not sure for java.
  14. Does anyone know the list of user rights for Dementhium 639 SQL? userGroup 6 = Admin Anyone know the rest.
  15. I converted the SMF highscores to 562 and am trying to get the server to connect to my database. I get this error. All of my information is 100% correct. I copied it from my SMF server settings. The only thing in question is the port and allowing outside connections. [code] [2011/08/11 13:06:50] [Server]: RS2HD Framework Loaded [2011/08/11 13:06:50] [Server]: Loaded 15500item prices. [2011/08/11 13:06:50] [Server]: Shops loaded... [2011/08/11 13:06:51] [Server]: Reading mapdata... [2011/08/11 13:06:51] [Server]: Loaded mapdata. [2011/08/11 13:06:51] [Server]: Loaded packet handlers. [2011/08/11 13:06:51] [Server]: Loading item definitions... [2011/08/11 13:06:51] [Server]: Loaded 21436 item definitions. [2011/08/11 13:06:51] [Server]: Loading npc definitions... [2011/08/11 13:06:51] [Server]: Loaded 281 npc definitions. [2011/08/11 13:06:51] [Server]: Connected to SQL... com.mysql.jdbc.CommunicationsException: Communications link failure due to under lying exception: ** BEGIN NESTED EXCEPTION ** java.net.ConnectException MESSAGE: Connection timed out: connect STACKTRACE: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja va:173) at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:267) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739) at com.mysql.jdbc.Connection.<init>(Connection.java:1553) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java :266) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.rs2hd.util.DBConnectionPool.connect(DBConnectionPool.java:27) at com.rs2hd.GameEngine.<init>(GameEngine.java:156) at com.rs2hd.Server.<init>(Server.java:71) at com.rs2hd.Main$1.run(Main.java:36) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION ** Last packet sent to the server was 12 ms ago. at com.mysql.jdbc.Connection.createNewIO(Connection.java:2814) at com.mysql.jdbc.Connection.<init>(Connection.java:1553) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java :266) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.rs2hd.util.DBConnectionPool.connect(DBConnectionPool.java:27) at com.rs2hd.GameEngine.<init>(GameEngine.java:156) at com.rs2hd.Server.<init>(Server.java:71) at com.rs2hd.Main$1.run(Main.java:36) at java.lang.Thread.run(Unknown Source) Cannot connect to database! [/code] Any help please?
  16. Let's start of by saying that this tutorial is designed specifically for Windows XP users only. Although it's basically the same thing as the others, the navigating part is different. There are many different databases out there, Java 6 even has one built in however this tutorial will teach you how to create a could-be functional ODBC database. This won't teach you how to do things in SQL however will give you a start by creating the initial database. Good luck! We'll first navigate to the ODBC Data Source Administrator Screen Click start and then go to your Control Panel. You'll see a bunch of other applications; however, the one we're narrowing it down to is the folder, Administrator Tools. Now, this folder may not appear to be a folder as of it's icon, however click it anyways. Once in there, you'll see numerous administrative tools but we've reached our destination. Click Datasources (ODBC) and we're there. Now, we'll add the database. Forget about everything in that screen except the button, add. Click it and select your drive you wish to use with your database. All of the following drivers listed in that box are already on your computer thus you shouldn't worry too much. However; select Microsoft Access Driver (*.mdb) and then click Finish. Personalizing your data is easy! No tables or any data has been created yet in your new database. First, you'll have to name it and give a simple description it's general purpose. So, in the DSN (Data source name) box, type in a name. Doesn't exactly matter what you put however it's useful to determine exactly what this database is used for. Also, same with the description box as well. Once you've done that, click Ok and you should be redirected to the main screen. On the box in the middle, you'll see your newly created database added to that list. Now, you can connect to this database by doing the following: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:Example"); Statement statement = connection.createStatement(); Within your class and do the obvious imports: import java.sql.DriverManager; import java.sql.Statement; import java.sql.Connection; import java.sql.SQLException; This is just a start, hope you learned something.