Page 1 of 1

PHP Editor

Posted: Tue Oct 12, 2010 9:44 am
by abbottsam1
Hey Guys , im just having a little trouble with a little bit of code.

Im just a beginner at PHP, and im just creating a little site for our Warcraft Guild.
what i have setup is a little script that displays youtube videos on our site. in the script is the list of the youtube videos that will be in the playlist.

What i was wondering is if there is a php script that i can use that can edit this file, and add another video(well , i line of text)

what im looking for is a script where the guy can enter the youtube videos id, and the script automatically edits it into my other pages code.

the code im using is - it is on my gallery.php page.

Code: Select all

<div class="demo-canvas">
  <div style="float: left; width: 371px; height: 300px;">
    <a name="ytplayer"></a>
    <div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  </div>
  <div style="float: left; width: 160px; height: 300px; overflow-y: scroll;">

    <div id="ytplayer_div2"></div>
  </div>
  <br style="clear: both;" />
  <br style="clear: both;" />
</div>
<script type="text/javascript" src="http://tsunami-guild.cz.cc/swfobject/swfobject.js"></script>
<script type="text/javascript">
  //
  // YouTube JavaScript API Player With Playlist
  // http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
  // Revision 1 [2009-10-12]
  //
  // Prerequisites
  // 1) Create following elements in your HTML:
  // -- a) ytplayer: a named anchor
  // -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
  // -- c) ytplayer_div2: container div for playlist
  // 2) Include SWFObject library from http://code.google.com/p/swfobject/
  //
  // Variables
  // -- ytplayer_playlist: an array containing YouTube Video IDs
  // -- ytplayer_playitem: index of the video to be played at any given time
  //
  var ytplayer_playlist = [ ];
  var ytplayer_playitem = 0;
  swfobject.addLoadEvent( ytplayer_render_player );
  swfobject.addLoadEvent( ytplayer_render_playlist );
  function ytplayer_render_player( )
  {
    swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
      'ytplayer_div1',
      '371',
      '300',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer_object'
      }
    );
  }
  function ytplayer_render_playlist( )
  {
    for ( var i = 0; i < ytplayer_playlist.length; i++ )
    {
      var img = document.createElement( "img" );
      img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
      var a = document.createElement( "a" );
      a.href = "#ytplayer";
      //
      // Thanks to some nice people who answered this question:
      // http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
      //
      a.onclick = (
        function( j )
        {
          return function( )
          {
            ytplayer_playitem = j;
            ytplayer_playlazy( 1000 );
          };
        }
      )( i );
      a.appendChild( img );
      document.getElementById( "ytplayer_div2" ).appendChild( a );
    }
  }
  function ytplayer_playlazy( delay )
  {
    //
    // Thanks to the anonymous person posted this tip:
    // http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
    //
    if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
    {
      window.clearTimeout( ytplayer_playlazy.timeoutid );
    }
    ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
  }
  function ytplayer_play( )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
    }
  }
  //
  // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
  // * Sets up handler for other events
  //
  function onYouTubePlayerReady( playerid )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.addEventListener( "onStateChange", "ytplayer_statechange" );
      o.addEventListener( "onError", "ytplayer_error" );
    }
  }
  //
  // State Change Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_statechange( state )
  {
    if ( state == 0 )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Error Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_error( error )
  {
    if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
  ytplayer_playlist.push( 'OyrsKyAO2dg' );
  ytplayer_playlist.push( 'e14ZLzVnou0' );
  ytplayer_playlist.push( 'O_z5lzApEFc' );
  ytplayer_playlist.push( 'XcinB07mfOg' );
  ytplayer_playlist.push( 'nHN_EmsP2C0' );
</script>
i have used google to search around but i couldnt find anything that worked for me.
hope you can help guys :D

Thanks, Sam..

Re: PHP Editor

Posted: Tue Oct 12, 2010 11:12 am
by Jonah Bron
Unfortunately, that would be very impractical. What you need to do is store the list in a database, and output it with PHP. Something like this:

Code: Select all

 [...]
    if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
<?php
$connection = mysql_connect('host', 'user', 'password');
mysql_select_db('database');
$result = mysql_query('SELECT youtube_id FROM queue_videos');
while ($row = mysql_fetch_assoc($result)) {
    echo 'ytplayer_playlist.push(\'' . $row['youtube_id'] . '\');' . PHP_EOL;
}
?>
</script>
You'll need to create a database on the server, and change the information here to match it (host, user, password, database, queue_videos, youtube_id).

Re: PHP Editor

Posted: Tue Oct 12, 2010 12:37 pm
by abbottsam1
ok , so ive edited that piece of code in and have my database made ,
but now , my browser .. or anyother browser wont update that page, its still using the html i had there before ... is this because of the mysql passwords and stuff in the page .

or must i have to put my code in a seprate file (lets say utube.php) and do an include() on my gallery.php page ?

Thanks,
Sam.

Re: PHP Editor

Posted: Tue Oct 12, 2010 12:44 pm
by Jonah Bron
abbottsam1 wrote:my browser .. or anyother browser wont update that page
What do you mean?

If you load the page, and right-click > View source, what do you see there? Post it here.

Re: PHP Editor

Posted: Tue Oct 12, 2010 12:50 pm
by abbottsam1
if i right click > view souce, its how i had it before - that how i know somethings not wrong

gallery.php(as shown in view>source for some reason)

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta name="Description" content="This site uses 'KoschtIT Image Gallery' v2.4 by Konstantin Tabere." /> 
<script type="text/javascript" src="gallery/ki_base/ki_js_framework.php?reldir=gallery/"></script>





  
  <meta name="Description" content="Tsunami Guild" />

  
  <meta name="Keywords" content="Tsunami" />

  
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

  
  <meta name="Distribution" content="Global" />

  
  <meta name="author" content="Samuel Abbott"/>

  
  <meta name="Robots" content="index,follow" />

  
  <link rel="stylesheet" href="images/Envision.css" type="text/css" /><title>Tsunami</title></head><body>
<!-- wrap starts here -->
<div id="wrap"><!--header -->
<div id="header">
<h1 id="logo-text"><a href="index.php">Tsunami</a></h1>

<p id="slogan">A New wave is rising...</p>
<div id="header-links">
<p> <a href="index.html"><br />
</a> </p>
</div>
</div>
<!-- menu -->
<div id="menu">
<ul>
  <li id="current"><a href="index.php">Home</a></li>
  <li><a href="forum/">Forum</a></li>

  <li><a href="gallery.php">Gallery</a></li>
  <li><a href="apply.php">Apply</a></li>
  <li><a href="about.php">About us</a></li>
</ul>
</div>
<!-- content-wrap starts here -->
<div id="content-wrap">
<div id="sidebar">&nbsp;<big><big><span style="color: rgb(0, 0, 153); font-style: italic;"> Guild Notices!</span></big></big><br />
<br />

<br />
<span style="color: rgb(51, 51, 255);"><dt>Tsunami Website Live</dt>
<dd class="post-date">Posted by Guild Notices on Monday, 11 October 2010</dd>
<dd><p>Hey guys , welcome to the Tsunami website, watch this area for guild notices and raids.</p>
</dd></span><br />
<div class="left-box">
<p><span style="color: rgb(51, 51, 255);">Random Screenshot:</span><br />
<img style="width: 166px; height: 130px;" alt="Random Image" src="gallery/ki_galleries/screenshots/randompic.php" /><br />
</p>
</div>

</div>
<div id="main">&nbsp;&nbsp;<a name="TemplateInfo"><span style="font-size: 21px; color: rgb(51, 51, 255);"><strong class="bbc" /></span><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><br />

</strong></strong></strong></strong></strong></strong></strong></strong></strong></a>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;">
      <div class="koschtitgallery" title="screenshots"><br />
      </div>
      </td>
    </tr>
  </tbody>

</table>
<strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><strong class="bbc">

<div class="demo-canvas">
  <div style="float: left; width: 371px; height: 300px;">
    <a name="ytplayer"></a>
    <div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  </div>
  <div style="float: left; width: 160px; height: 300px; overflow-y: scroll;">

    <div id="ytplayer_div2"></div>

  </div>
  <br style="clear: both;" />
  <br style="clear: both;" />
</div>
<script type="text/javascript" src="http://tsunami-guild.cz.cc/swfobject/swfobject.js"></script>
<script type="text/javascript">
  //
  // YouTube JavaScript API Player With Playlist
  // http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
  // Revision 1 [2009-10-12]
  //
  // Prerequisites
  // 1) Create following elements in your HTML:
  // -- a) ytplayer: a named anchor
  // -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
  // -- c) ytplayer_div2: container div for playlist
  // 2) Include SWFObject library from http://code.google.com/p/swfobject/
  //
  // Variables
  // -- ytplayer_playlist: an array containing YouTube Video IDs
  // -- ytplayer_playitem: index of the video to be played at any given time
  //
  var ytplayer_playlist = [ ];
  var ytplayer_playitem = 0;
  swfobject.addLoadEvent( ytplayer_render_player );
  swfobject.addLoadEvent( ytplayer_render_playlist );
  function ytplayer_render_player( )
  {
    swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
      'ytplayer_div1',
      '371',
      '300',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer_object'
      }
    );
  }
  function ytplayer_render_playlist( )
  {
    for ( var i = 0; i < ytplayer_playlist.length; i++ )
    {
      var img = document.createElement( "img" );
      img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
      var a = document.createElement( "a" );
      a.href = "#ytplayer";
      //
      // Thanks to some nice people who answered this question:
      // http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
      //
      a.onclick = (
        function( j )
        {
          return function( )
          {
            ytplayer_playitem = j;
            ytplayer_playlazy( 1000 );
          };
        }
      )( i );
      a.appendChild( img );
      document.getElementById( "ytplayer_div2" ).appendChild( a );
    }
  }
  function ytplayer_playlazy( delay )
  {
    //
    // Thanks to the anonymous person posted this tip:
    // http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
    //
    if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
    {
      window.clearTimeout( ytplayer_playlazy.timeoutid );
    }
    ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
  }
  function ytplayer_play( )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
    }
  }
  //
  // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
  // * Sets up handler for other events
  //
  function onYouTubePlayerReady( playerid )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.addEventListener( "onStateChange", "ytplayer_statechange" );
      o.addEventListener( "onError", "ytplayer_error" );
    }
  }
  //
  // State Change Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_statechange( state )
  {
    if ( state == 0 )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Error Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_error( error )
  {
       if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
ytplayer_playlist.push('OyrsKyAO2dg');
ytplayer_playlist.push('e14ZLzVnou0');
ytplayer_playlist.push('O_z5lzApEFc');
ytplayer_playlist.push('XcinB07mfOg');
ytplayer_playlist.push('nHN_EmsP2C0');
</script>



<br />
</strong></strong></a></strong>
</strong></strong></strong></strong>

</strong></strong><table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;"><big style="color: rgb(51, 51, 255);"><big><big>Upload your screenshot!</big></big></big><br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="color: rgb(51, 51, 255);">Have you got a screenshot you would
like to share ? Upload it with the forum below.</span><span style="color: rgb(51, 51, 255);"><br style="color: rgb(51, 51, 255);" />

      <span style="color: rgb(51, 51, 255);">Filesize limit is <big><span style="font-weight: bold;">490KB</span></big></span><br style="color: rgb(51, 51, 255);" />
      <span style="color: rgb(51, 51, 255);">JPG PNG GIF</span><br />
      </span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;">
      <form action="file-upload.php" method="post" enctype="multipart/form-data">Please select
file to upload: <input size="20" name="filename" type="file" /> <input value="Upload" name="submit" type="submit" /> </form>

      <br />
      </td>
    </tr>
  </tbody>
</table>
<strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><strong class="bbc"><br />
</strong></strong></a></strong></strong></strong></strong></strong></strong></strong></div>
<!-- content-wrap ends here --><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"> </strong></a></strong></strong></strong></strong></strong></strong></strong></strong></div>
<!--footer starts here-->
<div id="footer">
<p><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><br />
</strong></a></strong></strong></strong></strong></strong></strong></strong></strong></p>

</div>
<!-- wrap ends here --></div>

</body></html>
, but in my file manager, the updated file with your corrections to it is there..
gallery.php(in file manager:)

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><?php include_once("gallery/ki_include.php"); ?><?php echo $message; ?><?php echo $max_file_size_tag; ?><?php setlocale(LC_ALL, 'gb_GB', 'eng', 'english', 'gbr');
require_once "news/admin/functions.php";
require_once "news/admin/sx-config.php";
$sx_config = SXConfig();
?>





  
  <meta name="Description" content="Tsunami Guild" />

  
  <meta name="Keywords" content="Tsunami" />

  
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

  
  <meta name="Distribution" content="Global" />

  
  <meta name="author" content="Samuel Abbott"/>

  
  <meta name="Robots" content="index,follow" />

  
  <link rel="stylesheet" href="images/Envision.css" type="text/css" /><title>Tsunami</title></head><body>
<!-- wrap starts here -->
<div id="wrap"><!--header -->
<div id="header">
<h1 id="logo-text"><a href="index.php">Tsunami</a></h1>
<p id="slogan">A New wave is rising...</p>
<div id="header-links">
<p> <a href="index.html"><br />
</a> </p>
</div>
</div>
<!-- menu -->
<div id="menu">
<ul>
  <li id="current"><a href="index.php">Home</a></li>
  <li><a href="forum/">Forum</a></li>
  <li><a href="gallery.php">Gallery</a></li>
  <li><a href="apply.php">Apply</a></li>
  <li><a href="about.php">About us</a></li>
</ul>
</div>
<!-- content-wrap starts here -->
<div id="content-wrap">
<div id="sidebar">&nbsp;<big><big><span style="color: rgb(0, 0, 153); font-style: italic;"> Guild Notices!</span></big></big><br />
<br />
<br />
<span style="color: rgb(51, 51, 255);"><?php $tid = 1;
$user = "gnotice";
include "news/news.php";
?></span><br />
<div class="left-box">
<p><span style="color: rgb(51, 51, 255);">Random Screenshot:</span><br />
<img style="width: 166px; height: 130px;" alt="Random Image" src="gallery/ki_galleries/screenshots/randompic.php" /><br />
</p>
</div>

</div>
<div id="main">&nbsp;&nbsp;<a name="TemplateInfo"><span style="font-size: 21px; color: rgb(51, 51, 255);"><strong class="bbc" /></span><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><br />
</strong></strong></strong></strong></strong></strong></strong></strong></strong></a>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;">
      <div class="koschtitgallery" title="screenshots"><br />
      </div>
      </td>
    </tr>
  </tbody>
</table>
<strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><strong class="bbc">

<div class="demo-canvas">
  <div style="float: left; width: 371px; height: 300px;">
    <a name="ytplayer"></a>
    <div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  </div>
  <div style="float: left; width: 160px; height: 300px; overflow-y: scroll;">

    <div id="ytplayer_div2"></div>
  </div>
  <br style="clear: both;" />
  <br style="clear: both;" />
</div>
<script type="text/javascript" src="http://tsunami-guild.cz.cc/swfobject/swfobject.js"></script>
<script type="text/javascript">
  //
  // YouTube JavaScript API Player With Playlist
  // http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
  // Revision 1 [2009-10-12]
  //
  // Prerequisites
  // 1) Create following elements in your HTML:
  // -- a) ytplayer: a named anchor
  // -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
  // -- c) ytplayer_div2: container div for playlist
  // 2) Include SWFObject library from http://code.google.com/p/swfobject/
  //
  // Variables
  // -- ytplayer_playlist: an array containing YouTube Video IDs
  // -- ytplayer_playitem: index of the video to be played at any given time
  //
  var ytplayer_playlist = [ ];
  var ytplayer_playitem = 0;
  swfobject.addLoadEvent( ytplayer_render_player );
  swfobject.addLoadEvent( ytplayer_render_playlist );
  function ytplayer_render_player( )
  {
    swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
      'ytplayer_div1',
      '371',
      '300',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer_object'
      }
    );
  }
  function ytplayer_render_playlist( )
  {
    for ( var i = 0; i < ytplayer_playlist.length; i++ )
    {
      var img = document.createElement( "img" );
      img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
      var a = document.createElement( "a" );
      a.href = "#ytplayer";
      //
      // Thanks to some nice people who answered this question:
      // http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
      //
      a.onclick = (
        function( j )
        {
          return function( )
          {
            ytplayer_playitem = j;
            ytplayer_playlazy( 1000 );
          };
        }
      )( i );
      a.appendChild( img );
      document.getElementById( "ytplayer_div2" ).appendChild( a );
    }
  }
  function ytplayer_playlazy( delay )
  {
    //
    // Thanks to the anonymous person posted this tip:
    // http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
    //
    if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
    {
      window.clearTimeout( ytplayer_playlazy.timeoutid );
    }
    ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
  }
  function ytplayer_play( )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
    }
  }
  //
  // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
  // * Sets up handler for other events
  //
  function onYouTubePlayerReady( playerid )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.addEventListener( "onStateChange", "ytplayer_statechange" );
      o.addEventListener( "onError", "ytplayer_error" );
    }
  }
  //
  // State Change Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_statechange( state )
  {
    if ( state == 0 )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Error Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_error( error )
  {
       if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
<?php
$connection = mysql_connect('dbserver', 'dbusername', 'mypassword');
mysql_select_db('tsunamiguild_fom');
$result = mysql_query('SELECT youtube_id FROM queue_videos');
while ($row = mysql_fetch_assoc($result)) {
    echo 'ytplayer_playlist.push(\'' . $row['youtube_id'] . '\');' . PHP_EOL;
}
?>
</script>



<br />
</strong></strong></a></strong>
</strong></strong></strong></strong>
</strong></strong><table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;"><big style="color: rgb(51, 51, 255);"><big><big>Upload your screenshot!</big></big></big><br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="color: rgb(51, 51, 255);">Have you got a screenshot you would
like to share ? Upload it with the forum below.</span><span style="color: rgb(51, 51, 255);"><br style="color: rgb(51, 51, 255);" />
      <span style="color: rgb(51, 51, 255);">Filesize limit is <big><span style="font-weight: bold;">490KB</span></big></span><br style="color: rgb(51, 51, 255);" />
      <span style="color: rgb(51, 51, 255);">JPG PNG GIF</span><br />
      </span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;">
      <form action="file-upload.php" method="post" enctype="multipart/form-data">Please select
file to upload: <input size="20" name="filename" type="file" /> <input value="Upload" name="submit" type="submit" /> </form>
      <br />
      </td>
    </tr>
  </tbody>
</table>
<strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><strong class="bbc"><br />
</strong></strong></a></strong></strong></strong></strong></strong></strong></strong></div>
<!-- content-wrap ends here --><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"> </strong></a></strong></strong></strong></strong></strong></strong></strong></strong></div>
<!--footer starts here-->
<div id="footer">
<p><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><strong class="bbc"><a name="TemplateInfo"><strong class="bbc"><br />
</strong></a></strong></strong></strong></strong></strong></strong></strong></strong></p>
</div>
<!-- wrap ends here --></div>

</body></html>

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:11 pm
by Jonah Bron
That's because no PHP is passed to the browser. That PHP is just there to output what you see when you right-click > view source. You're not supposed to be able to see it.

In that case, it looks like it's working properly.

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:19 pm
by abbottsam1
:D , thats great to hear !!!
now i dont have to yell at my computer anymore :D

but just want to be able to answer my original question now ,
do you happen to have a little script handy that will let me let a user type the youtube_id in a box, and add it to my existing database?

THankyou so much for your help :D
i really apprectiate it:D

Sam..

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:27 pm
by Jonah Bron
Just create a simple HTML form (method="get") with an input box (name="youtube_id") and a submit button. On the target page, take $_GET['youtube_id'], and insert it into the database.

Code: Select all

$connection = mysql_connect('dbserver', 'dbusername', 'mypassword');
mysql_select_db('tsunamiguild_fom');
if (!isset($_GET['youtube_id']) || empty($_GET['youtube_id'])) {
    die('No id specified');
}
$youtube_id = mysql_real_escape_string($_GET['youtube_id']);
mysql_query('INSERT INTO queue_videos (youtube_id) VALUES ("' . $youtube_id . '")', $connection) or die(mysql_error());

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:32 pm
by abbottsam1
On the target page, take $_GET['youtube_id'], and insert it into the database.
how do you mean by this ?

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:36 pm
by Jonah Bron
That's demonstrated in the code I gave you.

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:41 pm
by abbottsam1
ooops :oops:
but hey :D thankyou so much for your help today :D
it was much much much apreciated :D

Sam.

Re: PHP Editor

Posted: Tue Oct 12, 2010 2:44 pm
by Jonah Bron
You're welcome. :)

Re: PHP Editor

Posted: Tue Oct 12, 2010 3:46 pm
by abbottsam1
ok , ran into another slight problem, being such a noob i am...
how do i run this script of yours , will i go about it like :

MY HTML PAGE, with INSERTUTUBE.PHP as the action.

Code: Select all

<form method="get" action="insertutube.php" name="youtube">&nbsp;&nbsp;<big><small><small>
http://i4.ytimg.com/vi/</small></small><big
style="text-decoration: underline;"><span style="font-style: italic;">w9ygYqj4rVM<br>
</span></big><small>2. paste it in the box below: and click
submit.<br>
<img style="width: 132px; height: 94px;" alt="Tsunami Tube"
src="images/tsutube.jpg"><br>
<input name="youtube_id"><br>
<br>
<button name="submit"><img style="width: 68px; height: 23px;"
alt="SUBMIT" src="images/submit.jpg"><br>
<br>
</button></small><big style="text-decoration: underline;"><span
style="font-style: italic;"></span></big></big></form>
or do i insert that bit of code in with this code ?

(sorry about the html there, Kompozer loves to add its <span>tags :banghead: )

Re: PHP Editor

Posted: Tue Oct 12, 2010 4:03 pm
by Jonah Bron
Yes. But, change

Code: Select all

<button name="submit">
To

Code: Select all

<button name="submit" type="submit">

Re: PHP Editor

Posted: Tue Oct 12, 2010 4:12 pm
by abbottsam1
Awesome , thanks a bunch man :D works great :D
(and i forgot to add the <?php ?> tags in my insertutube.php :D

Once again :D Thanks :D