简体   繁体   中英

php request: Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known

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;
?>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM