WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform
Close the current Shockwave Flash file

swf_closefile

(PHP 4)

swf_closefileClose the current Shockwave Flash file

Description

void swf_closefile ([ int $return_file ] )

Close a file that was opened by the swf_openfile() function.

Parameters

return_file

If set then the contents of the SWF file are returned from the function.

Return Values

No value is returned.

Examples

Example #1 Creating a simple flash file based on user input and outputting it and saving it in a database

<?php

// The $text variable is submitted by the
// user

// Global variables for database
// access (used in the swf_savedata() function)
$DBHOST "localhost";
$DBUSER "sterling";
$DBPASS "secret";

swf_openfile("php://stdout"25625630111);

    
swf_definefont(10"Ligon-Bold");
        
swf_fontsize(12);
        
swf_fontslant(10);

    
swf_definetext(11$text1);

    
swf_pushmatrix();
        
swf_translate(-50800);
        
swf_placeobject(1160);
    
swf_popmatrix();

    
swf_showframe();

    
swf_startdoaction();
        
swf_actionstop();
    
swf_enddoaction();

$data swf_closefile(1);

$data ?
  
swf_savedata($data) :
  die(
"Error could not save SWF file");

// void swf_savedata(string data)
// Save the generated file a database
// for later retrieval
function swf_savedata($data)
{
    global 
$DBHOST,
           
$DBUSER,
           
$DBPASS;

    
$dbh = @mysql_connect($DBHOST$DBUSER$DBPASS);

    if (!
$dbh) {
        die (
sprintf("Error [%d]: %s",
                      
mysql_errno(), mysql_error()));
    }

    
$stmt "INSERT INTO swf_files (file) VALUES ('$data')";

    
$sth = @mysql_query($stmt$dbh);

    if (!
$sth) {
        die (
sprintf("Error [%d]: %s",
                      
mysql_errno(), mysql_error()));
    }

    @
mysql_free_result($sth);
    @
mysql_close($dbh);
}
?>

See Also