I'm a noob to development and I am trying to figure out out how to run my own basic php using AWS Elastic beanstalk. I followed the tutorial here and was able to successfully deploy and run the php-secondsample script that was provided. However, when I created a new application with my own script the page returns blank. I am passing the URL "http://myenvironment.elasticbeanstalk.com/myfunction.php?action=test" Any help would be greatly appreciated.
Here is my script called index.php
<?php
$action = $_GET['action'];
if($action == "") $action = $_REQUEST['action'];
$type = $_GET['type'];
myconnect();
if($action == 'test'){
echo "Success!";
}
function myconnect(){
define('DB_SERVER', 'redacted');
define('DB_USERNAME', 'redacted');
define('DB_PASSWORD', 'redacted');
define('DB_DATABASE', 'redacted');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
//$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
if (!$connection) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>"
);
exit();
}
// Select the database
if (!mysql_select_db(DB_DATABASE) ) {
echo( "<p>Unable to locate the medical " .
"database at this time.</p>" );
exit();
}
}
?>
What you are trying to do with the following code ?
1) if($action == "") $action = $_REQUEST['action'];
2) $type = $_GET['type'];
If you are using only GET at this time, you can simply avoid the 1. $_REQUEST Super global will return an associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.
If you are passing 'type' as an optional GET parameter, you can use something like this
$type = isset($_GET['type']) ? $_GET['type'] : '';
Rest of your code seems to be fine.