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
Too little info bro!
Whats the error massage?
Can you connect to mysql thru command line?
I tried using a site called like raindow somthing
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.
Je t'aime
(Apr 22, 2022 04:39 PM)-Scrub Wrote: Jokes on you, I'm not smart enough to know what he's talking about.
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){}
}
Can we see the error massage in php?
(Apr 25, 2019 10:34 AM)Sanchez 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.
Je t'aime
(Apr 22, 2022 04:39 PM)-Scrub Wrote: Jokes on you, I'm not smart enough to know what he's talking about.
(Apr 25, 2019 10:34 AM)Sanchez 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); }
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.
(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
|