Reputation: 598
I am having trouble getting my script in a different folder to work. Very new to Google App Engine, totally new to YAML.
The folder structure is:
/login.php
/includes/mySQLConnection.php
app.yaml
application: test
version: 1
runtime: php
api_version: 1
handlers:
- url: /includes
static_dir: includes
application_readable: true
- url: /login.php
script: login.php
login.php
<?php
header('Content-type: application/json');
if($_POST) {
//Get Username and Password
$user_email = strip_tags(trim(strtolower($_POST['username'])));
$user_password = strip_tags(trim($_POST['password']));
//Connect to mySQL Server
include $_SERVER['DOCUMENT_ROOT']."includes/mySQL_connection.php";
// //Select which database to work with
$database = mysql_select_db("test",$mySQL_connection) or die("Cannot connect to user table");
echo json_encode(array('success' => 1,'error_message' => "Success"));
}
?>
/includes/mySQL_connection.php
<?php
$hostname = '127.0.0.1:3306';
$db_username = 'root';
$db_password = '';
//connection to the database
$mySQL_connection = mysql_connect($hostname, $db_username, $db_password) or die("Unable to connect to MySQL");
?>
This will not work, however if I take all the code out of /includes/mySQL_connection.php and put it into /login.php then it works perfectly.
Can anyone point me in the right direction?
Upvotes: 0
Views: 317
Reputation: 7054
DOCUMENT_ROOT does not have a trailing '/', looks like you'll need to add one.
In http://php-minishell.appspot.com/ I tried it out
>>> echo $_SERVER['DOCUMENT_ROOT'];
/base/data/home/apps/s~php-minishell/20140319.374522287571266149
So probably change your code to
//Connect to mySQL Server
include $_SERVER['DOCUMENT_ROOT']."/includes/mySQL_connection.php";
Upvotes: 1