Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "AWS";
- $link = mysqli_connect($servername,$username,$password,$dbname);
- if (!$link) {
- echo "Error: Unable to connect to MySQL." . PHP_EOL;
- echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
- echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
- exit;
- }
- $regions_str = '{
- "Regions": [
- {
- "Endpoint": "ec2.ap-south-1.amazonaws.com",
- "RegionName": "ap-south-1"
- },
- {
- "Endpoint": "ec2.eu-west-1.amazonaws.com",
- "RegionName": "eu-west-1"
- },
- {
- "Endpoint": "ec2.ap-southeast-1.amazonaws.com",
- "RegionName": "ap-southeast-1"
- },
- {
- "Endpoint": "ec2.ap-southeast-2.amazonaws.com",
- "RegionName": "ap-southeast-2"
- },
- {
- "Endpoint": "ec2.eu-central-1.amazonaws.com",
- "RegionName": "eu-central-1"
- },
- {
- "Endpoint": "ec2.ap-northeast-2.amazonaws.com",
- "RegionName": "ap-northeast-2"
- },
- {
- "Endpoint": "ec2.ap-northeast-1.amazonaws.com",
- "RegionName": "ap-northeast-1"
- },
- {
- "Endpoint": "ec2.us-east-1.amazonaws.com",
- "RegionName": "us-east-1"
- },
- {
- "Endpoint": "ec2.sa-east-1.amazonaws.com",
- "RegionName": "sa-east-1"
- },
- {
- "Endpoint": "ec2.us-west-1.amazonaws.com",
- "RegionName": "us-west-1"
- },
- {
- "Endpoint": "ec2.us-west-1.amazonaws.com",
- "RegionName": "us-west-1"
- },
- {
- "Endpoint": "ec2.us-west-2.amazonaws.com",
- "RegionName": "us-west-2"
- }
- ]
- }';
- $json_a=json_decode($regions_str,true);
- foreach($json_a['Regions'] as $mydata)
- $end_point = $mydata["Endpoint"];
- $region_name = $mydata["RegionName"];
- $ac_id = 1;
- {
- $statement = $link->prepare("INSERT INTO `aws_regions`(`ac_id`, `name`,`endpoint`) VALUES(?, ?, ?)");
- $statement->bind_param("iss",1,$mydata['Endpoint'], $mydata['RegionName']);
- $statement->execute();
- }
- mysqli_close($link);
- ?>
Add Comment
Please, Sign In to add comment