problems with mysql - Sanchez Sales - Apr 25, 2019
Building a site on ubuntu 16.04 and for some reason can't connect to the mysql DB
in the mysql file i have it set #bind_adress: 0.0.0.0
RE: problems with mysql - I337 - Apr 25, 2019
Too little info bro!
Whats the error massage?
Can you connect to mysql thru command line?
RE: problems with mysql - Sanchez Sales - Apr 25, 2019
I tried using a site called like raindow somthing
RE: problems with mysql - Nachfolger - Apr 25, 2019
What an absolute mad lad. You expect to get help with such useless info provided?
Try changing the address to "localhost". If that doesn't work, include the connection script.
RE: problems with mysql - Sanchez Sales - Apr 25, 2019
my php file
Code <?php
$conn = new mysqli("localhost", "infidel", "yourpass", "yourdb");
if ($conn->connect_error) {
die("ERROR: Unable to connect: " . $conn->connect_error);
}
$conn->set_charset('utf8mb4');
$botUser=$conn->real_escape_string($_POST['botUser']);
$botName=$conn->real_escape_string($_POST['botName']);
$botWorld=(int)$_POST['botWorld'];
$location=$conn->real_escape_string($_POST['location']);
$query = "INSERT INTO online ( `user`, `bot`, `world`, `loc` ) VALUES ('$botUser', '$botName', '$botWorld', '$location')";
$result=mysqli_query($conn,$query);
echo '<center>404: This page does not exist.</center></br>';
?>
java file:
Code public void onlineBot(String user, String host, int world, String loc) {
try{
String urlParameters = "botUser="+user+"&botName="+host+"&botWorld="+world+"&location="+loc;
URL url = new URL("http://Yoururl/yourfile.php");
HttpURLConnection hc = (HttpURLConnection)url.openConnection();
hc.setDoInput(true);
hc.setDoOutput(true);
hc.setInstanceFollowRedirects(false);
hc.setRequestMethod("POST");
hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
hc.setRequestProperty("charset", "utf-8");
hc.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
hc.setUseCaches(false);
DataOutputStream ds = new DataOutputStream(hc.getOutputStream());
ds.writeBytes(urlParameters);
ds.flush();
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(hc.getInputStream()));
line = br.readLine();
log(line);
ds.close();
br.close();
hc.disconnect();
} catch(IOException e){}
}
RE: problems with mysql - I337 - Apr 25, 2019
Can we see the error massage in php?
RE: problems with mysql - Nachfolger - Apr 25, 2019
(Apr 25, 2019 10:34 AM)Life Sales Wrote: my php file
Code <?php
$conn = new mysqli("localhost", "infidel", "yourpass", "yourdb");
if ($conn->connect_error) {
die("ERROR: Unable to connect: " . $conn->connect_error);
}
$conn->set_charset('utf8mb4');
$botUser=$conn->real_escape_string($_POST['botUser']);
$botName=$conn->real_escape_string($_POST['botName']);
$botWorld=(int)$_POST['botWorld'];
$location=$conn->real_escape_string($_POST['location']);
$query = "INSERT INTO online ( `user`, `bot`, `world`, `loc` ) VALUES ('$botUser', '$botName', '$botWorld', '$location')";
$result=mysqli_query($conn,$query);
echo '<center>404: This page does not exist.</center></br>';
?>
What error is given? You should also be using prepared statements, it's not that hard to do.
RE: problems with mysql - Disease - Apr 26, 2019
(Apr 25, 2019 10:34 AM)Life Sales Wrote: my php file
Code <?php
$conn = new mysqli("localhost", "infidel", "yourpass", "yourdb");
if ($conn->connect_error) {
die("ERROR: Unable to connect: " . $conn->connect_error);
}
$conn->set_charset('utf8mb4');
$botUser=$conn->real_escape_string($_POST['botUser']);
$botName=$conn->real_escape_string($_POST['botName']);
$botWorld=(int)$_POST['botWorld'];
$location=$conn->real_escape_string($_POST['location']);
$query = "INSERT INTO online ( `user`, `bot`, `world`, `loc` ) VALUES ('$botUser', '$botName', '$botWorld', '$location')";
$result=mysqli_query($conn,$query);
echo '<center>404: This page does not exist.</center></br>';
?>
java file:
Code public void onlineBot(String user, String host, int world, String loc) {
try{
String urlParameters = "botUser="+user+"&botName="+host+"&botWorld="+world+"&location="+loc;
URL url = new URL("http://Yoururl/yourfile.php");
HttpURLConnection hc = (HttpURLConnection)url.openConnection();
hc.setDoInput(true);
hc.setDoOutput(true);
hc.setInstanceFollowRedirects(false);
hc.setRequestMethod("POST");
hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
hc.setRequestProperty("charset", "utf-8");
hc.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
hc.setUseCaches(false);
DataOutputStream ds = new DataOutputStream(hc.getOutputStream());
ds.writeBytes(urlParameters);
ds.flush();
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(hc.getInputStream()));
line = br.readLine();
log(line);
ds.close();
br.close();
hc.disconnect();
} catch(IOException e){}
}
First off, procedural or object-oriented, pick one. You're mixing a procedural query with otherwise object-orientated code. Also, you're started to set up error dumping, but aren't doing so after the query. Do so.
PHP Code
<?php if (!$conn->query($query)) { die($conn->error); }
RE: problems with mysql - kawaii - Apr 28, 2019
Do NOT bind your MySQL server to 0.0.0.0. This will make it publicly accessible on ALL IP addresses bound to your server (including your public IP), bind to either localhost or 127.0.0.1.
RE: problems with mysql - Sanchez Sales - Apr 28, 2019
(Apr 28, 2019 02:26 PM)kawaii Wrote: Do NOT bind your MySQL server to 0.0.0.0. This will make it publicly accessible on ALL IP addresses bound to your server (including your public IP), bind to either localhost or 127.0.0.1.
I can’t access remotely
|