SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP echo command in Flash

    Hi iam trying to echo a php varable in a enbeded object

    i have a problem trying to play my flash files here is the code

    PHP Code:
    <object type="application/x-shockwave-flash" data="movie<?=$row['calledNumber']?>.swf" width="300" height="40"> 
    <param name="movie" value="movie<?=$row['calledNumber']?>.swf" /> 
    </object>
    if i echo
    PHP Code:
    echo "</b> movie$row[calledNumber].swf" 
    it works fine what am i missing.

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I would say short tags are not enabled, additionally there maybe a slight syntax error.
    Code:
    <?=$row['calledNumber']; ?>
    Don't quote me, I don't use this feature.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    it can't be the tags because if i use this code

    PHP Code:
    <? 
    $r
    =rand(1,3); 
    ?> 
    <object type="application/x-shockwave-flash" data="movie<?=$r?>.swf" width="300" height="40"> 
    <param name="movie" value="movie<?=$r?>.swf" /> 
    </object>
    the code above will play random movie files from 1 -3 with no problem so its playing a varable of movies 1-3 but if i try to get a varable from mysql it doesn't work, but i can print the move but not play a varable why!!!!!!

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Okie Dokie.

    Can you post the code which queries the database, assigns the relevant variables and outputs the HTML?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi this has been a nightmare project for me
    here is the php code

    PHP Code:
    $calledNumber=$_GET['calledNumber'];
    $numb = mysql_query("SELECT * FROM number WHERE called= 1 ");
    if (!$numb) {
      exit('<p>Error retrieving number from database!<br />'.
          'Error: ' . mysql_error(). '</p>');
    }

    while ($called = mysql_fetch_array($numb)) {
      $id = $called['id'];


      $calledNumber = htmlspecialchars($called['calledNumber']);
     
     echo "$calledNumber ";
    }

    ?>
     <object type="application/x-shockwave-flash" data="movie<?=$calledNumber?>.swf" width="300" height="40"> 
    <param name="movie" value="movie<?=$calledNumber?>.swf" /> 
    </object>
    here is the link to the test file so you can see what iam trying to do
    http://www.easynet4u.com/bingo/bingo1.php

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Any joy with the following?
    PHP Code:
    <?php
    if((true === isset($_GET['calledNumber'])) && (false === empty($_GET['calledNumber'])))
    {
        
    $rResult mysql_query(
            
    sprintf(
                
    'SELECT calledNumber FROM number WHERE id = %s LIMIT 1',
                
    $_GET['calledNumber']
            )
        );
        if((
    true === is_resource($rResult)) && (=== mysql_num_rows($rResult)))
        {
            
    $aRecord mysql_fetch_assoc($rResult);
            
    printf(
                
    '<object type="application/x-shockwave-flash" data="movie%1$d.swf" width="300" height="40">
                    <param name="movie" value="movie%1$d.swf" />
                </object>'
    ,
                
    $aRecord['calledNumber']
            );
        }
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    tried your code just get a blank page.

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that, I misread your code (or rather just made my own up!).

    I'm not entirely sure what you're trying to achieve. You never use the $_GET parameter in any of the code, is there a reason for this? The query also asks for a number which has been called before (i think), again, I think I'm getting confuzzled. :P

    I have assumed you just want to check for it's existence in the following code.
    PHP Code:
    <?php
    if(true === isset($_GET['calledNumber']))
    {
        
    $rResult mysql_query('SELECT calledNumber FROM numbers WHERE called = 1 LIMIT 1');
        if((
    true === is_resource($rResult)) && (=== mysql_num_rows($rResult)))
        {
            
    $aRecord mysql_fetch_assoc($rResult);
            
    printf(
                
    '<object type="application/x-shockwave-flash" data="movie%1$d.swf" width="300" height="40">
                    <param name="movie" value="movie%1$d.swf" />
                </object>'
    ,
                
    $aRecord['calledNumber']
            );
        }
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #9
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi iam using javascript to call the number by random between 1-90 then i use some ajax script to pass it to a php file called ajax.php then post the random numbers to the database this works fine, then iam using the code i posted earlier to select the numbers from the database then play the swf file,
    if you look at the demo i posted you will see a board when a number is called it lights up, above the board you will see some numbers appear about 2 seconds after the first number is called.these are the numbers from the php file i posted earlier, they print fine but wont play swf files why????????.
    don't say i need swfobject can't get my head round it.

  10. #10
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    i have change the code. now the ajax.php post's the full url plus the number into the database but still no joy, i can print it out no problem but can't play swf file, can't seem to solve this no matter what i do
    here is the code
    PHP Code:
    $numb = mysql_query("SELECT * FROM number WHERE called= 1 ");
    if (!$numb) {
      exit('<p>Error retrieving number from database!<br />'.
          'Error: ' . mysql_error(). '</p>');
    }

    while ($called = mysql_fetch_array($numb)) {
      $id = $called['id'];


      $sitePath= htmlspecialchars($called['sitePath']);
     
    echo"$calledNumber";
    }

    ?>
     <object type="application/x-shockwave-flash" data="<?=$sitePath?>/movie<?=$calledNumber?>.swf" width="300" height="40"> 
    <param name="movie" value="<?=$sitePath?>/movie<?=$calledNumber?>.swf" /> 
    </object>


Bookmarks

Posting Permissions

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