• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Ho-oh 112's mySQL Trade System

15
Posts
12
Years
  • Seen May 17, 2012
i knew it. u cant script. copiing the script failed and youhave no idea what to do.
my opinion cya
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
i knew it. u cant script. copiing the script failed and youhave no idea what to do.
my opinion cya

????? I'm taking a break because I found a new game called edgeworld you dope AND WHERE DID I COPY THIS FROM?? I MADE IT FROM SCRATCH!!!!

Note: Scripting myself out for a week can be tiring so DON'T SAY IT'S NOT HARD WORK!
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
UPDATES:

Hey people I got the base structure of the php file ready! It's only a very unstable base but if you can improve fix any errors I didn't find then please do so.

Code:
<?php
$host="Localhost";
$user="root";
$pass="";
$base="pokemon";
$port=3306;
$sql=mysql_connect($host,$user,$pass,$base,$port) or die("Cannot connect to MySQL");
$request = $_GET['Request'];

if ($request == "delete_pokemon") {
$code = $_GET['Code'];
mysql_query("DELETE FROM Trades WHERE Code=$code") or die("Cannot delete".$code."From Trades");
}

if ($request == "taken_pokemon") {
$poke=$_GET['Pokemon'];
$ech=mysql_query("FROM Trades SELECT Taken WHERE Pokemon=$poke") or die("Cannot Select".$Poke."From Trades");
}

if ($request == "send_pokemon") {
$code=$_GET['Code'];
$poke=$_GET['Pokemon'];
$level=$_GET['Level'];
$level1=$_GET['Level1'];
$level2=$_GET['Level2'];
$wanted=$_GET['Wanted'];
mysql_query("INSERT INTO Trades Code=$code,Pokemon=$poke,Level=$level,Wanted=$wanted,Level1=$level1,Level2=$level2,Taken='No'") or die("Cannot insert Query.");
}

if ($request == "get_pokemon") {
$poke=$_GET['Pokemon'];
$level1=$_GET['Level1'];
$levle2=$_GET['Level2'];
$ech=mysql_query("FROM Trades SELECT * WHERE Pokemon=$poke and Level>$level1 and Level<$level2") or die("None");
}

if ($request == "get_all") {
$ech=mysql_query("FROM Trades SELECT *") or die("Error!");
}
die($ech);
$sql_close;

?>
 

venom12

Pokemon Crystal Rain Relased
476
Posts
17
Years
  • Age 33
  • Seen Dec 28, 2023
Ok so i tested it, i got few errors, pokemon stores online but cant finish trade + some bugs. here are screens.
First screen Pokemon is stored but is not on the lsit but when i press space it continue.
http://dl.dropbox.com/u/4212314/Gts errpr/capture018.png

And here is something messed
http://dl.dropbox.com/u/4212314/Gts errpr/capture019.png

and error when want to finish trade.
Spoiler:
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
Ok so i tested it, i got few errors, pokemon stores online but cant finish trade + some bugs. here are screens.
First screen Pokemon is stored but is not on the lsit but when i press space it continue.
http://dl.dropbox.com/u/4212314/Gts errpr/capture018.png

And here is something messed
http://dl.dropbox.com/u/4212314/Gts errpr/capture019.png

and error when want to finish trade.
Spoiler:


AHHHH I Forgot to add the new version of the trade system....

EDIT: I'm fixing up some more bugs I found + making the php file better.
 
Last edited:
5
Posts
13
Years
  • Seen May 8, 2015
Thankyou for this awesome feature
Can you help me? after pressing search for pokemon and put the pokemon i want i get this error:

Spoiler:
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
Thankyou for this awesome feature
Can you help me? after pressing search for pokemon and put the pokemon i want i get this error:

Spoiler:

still working on a huge fix I noticed a small complicated error that'll take me a few to fix...
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
Hope it will be out soon.


Yeah I'm going to start working on this before H-Mode 7 until this works I just realized I can't compile the pokemon but I need to instead send all the different values of the pokemon...
 
772
Posts
13
Years
  • Age 35
  • UK
  • Seen today
A few comments about your php script. Bolded is how to improve/fix the issue

First off, pbpPostData in essentials sends requests using $_POST not $_GET.
Any $_GET should be $_POST

Also, any variables you send from the essentials script need to be sanitised before use in php otherwise you'll be open to sql injection which could potentially wipe out your database or have others insert unauthorised data into it if they managed to get hold of the url, which is pretty easy to do
You need to use mysql_real_escape_string() on all variables
e.g.
$ech=mysql_query("FROM Trades SELECT * WHERE Pokemon=".mysql_real_escape_string($poke)." and Level>".mysql_real_escape_string($level1)." and Level<".mysql_real_escape_string($level2)."") or die("None");


Your final $sql_close; at the end won't do anything since anything after a die() call isn't executed. You shouldn't be using die() to output data anyway.
Change the die to an echo or print

Its better to use elseif statements not several ifs since you're only going to be sending one request at once, and for each request its going to go through the whole script each time, which takes more time in the long run than elseif. With elseif it'd go through only until the criteria is met.
Use elseifs
e.g.
if(this>1){
do this
} elseif (this>2) {
do this
} else
do this
}
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
A few comments about your php script. Bolded is how to improve/fix the issue

First off, pbpPostData in essentials sends requests using $_POST not $_GET.
Any $_GET should be $_POST

Also, any variables you send from the essentials script need to be sanitised before use in php otherwise you'll be open to sql injection which could potentially wipe out your database or have others insert unauthorised data into it if they managed to get hold of the url, which is pretty easy to do
You need to use mysql_real_escape_string() on all variables
e.g.
$ech=mysql_query("FROM Trades SELECT * WHERE Pokemon=".mysql_real_escape_string($poke)." and Level>".mysql_real_escape_string($level1)." and Level<".mysql_real_escape_string($level2)."") or die("None");


Your final $sql_close; at the end won't do anything since anything after a die() call isn't executed. You shouldn't be using die() to output data anyway.
Change the die to an echo or print

Its better to use elseif statements not several ifs since you're only going to be sending one request at once, and for each request its going to go through the whole script each time, which takes more time in the long run than elseif. With elseif it'd go through only until the criteria is met.
Use elseifs
e.g.
if(this>1){
do this
} elseif (this>2) {
do this
} else
do this
}
EDIT:
Fixed up the problems with the scripts now I gotta test/make sql file...
 
Last edited:

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
UPDATES:
Fixed the PHP file and improved it to what Desbrina said
Fixed some errors with the Main script

Version: 2.0 Full


EDIT:
sql configuration table:

Table Name: trades
Column1: Code, Varchar(45)
Column2: Pokemon, Varchar(45)
Column3: Level, smallInt
Column4: Wanted, Varchar(45)
Column5: Level1, smallInt
Column6: Level2, smallInt
COlumn7: Taken, Varchar(45)
 
30
Posts
13
Years
  • Seen Jul 23, 2013
I don't know what I do bad, but when i call script pbStartGTS() and choose my Pokemon to trade nad press "Trade" i have an error: No pokemon chosen. This is screen for this error:

capture032.png


Ho-oh doy you know, what i do bad?
 

Ho-oh 112

Advance Scripter
311
Posts
13
Years
  • Age 28
  • Seen Mar 8, 2014
I don't know what I do bad, but when i call script pbStartGTS() and choose my Pokemon to trade nad press "Trade" i have an error: No pokemon chosen. This is screen for this error:

capture032.png


Ho-oh doy you know, what i do bad?


Did you click trade on the storage screen?
 
Back
Top