I've got an AS3 code that goes to a php page on a website. That php search in a database (sql) online and send results to my AS3 code.
So I've got 3 files : my project (FLA file), my php file, and my sql file.
Everything is working, but now I would like to do this operation offline (local).
How can I do ?
In my AS3 code I've got :
var urlreq =newURLRequest("http://www.****.com/****/myPHP.php");
urlreq.method =URLRequestMethod.POST;
var urlVars =newURLVariables();
urlVars.theport ="New-York";
urlreq.data = urlVars;
var loader:URLLoader=newURLLoader(urlreq);
loader.addEventListener(Event.COMPLETE, completed);
loader.dataFormat =URLLoaderDataFormat.VARIABLES;
loader.load(urlreq);
In my php :
$theport = $_POST['theport'];...
linked to a conn.php file :
$cfg_hote ='mys****.perso';
$cfg_base ='******';
$cfg_user ='*****';
$cfg_password ='****rhx';
And I've got an sql file uploaded at phpmyadmin.ovh.net
So now, how can I do this operation offline (local) ?
I've tried to change
var urlreq =newURLRequest("http://www.****.com/****/myPHP.php");
to
var urlreq =newURLRequest("myPHP.php");
But it can't find the database on local (sql file);
Thx for your help
EDIT
I've tried to add that to my AS3 code :
import flash.data.SQLConnection;
import flash.data.SQLMode;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;
var conn:SQLConnection=newSQLConnection();
conn.addEventListener(SQLEvent.OPEN, openHandler);
conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
// The database file is in the application storage directory
var folder:File=File.applicationStorageDirectory;
var dbFile:File= folder.resolvePath("database.sql");
conn.openAsync(dbFile,SQLMode.UPDATE);
function openHandler(event:SQLEvent):void{
trace("the database opened successfully");
}
function errorHandler(event:SQLErrorEvent):void{
trace("Error message:",event.error.message);
trace("Details:",event.error.details);
}
But it can't open the database.sql (trace output : Error #3125: Unable to open the database file
)
Anyone see what i can do ?