×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    157

    Unable to connect to database with php and actionscript 2.0

    Hi,

    I get an error 'Error opening URL 'http://localhost/PhpProject2/index.php' while I try a database connection using PHP from the AS 2.0. Otherwise sending and receiving data works fine between the AS and the PHP.

    Below are my AS 2.0 and PHP codes:

    result_lv = new LoadVars();
    data_lv = new LoadVars();
    data_lv.num1 = 98;
    data_lv.num2 = 45;

    result_lv.onLoad = function (success)
    {
    if (success)
    {
    for( var prop in this )
    {
    trace (" key " + prop + " = " + this[prop]);
    }
    }
    else
    {
    trace("Cannot call the PHP file...");
    }
    }

    result_lv.onData = function(dataReceived)
    {
    trace(dataReceived);
    }

    data_lv.sendAndLoad("http://localhost/PhpProject2/index.php", result_lv, "POST");


    <?php
    $fVar1 = $_POST['num1'];
    $fVar2 = $_POST['num2'];
    $connect = mysql_connect('localhost','root','root');
    $dbselect = mysql_select_db('test',$connect);
    $query = mysql_query('SELECT name FROM testtable where Id = 2');
    if (!$connect or !$dbselect or !$query)
    {
    echo('failed=true');
    }
    else
    {
    echo ('true');
    }
    ?>


    Please help.

    Regards,
    Supriya Tenany

  2. #2
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Karachi, Pakistan
    Posts
    277

    Re: Unable to connect to database with php and actionscript 2.0

    Hi,

    You could have posted in same thread you started http://discussion.forum.nokia.com/fo...d.php?t=200482

    Anyway, I see that you're using http://localhost for server. It will work as long as you are testing on same PC using Device Central. When you put it on real device, you need to replace it with the server's hostname or IP address.

    If you have WiFi setup and your device supports WLAN, you can use the IP address of your test machine.

    Also, you can call the PHP directly in your PC browser (i.e. Firefox) to see if PHP script is not throwing any errors. If it is, simply fix the errors before using it in your FL application.

    Hope it helps,

    // chall3ng3r //
    Faisal Iqbal (skype: chall3ng3r)
    Flash Mobile Specialist | Orison Technologies
    _____________________________________
    blog: F·L·A·S·H·I·S·M
    swf2go: www.swf2go.com

  3. #3
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    157

    Re: Unable to connect to database with php and actionscript 2.0

    Hi chall3ng3r,

    There seems some problem in executing database related commands. There is no display even in the browser when I run the php with database commands, directly.

    <?php
    echo "starting";
    // (1) Open the database connection
    $connection = mysql_connect("localhost","root","root");
    echo "connected";
    // (2) Select the winestore database
    mysql_select_db("test", $connection);
    echo "db selected";

    // (3) Run the query on the winestore through the connection
    $result = mysql_query ("SELECT * FROM testtable", $connection);
    echo $result;
    ?>

    For the above code, I only get the first echo in the execution.

    As I am new to PHP, MySQL and Apache I need more details for debugging. All I can tell is I am using NetBeans IDE 6.8, PHP 5, Apache HTTP Server 2.2 and MySQL Server 5.1.

    Regards,
    Supriya Tenany
    Last edited by supriyaakg; 2010-05-13 at 04:22.

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Unable to connect to database with php and actionscript 2.0

    Quote Originally Posted by supriyaakg View Post
    Hi chall3ng3r,

    There seems some problem in executing database related commands. There is no display even in the browser when I run the php with database commands, directly.
    ...

    As I am new to PHP, MySQL and Apache I need more details for debugging. All I can tell is I am using NetBeans IDE 6.8, PHP 5, Apache HTTP Server 2.2 and MySQL Server 5.1.

    Regards,
    Supriya Tenany
    My advice for you would be to find a forum where PHP developers are discussing about accessing MySQL from PHP. This has nothing to do with flash and the changes of getting an answer here is significantly smaller than on a specialized forum.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×