Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Page 1 of 5 123 ... LastLast
Results 1 to 15 of 69

Thread: Need Help

  1. #1

    Need Help

    I've written another thread sort of like this one; But I'm wondering that when you have a MySQL database for multiple wmv files; that on an average are about 40 MB each and their are about 20 or more on the site now; Is it usually custom to actually have the videos stored on the server and the video file names in the database to display them on the site? And if so; what code or code combination would be needed to upload them from an FTP program (backend) to the server and then have them appear on a certain web-site page on an alternating table witout writing anymore code for each one uploaded or added to the site? And if this is a more logical way to do it; what code would fetch the file when the front-end users click to play it? It seems to me that there must be code that would connect the file name from the database and fetch the video file from the server and play it. Am I making sense? I am new at MySQL and know very little about how to use it! Also if I were to connect to the site through an FTP program and delete a video file; would there also be a certain prefered code for that? This is the site www.viewtheword.org It's the site that belongs to the church I attend and I'm trying to understand how to work on it and how it works and maybe some code examples? I'm sorry for all the digressing! I'm terribly in need of some information! I would really appreciate any help you could give me!!!!!

  2. #2
    1,627
    posts
    hugeExplosions = true;
    Yes, it's usually best to stick the file content on the server drive in a specific location and then store the path to the file and filename in the database.

    To upload the files you would usually write a script which would do the following:

    Retrieve the actual file (using the standard upload functionality)
    Save the file to a specific directory and rename it with a unique identifier
    Insert a row into the database with a path to this newly named file and any other information you need about the file

    To display the file/list the files available:

    Read the list of files/a specific file from the database (i.e. a user visiting the list page would query all rows, a user visiting a particular files information page would only need a single row of data)
    Display the information on the page using a loop for a list (I usually create list templates and write a renderer for the template for code re-usability)
    Links and stuff can be retrieved from the data you inserted in the first step
    The fetching of the file would simply be an embed tag or an embedded player of your choice with the path supplied from the data row for the specific file.

    I wouldn't connect to the site to delete a video - you should do it via your administration back end (write a few pages to maintain the data) - otherwise your data rows will still exist on the server, but the video file won't and you will get broken links.
    MS Paint FTW!


  3. #3
    You will encounter problems in the file size during upload. Only if you have acces to the server or when the server is not running in savemode you can do something about it.
    Because the upload of these files will generate a time_out or it would exceed the maximum filesize for uploaded files....
    the world is getting more complex because people need simple solutions

  4. #4
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    You can change the maximum script execution time and the maximum upload size in the php.ini file, so he wouldn't have to worry about that. I maintain web-apps that have a maximum file upload size of 500mb.

  5. #5
    Thank you Charleh, borob and jwilliam for your input! I've had a very dificult time understanding the relationship between the Linux Rehat system; the Apache server and MySQL on the churches website! We have a site that we paid to have developed which alows me to upload through Smart Ftp and delete through Smart Ftp; but I have had a hard time figuring out the sceme of code! I do textual changes through the site's c-panel (i guess that would be the front end)? Each page has a text editor in c-panel and it shows up on the pages when i update! The videos on the other hand are uploaded and deleted with Smart Ftp and show up in an alternating table or disapear if deleted! I'm just trying to get a grip on how I can better take care of that site or write code if need be. The site in this thread is different from the one listed above. It is www.viewtheword.org and I wrote the site above trying to learn how to create a site like viewtheword.org ! The MySQL has stumped me and the site I wrote is www.cofchristsh.org . It has all the code and videos uploaded through Smart Ftp. Thanks for your help! And if you could recommend any learning tools; I'd appreciate it very much!

  6. #6
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    It sounds like (but I'm usually wrong when I begin a sentence like that) the guy who originally maintained the site would upload his movies with ftp (Smart FTP) and then manually update the database to handle his new file. What you need is an admin panel that uploads the file and updates the database automatically for new movies and does the opposite for deletions. You'll need to learn php and mysql to do this yourself.

    If you don't want to take this on yourself, send me a PM and I'll help you.

  7. #7
    I'm sorry! The site has an admin panel and that is the way I was told by the developer to edit the text and images on the pages. I said c-panel earlier; but c-panel is just a place that I can get a count of visitors and technical info. The admin is what I use on front-end. The developer never uploaded the video; He taught me how to do it through Smart Ftp only and to delete videos through Smart Ftp only! It works that way; I just cannot figure out the code relationship between the MySQL database and the Apache/Red Hat Linux system! Any suggestions or tools who be most welcome! Thank you very much for your help! I've made it as far as coding with xhtml and css and a little dash of php using someone elses php script for an e-mailer! So you can see I'm very new and trying to get the concept of this type of site in my head so I could save the church future expenses and maybe learn a thing or two in the process! Thanks!

  8. #8
    1,627
    posts
    hugeExplosions = true;
    Well let's make the terminology clear first!

    Your front end is the presentation layer - i.e. the site
    The back end is the techincal layer such as the database and the administration pages

    Let me get this right though, it sounds to me like you simply need to upload a video via Smart FTP for it to appear on your site..? Is this the case? If not what do you need to do once you've uploaded a vid?
    MS Paint FTW!


  9. #9
    Quote Originally Posted by Charleh View Post
    Well let's make the terminology clear first!

    Your front end is the presentation layer - i.e. the site
    The back end is the techincal layer such as the database and the administration pages

    Let me get this right though, it sounds to me like you simply need to upload a video via Smart FTP for it to appear on your site..? Is this the case? If not what do you need to do once you've uploaded a vid?
    Thank you! I do lack in terminology as well! I'm just trying to get started on learning the ropes! The site I'm referring to has been running great for about two years now; but it did have a problem about 3 years ago and every since; I've made it a mission to learn the developing part of it so that we (the Church) would not have to pay the high cost to a programmer/developer if and when another problem arises! I know some xhtml and css; but I need to learn how to script in PHP+MySQL and how to tie it all together! I need a simple script that would help me to locate a certain place on a page and add content by adding it to a MySQL database and fetch it to the page when uploaded through Smart Ftp! It seems to me that there should be a container on the page and a PHP script that would post the data to it. And a PHP script that would put the data into the database and a script that would fetch it. Is there a simple script that I can learn the PHP/ MySQL /Apache relationship with; and build from? Any info would really be appreciated!!!!

  10. #10
    1,627
    posts
    hugeExplosions = true;
    Well I'm trying to figure out what you currently do to get videos up on the page - or is that the problem that you can't get the videos up?

    I can explain the relationship between the systems if that will help.

    The Apache software sits on the server PC and serves pages - the software will have an installation of PHP. When a page is requested, the Apache server will check to see the file extension of the requested page. If it's a regular HTML file, it will send the HTML file contents to the requester.

    If it's a PHP file (you can choose which extensions are parsed by the PHP engine but it's usually any files with a .php extension) the Apache server passes the page contents to the PHP software engine. The PHP engine processes the file, runs any code it finds in the file then modifies the page in memory accordingly - it finally strips out any PHP code and sends the page back to the Apache server which then forwards the now changed page to you.

    The PHP scripts can interact with the MySQL server as PHP comes with a MySQL library and with certain functions you can retrieve data from MySQL with PHP scripts.

    For instance, the list of videos on your site could be created with the following steps:

    Create a PHP page which has an area you wish the video list to be displayed, in that area put some PHP script which will connect to the database and query the (hypothetical) 'videos' table. The script will grab all the information from the table. This information is now held in memory and can be manipulated.

    The most common method of getting a list onto a page is to start looping through the data row by row (PHP has a mysql_fetch_row() function which can do this) and for each row output some HTML (the final aim being to build a <table> which contains the data)

    So your script may be something like

    PHP Code:
    // Let's assume we have the data in a variable called $data
    echo '<table>'// Start an HTML table
    while ($row mysql_fetch_row($data)) { // While there is a data row to read put the data in the $row variable
      
    echo '<tr>'// Add a new HTML row
      
    echo '<td>Here is the video name' $row["video_name"] . '</td>'// Add a new HTML table cell and fill it with the video name, then close the cell tag
      
    echo '</tr>'// Close the HTML row tag
    }
    echo 
    '</table>'// Close the table 
    The output should be an HTML table containing the video names

    The actual HTML will be something like

    <table><tr><td>Some video</td></tr><tr><td>some other video</td></tr></table>

    Try pasting this into a text document and saving it with an HTML extension, you can then view it in internet explorer and it should be a table.

    Of course you will want a link to the video or a page where the video will be displayed. Usually you would either save the path to the video file in your database and output this as an HTML link, or create a separate page which displayed a single video, passing the 'video_id' in via the querystring

    e.g. www.yoursite.com/view_videos?video_id=15

    I would download the PHP manual and have a read first off to familiarise yourself with what it actually does.
    MS Paint FTW!


  11. #11
    Quote Originally Posted by Charleh View Post
    Well I'm trying to figure out what you currently do to get videos up on the page - or is that the problem that you can't get the videos up?

    I can explain the relationship between the systems if that will help.

    The Apache software sits on the server PC and serves pages - the software will have an installation of PHP. When a page is requested, the Apache server will check to see the file extension of the requested page. If it's a regular HTML file, it will send the HTML file contents to the requester.

    If it's a PHP file (you can choose which extensions are parsed by the PHP engine but it's usually any files with a .php extension) the Apache server passes the page contents to the PHP software engine. The PHP engine processes the file, runs any code it finds in the file then modifies the page in memory accordingly - it finally strips out any PHP code and sends the page back to the Apache server which then forwards the now changed page to you.

    The PHP scripts can interact with the MySQL server as PHP comes with a MySQL library and with certain functions you can retrieve data from MySQL with PHP scripts.

    For instance, the list of videos on your site could be created with the following steps:

    Create a PHP page which has an area you wish the video list to be displayed, in that area put some PHP script which will connect to the database and query the (hypothetical) 'videos' table. The script will grab all the information from the table. This information is now held in memory and can be manipulated.

    The most common method of getting a list onto a page is to start looping through the data row by row (PHP has a mysql_fetch_row() function which can do this) and for each row output some HTML (the final aim being to build a <table> which contains the data)

    So your script may be something like

    PHP Code:
    // Let's assume we have the data in a variable called $data
    echo '<table>'// Start an HTML table
    while ($row mysql_fetch_row($data)) { // While there is a data row to read put the data in the $row variable
      
    echo '<tr>'// Add a new HTML row
      
    echo '<td>Here is the video name' $row["video_name"] . '</td>'// Add a new HTML table cell and fill it with the video name, then close the cell tag
      
    echo '</tr>'// Close the HTML row tag
    }
    echo 
    '</table>'// Close the table 
    The output should be an HTML table containing the video names

    The actual HTML will be something like

    <table><tr><td>Some video</td></tr><tr><td>some other video</td></tr></table>

    Try pasting this into a text document and saving it with an HTML extension, you can then view it in internet explorer and it should be a table.

    Of course you will want a link to the video or a page where the video will be displayed. Usually you would either save the path to the video file in your database and output this as an HTML link, or create a separate page which displayed a single video, passing the 'video_id' in via the querystring

    e.g. www.yoursite.com/view_videos?video_id=15

    I would download the PHP manual and have a read first off to familiarise yourself with what it actually does.


    I convert the videos; which are actually sermons to 40 MB wmv files and they upload just fine with Smart Ftp! I'm just trying to come to grips with how the site is coded so that; if and when future problems arise; I can take care of the repair instead of having to pay the high cost of having a developer fix the situation! I was told by the original developer how to upload the wmv files and it is all through Smart Ftp. Once they upload; they appear on the sermons page in an alternating table. If i delete them through Smart Ftp; they automatically delete from the table! Then when it comes to text and images; all this is done through the admin part of the hosting site with no scripting at all! So all the videos are uploaded through Smart Ftp and deleted through Smart Ftp (no scripting required). I thank you a lot! I believe that the script and info that you've given me; will help me to understand and build from in my knowledge of how the code works between the server and database!!! If you want; visit the site- www.viewtheword.org Thank you very much for your input and I apologize for all the digressing!!! I'm disabled; cannot sit long enough in a class to learn; and have had to pick up on things up at my leisure!!!! So far I've read numerous books articles etc. and have not been able to grasp on to; how to write a script that communicates with the database and server yet that will do what the code on this site does!!! Thanx a million!!!

  12. #12
    I thank everyone who has offered their assistance! These blogs are great! I was even told by the developer of the site that I'm trying to understand; that he had learned quite a bit from forums! Unfortunately he has since moved on to bigger and brighter things or else I would be pumping him for all this information instead if worrying you all to death! I have a site with videos in contrast to this one in question. It is my practice site to help me learn. I have only used xhtml and css on this site with a borrowed PHP mailer script and now I'm trying to move things up a notch to enable me to get familiar with MySQL and PHP! So all your help has been great and I hope to not wear out my welcome!!! The other site in question has thrown me for a loop considering that it has a MySQL database; xhtml; PHP; Javascript and a flash banner embeded in the index page not to mention the wmp embeded in the sermons page!!! So once it clicks with me; I know that all this searching and your help will pay off!!! Thank you all for your comments and your patience!!!! I'm truly a newbie!!!! If you would like to look at the practice site I've constructed; it is www.cofchristsh.org Thanx!!!!!!!

  13. #13
    1,627
    posts
    hugeExplosions = true;
    No problem. So to sum up...my guess is that the site works like this:

    When the page with the videos is run the PHP script looks in the videos directory and picks up all available files. It then splits the filename of each file into 3 seperate pieces using the underscore (_) character as the seperation point.

    These three bits of information are then used to compile a table using a similar method to the script I described before with the links being created etc.

    Each link takes you to the same page, the only difference is the querystring specifies a different video filename and a viewing speed.

    You can open view.php from the web server and the main index page (probably index.php but I can't be sure) to view the PHP code - post it here if you want and I can dissect it for you.

    To explain how your view.php page works:

    The view.php page has a video viewer embedded in the page. It's a standard microsoft video viewer control and should work on any computer with Internet Explorer.

    The querystring actually used to get to the page affects what is visible on the page

    e.g.

    http://www.schofchristsermon.com/vie...01-08_Honoring Our Great GOD_GODs WORD-Dwayne Whitley.wmv

    As you can see, the actual page used is view.php and the rest of the link contains the information which is fed to the page you are visiting

    Everything after the ? is a query string parameter. These are fed to the server when the page is requested, and the PHP engine can use them however it wants. The parameter name is first, followed by an = then the value follows. Each parameter pair is seperated by an &. So in this case you have the speed=highspeed or speed=dialup followed by the file=some_sermon_file.wmv.

    There are two main ways to get user input across from the client (you) to the server (web server/PHP). This method (querystring) is usually known as a HTTP GET. The other method is an HTTP POST which happens when you are filling in an online form. You click 'submit' and the information does get sent to the server, but you can't see what got sent in the browser. Anyway, back to the HTTP GET as this is what is being used...

    When you request a PHP page the parser has access to two global variables $_GET and $_POST. These are arrays (lists of values) which contain the values in the querystring and form content. You won't need to worry about $_POST for now as it's not used on this page

    The values in these arrays have keys (a key identifies which data you want to use in an array) which match the query string parameter names. So for the link in the example above the two keys would be

    $_GET["speed"];

    and

    $_GET["file"];

    The values contained in these array keys would be 'dialup' and '12-01-08_Honoring Our Great GOD_GODs WORD-Dwayne Whitley.wmv' respectively.

    These two values are passed to the video viewer when the page is constructed so that it points to the right video for the right speed (two settings the video player can have), and voila!

    Pretty simple in practice once you get your head round how the web stuff works.
    Last edited by Charleh; December 3rd, 2008 at 01:37 PM.
    MS Paint FTW!


  14. #14

    You are G _ O _ O _D!!!!!!

    Quote Originally Posted by Charleh View Post
    No problem. So to sum up...my guess is that the site works like this:

    When the page with the videos is run the PHP script looks in the videos directory and picks up all available files. It then splits the filename of each file into 3 seperate pieces using the underscore (_) character as the seperation point.

    These three bits of information are then used to compile a table using a similar method to the script I described before with the links being created etc.

    Each link takes you to the same page, the only difference is the querystring specifies a different video filename and a viewing speed.

    You can open view.php from the web server and the main index page (probably index.php but I can't be sure) to view the PHP code - post it here if you want and I can dissect it for you.

    To explain how your view.php page works:

    The view.php page has a video viewer embedded in the page. It's a standard microsoft video viewer control and should work on any computer with Internet Explorer.

    The querystring actually used to get to the page affects what is visible on the page

    e.g.

    http://www.schofchristsermon.com/vie...01-08_Honoring Our Great GOD_GODs WORD-Dwayne Whitley.wmv

    As you can see, the actual page used is view.php and the rest of the link contains the information which is fed to the page you are visiting

    Everything after the ? is a query string parameter. These are fed to the server when the page is requested, and the PHP engine can use them however it wants. The parameter name is first, followed by an = then the value follows. Each parameter pair is seperated by an &. So in this case you have the speed=highspeed or speed=dialup followed by the file=some_sermon_file.wmv.

    There are two main ways to get user input across from the client (you) to the server (web server/PHP). This method (querystring) is usually known as a HTTP GET. The other method is an HTTP POST which happens when you are filling in an online form. You click 'submit' and the information does get sent to the server, but you can't see what got sent in the browser. Anyway, back to the HTTP GET as this is what is being used...

    When you request a PHP page the parser has access to two global variables $_GET and $_POST. These are arrays (lists of values) which contain the values in the querystring and form content. You won't need to worry about $_POST for now as it's not used on this page

    The values in these arrays have keys (a key identifies which data you want to use in an array) which match the query string parameter names. So for the link in the example above the two keys would be

    $_GET["speed"];

    and

    $_GET["file"];

    The values contained in these array keys would be 'dialup' and '12-01-08_Honoring Our Great GOD_GODs WORD-Dwayne Whitley.wmv' respectively.

    These two values are passed to the video viewer when the page is constructed so that it points to the right video for the right speed (two settings the video player can have), and voila!

    Pretty simple in practice once you get your head round how the web stuff works.




    Yes; Yes; and Yes!!!!!! You are definately good!!! Thank you! My sermons are as such- 12-01-08_Sermon Name.wmv_Preachers Name. I do 1 for highspeed progressive download and another for dial-up progressive download which buffers and seems to play only with ie and wmp! When I upload; I must upload one for each speed with a public_html/sermons/dialup folder and a public_html/sermons/highspeed folder! They must match in date_name.wmv_preacher and then they both appear on the view sermons page of the site! I will dig a little and post the script you asked for! May be a little later before I get the time to search it out! Sounds like you are on he ball!!! Great work!!!! Thanx!!!!

  15. #15
    I have a lot of code!!! Here is view.php
    <?php
    require_once("sources/config.php");

    function browser_detection( $which_test ) {

    // initialize the variables
    $browser = '';
    $dom_browser = '';

    // set to lower case to avoid errors, check to see if http_user_agent is set
    $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';

    // run through the main browser possibilities, assign them to the main $browser variable
    if (stristr($navigator_user_agent, "opera"))
    {
    $browser = 'opera';
    $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "msie 4"))
    {
    $browser = 'msie4';
    $dom_browser = false;
    }

    elseif (stristr($navigator_user_agent, "msie"))
    {
    $browser = 'msie';
    $dom_browser = true;
    }

    elseif ((stristr($navigator_user_agent, "konqueror")) || (stristr($navigator_user_agent, "safari")))
    {
    $browser = 'safari';
    $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "gecko"))
    {
    $browser = 'mozilla';
    $dom_browser = true;
    }

    elseif (stristr($navigator_user_agent, "mozilla/4"))
    {
    $browser = 'ns4';
    $dom_browser = false;
    }

    else
    {
    $dom_browser = false;
    $browser = false;
    }

    // return the test result you want
    if ( $which_test == 'browser' )
    {
    return $browser;
    }
    elseif ( $which_test == 'dom' )
    {
    return $dom_browser;
    // note: $dom_browser is a boolean value, true/false, so you can just test if
    // it's true or not.
    }
    }


    $user_browser = browser_detection('browser');

    if ( $user_browser == 'msie' or $user_browser == 'msie4')
    {
    ?>
    <!-- begin embedded WindowsMedia file... -->
    <table border='0' cellpadding='0' align="center">
    <tr><td>

    <OBJECT ID="mediaPlayer" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" STANDBY="Loading Microsoft Windows Media Player components..." TYPE="application/x-oleobject" width="320" height="285">
    <PARAM NAME="fileName" VALUE="<? echo SITE_ADDRESS."sermons/".$_GET['speed']."/".str_replace("%20", " ", $_GET['file']);?>">
    <PARAM NAME="animationatStart" VALUE="true">
    <PARAM NAME="transparentatStart" VALUE="true">
    <PARAM NAME="autoStart" VALUE="true">
    <PARAM NAME="showControls" VALUE="true">
    </OBJECT>




    </td></tr>
    <!-- ...end embedded WindowsMedia file -->
    <!-- begin link to launch external media player... -->
    <tr><td align='center'>

    <!-- ...end link to launch external media player... -->
    </td></tr>
    </table>
    <?
    }

    else
    {
    ?>
    <!-- begin embedded WindowsMedia file... -->
    <table border='0' cellpadding='0' align="center">
    <tr><td>

    <object id="MediaPlayer1" width=180 height=200
    classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
    standby="Loading Microsoft® Windows® Media Player components..."
    type="application/x-oleobject" align="middle">
    <param name="FileName" value="Server/file">
    <param name="ShowStatusBar" value="True">
    <param name="DefaultFrame" value="mainFrame">
    <param name="autoStart" value="true">
    <embed type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" src="<? echo SITE_ADDRESS."sermons/".$_GET['speed']."/".str_replace("%20", " ", $_GET['file']);?>" align="middle" defaultframe="rightFrame" width="320" height="285" showstatusbar=true>
    </embed>
    </object>

    </td></tr>
    <!-- ...end embedded WindowsMedia file -->
    <!-- begin link to launch external media player... -->
    <tr><td align='center'>

    <!-- ...end link to launch external media player... -->
    </td></tr>
    </table>
    <?
    }

    ?>


    *There are 4 more PhpBACKend files in the config. folder
    Last edited by Wantabe; December 6th, 2008 at 11:13 PM. Reason: To note extra PHP

Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012