Make the PHP Script Better with error management
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
cee41d7abd
commit
a869cd66c2
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
$username="dafldev";
|
$username="dafldev"; //Get the username
|
||||||
$host="89.83.53.34";
|
$host="89.83.53.34"; //Get the address IP of the hosting machine
|
||||||
$password="wrap";
|
$password="wrap"; //Get the password for the user selected
|
||||||
$db_name="positiondaflmusic";
|
$db_name="positiondaflmusic"; //Get the name of the database
|
||||||
|
|
||||||
$connect=mysqli_connect($host,$username,$password,$db_name);
|
$connect=mysqli_connect($host,$username,$password,$db_name); //Connecting to database
|
||||||
|
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) { //Check if the connection failed
|
||||||
print(json_encode("Failed to connect to MySQL"));
|
print(json_encode("Failed to connect to MySQL")); //Return a json string, so the dart script can interpret the error
|
||||||
exit(-1);
|
exit(-1); //Send a return code as -1, so insert.php can know if the connection is successful
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
$dns = 'mysql:host=89.83.53.34;dbname=positiondaflmusic';
|
|
||||||
$user = 'dafldev';
|
|
||||||
$password = 'wrap';
|
|
||||||
try{
|
|
||||||
$db = new PDO ($dns, $user, $password);
|
|
||||||
}catch( PDOException $e){
|
|
||||||
$error = $e->getMessage();
|
|
||||||
echo $error;
|
|
||||||
}
|
|
Loading…
Reference in new issue