Reputation: 13
PHP requests show a message Warning:
mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\project\www\js\insert.php on line 12
I am using openshift host and ionic framework. I'm still working on localhost.
Here is insert.php :
<?php
$data = json_decode(file_get_contents("php://input"));
$first_name = mysql_real_escape_string($data->first_name);
$last_name = mysql_real_escape_string($data->last_name);
$age = mysql_real_escape_string($data->age);
$homeCity = mysql_real_escape_string($data->homeCity);
$mobile = mysql_real_escape_string($data->mobile);
$host="www.pyf-michaelreda96.rhcloud.com";
mysql_connect($host,"********","********") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
mysql_query("INSERT INTO members(first_name,last_name,age,home_city,mobile_number)VALUES('".$first_name."','".$last_name."','".$age."','".$homeCity."','".$mobile."')");
$id = json_decode(mysql_insert_id());
echo $id;
?>
Upvotes: 0
Views: 112
Reputation:
The MySQL server on your OpenShift gear is not accessible from the internet, it is only accessible from the gear, or over port forwarding. You can learn more about accessing your database over port forwarding here: https://developers.openshift.com/managing-your-applications/port-forwarding.html
Upvotes: 0