A Flash Developer Resource Site

Page 2 of 5 FirstFirst 12345 LastLast
Results 21 to 40 of 93

Thread: Load a movie into flash using a PHP file

  1. #21
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    what files?
    Altruism does not exist. Sustainability must be made profitable.

  2. #22
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488

  3. #23
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    The txt files that my PHP files load in, is there any way that I can stop these being cahced?

    And thanks for the link Ask The Geezer
    ninjakannon

    - My Website -

  4. #24
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Wait a minute. If you load txt files into PHP with fread you don't get any caching.

    Anyway, it's a general rule that when you append variables to a URI, the browser is forced to send the request to the server and get a fresh response (because it's mandatory for bi-directional communication).

    Just add "?ran=#" where # stands for a random number. This is necessary because most ISP's and browsers will attempt to cache the content even in case of sent variables. If you send the same variable twice, the second time you are getting the cached result.

    p.s. The Safari browser is stupid, it doesn't send full headers and so it doesn't force IPS's to refresh the content. Caching occours in your computer and in your provider's servers to limit outward bandwidth usage. Usually if the ISP is caching, you just have to refresh twice to get it to fetch new content from the web. But Safari can't manage to do it, because it doesn't send the headers that force the ISP to refresh the content....

    just weird...
    Altruism does not exist. Sustainability must be made profitable.

  5. #25
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    That's very odd, I am using fread to read the text files and they still cache, I expect it caches when you use fwrite then.

    I did use the ?ran# technique, I checked my tempary iternet files and found that I had 100s of each of the files, with different random numbers sent to them.

    I want to stop the caching so that people cannot read the variables inside, but that will not matter soon as I will be upgrading to a database.

    If I use the meta tag CONTENT="no-cache" on my webpage with the flash movie in that loads the php files which load the txt files, will caching be stopped?
    ninjakannon

    - My Website -

  6. #26
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Well, from what I know, even though you forse the browser not to cache a media, this will tell the browser to fetch a new version of the media each time, but won't prevent it from storing a local copy of it.

    In your case you should pass to a database anyway. And db is much easier too, than textfiles...
    Altruism does not exist. Sustainability must be made profitable.

  7. #27
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Yes, I should be using a database, and I plan to. But I need to know more about MySQL first, I really have no idea about how to use it or anything.

    Idealy I would like to create a MySQL database, containing a table, and upload the database file to the the server that I am using. Then I could find out how to access the database pretty easily. It's just the creating of the database in the first place that I cannot do.

    I assume that there are PHP functions that will create a MySQL database, so I could always use a PHP file to create the database in the first place. Could you help out on this please?

    Cheers
    Last edited by ninjakannon; 03-30-2006 at 11:27 AM.
    ninjakannon

    - My Website -

  8. #28
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Easier to do it from your server sql interface.

  9. #29
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    So how would I go about doing that?
    ninjakannon

    - My Website -

  10. #30
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Create the database on your hosting server. Then log into it and create the tables with their columns and rows. You don't need to know much sql to do it that way, otherwise, you need to learn the syntax for php and sql to do it by loading it from a php page.

    On your server, you should already have a phpAdmin interface to create and edit the content. It's all done by filling out forms.

  11. #31
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Yes, your hosting service will definetly have phpMyAdmin.

    It is true though that shell commands for mysql and mysqladmin are very similar to, and in many cases just equal to, the mysql queries launched through PHP. This means that there is only one language to learn and pretty much the same commands for everything.

    I don't like phpMyAdmin, so I created my own "control panel", which consists of a simple query form and 4 output frames. I manage my db from there, because I don't have root access on the server that is hosting me.
    I just prefer writing queries by hand, even though this raises the chances of mis-typing..
    Altruism does not exist. Sustainability must be made profitable.

  12. #32
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Yes, I do have myPHPAdmin and I have created a database.

    I now need to know how to insert new records into the table, read specific records and delete specific records using PHP.
    ninjakannon

    - My Website -

  13. #33
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    No, you do not use PHP to talk to the database.
    You tell PHP what to "say" to the database.

    This is why they often say PHP/mySQL, because when creating database-driven applications, you are actually using two languages at the same time.

    For example, this is a way to create a table
    PHP Code:
    $query 'CREATE TABLE myTable(id INT NOT NULL AUTO_INCREMENT, name TINYTEXT, age INT(3), PRIMARY KEY(id))';
    if(
    $result mysql_query($query)) {
        
    // table was created
    } else {
        
    // table wasn't created, you can inquire with the following line:
        
    echo (mysql_error());


    To learn how to use all this stuff, there is nothing like the two following sites:
    http://www.php.net/
    http://www.mysql.com/

    In php.net you will find a bunch of good programming examples and all the documentation you need.

    In mysql.com you will find specific db-related resources, as like when you need advanced mySQL syntax rules.

    Hope this helps, but you have to do the rest...! It will take a few head eachs, but you will be up and running before you think, so get started!
    Altruism does not exist. Sustainability must be made profitable.

  14. #34
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    OK,

    I am trying to get the number of rows in my database but I get this error:
    "I could not run this query because: No Database Selected"

    Here Is my code:
    PHP Code:
    <?php

    header
    ("Cache-control: no-cache");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);
    header("Pragma: no-cache");

    $db_connect mysql_connect("localhost""mysql_username""mysql_password") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db("myDatabaseName"$db_connect);

    $result mysql_query("SELECT * FROM myTableName"$db_connect) or die ('I could not run this query because: ' mysql_error());
    $num_rows mysql_num_rows($result);

    echo 
    "$num_rows Rows\n";

    mysql_close($db_connect);

    ?>
    So... erm... I thought I did select a database, what's wrong - any ideas?

    Thanks a lot
    ninjakannon

    - My Website -

  15. #35
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    You are miss-spelling the db name, or something else is happening at db selection time.

    You should use the "or" clause on the mysql_select_db command too, so you can see what happens:

    mysql_select_db("name", $link) or die(mysql_error());

    That should give you a hint of your problem..
    Altruism does not exist. Sustainability must be made profitable.

  16. #36
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Thanks for that!

    I added the 'or die' and found that my user did not have access to do anything to the database. I changed the settings and now I am fine.
    ninjakannon

    - My Website -

  17. #37
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Oh dear, another problem:
    PHP Code:
    <?php

    $db_connect 
    mysql_connect("localhost""my_username""my_pass") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db("my_databaseName"$db_connect) or die('error sellecting db: ' mysql_error());

    "INSERT INTO `my_tablename` (`field1`, `field2`, `field3`, `field4`, `field5`, `field6`) VALUES ('value1', 'value2', 'value3', 'value4', 'value5', 'value6')" or die ('huh?' mysql_error());

    mysql_close($db_connect);

    ?>
    This time I have permision to do this and there are no errors anywhere. Apparently the script is working, however nothing happens, the table stays as it is!

    Any ideas this time?

    Cheers
    ninjakannon

    - My Website -

  18. #38
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    You are mistaking the INSERT syntax.

    You can do it either like this (thinking about a table with 5 columns:

    INSERT INTO tblname (colname3, colname2, colname5) VALUES ('foo', 123, UNIX_TIMESTAMP());

    or like this:

    INSERT INTO tblname VALUES (NULL, 123, 'foo', NULL, UNIX_TIMESTAMP());

    In any case column names must NOT be quoted in any way, and are NOT case sensitive (while table name ARE case sensitive).

    Hope this helps!
    Altruism does not exist. Sustainability must be made profitable.

  19. #39
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    In your code anyway, you are not creating and sending the query...

    Your code is:
    PHP Code:
    [...]
    "INSERT INTO `my_tablename` (`field1`, `field2`, `field3`, `field4`, `field5`, `field6`) VALUES ('value1', 'value2', 'value3', 'value4', 'value5', 'value6')" or die ('huh?' mysql_error());
    [...] 
    While it should be:
    PHP Code:
    [...]
    $query "INSERT INTO my_tablename (field1, field2, field3, field4, field5, field6) VALUES ('value1', 'value2', 'value3', 'value4', 'value5', 'value6')";
    if(!
    $result mysql_query($query)) {
        echo 
    mysql_error();
    } else {
        
    // command executed..
    }
    [...] 
    Altruism does not exist. Sustainability must be made profitable.

  20. #40
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    OK, I have updated my code but now i have a really strange problem.

    PHP Code:
    $addData mysql_query("INSERT INTO $tableName ($Fields[0]$Fields[1]$Fields[2]$Fields[3]$Fields[4]$Fields[5]) VALUES ($NewID$NewName$NewPass, 'false', NULL, NULL)"$db_connect) or die (mysql_error()); 
    My code works fine, but only I enter numbers in the $NewName and $NewPass variables. Why is this? I need to be able to enter letters, spaces and underscores as well.

    I get the error: Unknown column 'username' in 'field list'
    In place of 'username' there is the username that I try to write to the database. (Or password if it was that field that was not a number).

    The $NewID variable works because it is allready a number. The fields are set to text in the database.
    Last edited by ninjakannon; 04-03-2006 at 06:30 AM.
    ninjakannon

    - My Website -

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center