Jump to content

Fluoresce

Members
  • Posts

    279
  • Joined

  • Last visited

Posts posted by Fluoresce

  1. I embed YouTube videos on my site.

     

    The problem is, the videos often get deleted by the user, which means that the videos obviously become unavailable on my site.

     

    This happens often, which means that I regularly have to look through my site, find unavailable videos and delete them.

     

    I am looking for an automated way of doing this.

     

    Here's what I've got so far:

    <?php
        $con = mysql_connect("", "", "");
        mysql_select_db("");
        $qry = "SELECT video_id FROM `table`";
        $run = mysql_query($qry, $con);    
        while($row = mysql_fetch_assoc($run)) {    
            $headers = get_headers("http://gdata.youtube.com/feeds/api/videos/{$row['video_id']}");
            if(!strpos($headers[0], '200')) {
                echo "Unavailable: {$row['video_id']}<br />";
                return false;
            }
            else {
                echo "Available: {$row['video_id']}<br />";
            }
        }
    ?>

    The code's very slow and doesn't work. It produces a list of available videos and then stops when it finds one that is unavailable. The problem is, the video that it says is unavailable is usually available, which means that it's getting it wrong.

     

    Is there a faster, more accurate way of doing it?

     

    Basically, I want a fast and accurate way of checking the availability of the thousands of videos in my database and I want to produce a list of the ones that are unavailable.

  2. Probably a stupid question . . .

     

    The MIME type in my php.ini file is set to text/html:

    default_mimetype = "text/html"

    But, because I use XHTML 1.0 Strict, the MIME type of my web pages is set to text/xml:

    <meta http-equiv="content-type" content="text/xml; charset=utf-8" />

    I should therefore change the php.ini MIME type to text/xml, right?

     

  3. Okay, here's what I've done:

    1) Encoded all of my pages in UTF-8 without BOM using Notepad++.

    2) Added this to my .htaccess file:

    IndexOptions +Charset=UTF-8

    3) Changed the default charset in my php.ini file to:

    default_charset = "utf-8"

    4) Specified my MySQL connections with:

    mysql_set_charset("UTF8", $connection);

    5) Set my databases to utf8_general_ci.

    6) Used this meta tag:

    <meta http-equiv="content-type" content="text/xml; charset=utf-8" />

    7) Added this to my external style sheet:

    @charset "utf-8";

    I'm guessing I've gone overboard. However, it all seems to work, so I'm happy. :happy-04:

     

    I thank you guys—especially Jacques1—for your assistance.

  4. No, you get the encoding which you've set in your editor. 

     

    I've just checked, and the editor that I use (Aptana Studio 2) has cp1252 set as the default encoding.

     

    What kind of trouble am I in, then? :confused:

     

    I assume that I should re-save all of my web pages as UTF-8 and then re-upoad them. Is that correct?

     

    Is there anything else that I should do?

     

    My setup looks like this:

     

    1) I've got this meta tag on all of my pages, at the top of the head element:

    <meta http-equiv="content-type" content="text/xml; charset=utf-8" />

    2) All of my MySQL connections include this:

    mysql_set_charset("UTF8", $connection);

    3) My database tables are set to utf8_general_ci.

     

    I still haven't specified UTF-8 headers. I want to do it on the server instead of using the head() function. Do I do it in my php.ini file or in my .htaccess file?

     

    Note that, when I check my headers, the Content-Type header just says "text/html". Shouldn't it also say UTF-8?

     

    And what about my CSS files? I heard that I have to encode them in UTF-8 as well.

     

    This is a very confusing subject for me. :shrug: I appreciate your help very much.

  5. One additional thing to mention, you need to ensure that when you create the document you need to ensure that your editor saves the document as UTF-8 as well. If you create and save your document in something like Windows-1252 but tell the browser that it's UTF-8 you'll still have issues because the literal curly-quote will not be encoded properly.

     

    This is a somewhat common issue to people who are new to character encoding. They will configure their page with the meta tag and/or header but neglect to ensure they are actually creating a UTF-8 page in the first place with their editor.

     

    That's confused me a bit. :confused:

     

    Let's say that I write something in MS Word and then I copy and paste it into my web page. Are the characters on that page now gong to be Windows-1252?

  6. Note that you should also declare the encoding in a Content-Type header. Using a meta element usually leads to the expected result, but it's somewhat paradox: The browser has to understand the document so that it can get the information which is necessary to understand the document. This only works under certain circumstances: The meta element itself must be ASCII-encoded, and it must be within the first 1,024 bytes of the document. There are no such issues with the Content-Type header. Actually, the meta element should only be used as a backup in case the user views the document offline (in which case the HTTP headers are not available).

     

    Why do you use text/xml as the content type, by the way?

     

    I use the content type text/xml because my doctype is XHTML 1.0 Strict. Is that wrong?

     

    This is what my doctype and <head> element looks like. Please tell me if you can see any problems.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
            <meta name="robots" content="index, follow" />
            <link rel="stylesheet" type="text/css" href="/mystyle.css" />
            <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
            <meta name="description" content="" />
            <meta name="keywords" content="" />
            <title></title>
        </head>        
        <body>

    "The meta element itself must be ASCII-encoded, and it must be within the first 1,024 bytes of the document."

     

    Sorry, I don't understand what you mean when you say that it has to be ASCII-encoded. The charset attribute is set to utf-8.

     

    Some of my pages have lots of PHP at the top. Does this mean that my content-type declaration might be outside of the first 1,024 bytes, or does PHP not count?

     

    "Note that you should also declare the encoding in a Content-Type header."

     

    Do you mean that I should put something like the following at the top of the page?

    <?php header(Content-Type: text/xml) ?>
  7. Thank you, Jacques1!

     

    I've learnt quite a bit off you in the past couple of days. ;D

     

    Please tell me if I've got this right . . .

     

    As long as I have this meta tag:

    <meta http-equiv="content-type" content="text/xml; charset=utf-8" />

    on my web pages, I can have literal curly quotes (which I will produce like this: Alt+0147 and Alt+0148) in the bodies of my web pages.

     

    In fact, I can have any UTF8 character.

     

    They will all be compatible in all browsers. It doesn't matter what browser they're using and what web fonts they have installed. No users will see strange characters.

     

    I do not have to use the curly quote HTML entities (“ and ”).

     

    Is that all correct?

  8. Quotation marks are confusing me.

     

    What do you guys use when it comes to quotation marks?

     

    In HTML attributes and throughout the bodies of my web pages, I use the HTML entity ("). For example:

    <a href="" title="Read "Article Name"">
    <p>In his new book, he says: "This is a quote."</p>

    I thought that this is the best practice.

     

    However, today, I read that it's perfectly safe to use straight quotes (") in the body, and that I should use the HTML entity only in HTML attributes.

     

    Is that correct?

     

    But what if I want to use curly quotes in the body instead of straight quotes? Should I always use the HTML entities for curly quotes (“ and ”), or can I also safely use the characters (“”)?

     

    I heard that straight quotes are safe in all browsers, even if you don't specify the character set of your web pages, but that curly quotes are only safe if you specify the character set or if you use the HTML entities.

     

    Is that true?

     

    And what about the <q> tag? Apparently, it's compatible with all browsers but they treat it differently.

  9. Thanks, Jacques1!

     

    You were right.

     

    I added:

    mysql_set_charset("utf8", $connection);

    and now the curly quotes, em dashes, etc., are submitted from my form to my database without being changed into strange characters.

     

    Curly quotes, em dashes, etc., can now also be displayed on my web pages (before, they would render as small diamonds with question marks inside).

     

    I used:

    echo mysql_client_encoding($connection);

    to check the character set of my MySQL connection. It said latin 1. Now it says utf 8.

     

    I appreciate your help. ;D

  10. I submit text to my MySQL database using a form on my site. When I look at the text in my database, sometimes, there are strange characters. The strange characters are caused by quotation marks, em dashes, apostrophes and foreign letters of the alphabet. I think that this only happens when the source of the text is a Windows program. I understand that this is a character encoding issue, but I don't fully understand the subject. I've spent the last few hours researching it, but it's only confused me.

     

    My site uses UTF-8 encoding:

    <meta http-equiv="content-type" content="text/xml; charset=utf-8" />

    The collation of my database is utf8_general_ci.

     

    My form looks like this:

    <form action="" method="post">
    </form>

    As you can see, an accept-charset="utf-8" attribute has not been specified.

     

     

    Questions

     

    1) I am guessing that my problem is that the Windows characters are being misinterpreted by my UTF-8 setup. Is that correct?

     

    2) If so, is there a way that I can safely convert the Windows characters to UTF-8 during the submission process?

     

    3) Should I also specify an accept-charset="utf-8" attribute on the form?

     

    4) When I paste the Windows text directly into my database without using the form, the characters save without turning into the strange characters. But they don't render properly on my site. Can't browsers identify Windows characters?

  11. You are storing the entire HTML code to your database? Why not just store the variable parameters separately and build the URLs dynamically. That makes it much more flexible. For example, you might just store three values: height, width and code. Then when you need to output the HTML you would build the entire iframe using those three values.

     

    Dude, why didn't I think of that!

     

    Thank you! :happy-04:

  12. I embed videos on my site. I submit the embed codes to my database using a form. The codes look like this:

    <iframe width="560" height="315" src="//www.youtube.com/embed/xDIgbjDGsOM?rel=0" frameborder="0" allowfullscreen></iframe>

    Before I submit each code, I have to change its width and height, and I have to add this:

    &showinfo=0

    after this:

    ?rel=0

    Is there a function that will allow me to do all of that simultaneously?

     

    I know about str_ireplace(). It will let me replace ?rel=0 with ?rel=0&showinfo=0, but I don't know how to simultaneously make the other changes.

     

    It's not helping that the embed code includes quotation marks.

  13. Yes. What if something changes, like you add a new feature.  Would you like to update 1 page of code or 9? You'd be basically duplicating code 9 times with small variances which is not what programmers should do. This is like saying you shouldn't have pagination and manually create 1 file for each page.

     

    Do you really need to rewrite the url for this part? Why not keep that part a querystring?

    /browse/1?category=video-documentaries&order=popularity

     

    Also, since you have newest-oldest (descending), oldest-newest (ascending)...why wouldn't you do the same for popularity?

    Good points!

     

    The thing that was disuading me from doing it all on one page was that, once I rewrite the URLs, they would seem like 9 separate pages anyway, all with the same content, albeit arranged in a different order. I therefore thought, Why not just do 9 separate pages? It would actually be easier. I didn't realise that I didn't have to rewrite the URLs to hide the querystring.

     

    Thanks for that!

     

    Yes, by "popularity", I meant from most popular to least popular.

     

    Thanks for the help, gentlemen.

  14. I think I get it:

    1. I'll construct a simple HTML form with radio buttons and a Submit button and put it on the page.
    2. Visitors will be able to select from the options and submit the form to the same page.
    3. The page will "GET" the parameters from the URL and create the SQL statements to be used in selecting the content and building the pagination.

    Does that sound right?

     

    But there's something that's confusing me.

     

    I have used mod_rewrite to rewrite my URLs. At the moment, to visitors, the URL of my Browse page looks like this:

     

    /browse/page_number

     

    But the actual URL looks like this:

     

    /browsevideos.php?page=page_number

     

    I want to give visitors 3 content options:

    1. videos and documentaries
    2. just videos
    3. just documentaries.

    I also want to give them 3 sorting options:

    1. newest-oldest
    2. oldest-newest
    3. popularity.

    This means that there will be 9 possible arrangements of the content, and each arrangement will have its own URL, for example:

     

    /browsevideos.php?content=justvideos&sort=newest_oldest&page=page_number

     

    I then have to rewrite the URLs, for example:

     

    browse/videosanddocumentaries/newest-oldest/page_number

    browse/videosanddocumentaries/oldest-newest/page_number

    browse/videosanddocumentaries/popular-unpopular/page_number

     

    browse/justvideos/newest-oldest/page_number

    browse/justvideos/oldest-newest/page_number

    browse/justvideos/popular-unpopular/page_number

     

    browse/justdocumentaries/newest-oldest/page_number

    browse/justdocumentaries/oldest-newest/page_number

    browse/justdocumentaries/popular-unpopular/page_number

     

    Is that correct?

     

    If so, what are the consequences for SEO? Wouldn't there be duplicate content issues?

  15.  

    You could do something like this?

    $documentaries = array("A Great Film","A Not So Great Film","Brilliant Film","Chirpy Film");
    $currentHeader = '';
    
    foreach($documentaries as $documentary){
    
      $headerCheck = substr($documentary,0,1);
    
      if($currentHeader!==$headerCheck){
        echo '<h2>'.$headerCheck.'</h2>';
      }
    
      $currentHeader = $headerCheck;
    
      echo $documentary;
      echo "</br>";
    
    }
    

    Thanks for trying. Your code was helpful.

  16.  

    Where does $counter come from? It looks like that should be $count?

     

    Not a big deal, but you could use is_numeric() here (I think it reads a little better):

    if(strpbrk($currLetter, '0123456789') == true) {
    if (is_numeric($currLetter)) {

    Good spot regarding $counter!

     

    Thanks for is_numeric(). Used it.

     

    Thanks also for the strtoupper() advice.

  17. Okay, I seem to have done it.

     

    What do you guys think?

     

    Yes, I know I'm an amateur! I only know if/else statements!

    $con = mysql_connect("", "", "") or handle_mysql_error("Con failed! ");
    mysql_select_db("") or handle_mysql_error("Select db failed! ");
    $sql = "SELECT title, link FROM `doc_table` ORDER BY title ASC";                    
    $query = mysql_query($sql, $con) or handle_mysql_error("Query failed! ");
    echo"<h1>Full List</h1>";
    echo "<div id=\"floated-left\">";
    $prevLetter = '';
    $count = 0;
    while($row = mysql_fetch_assoc($query)) {                            
         $currLetter = substr($row['title'], 0, 1);                                
         if(strpbrk($currLetter, '0123456789') == true) {
              $currLetter = '0-9';
         }                                
         if($currLetter !== $prevLetter) {
              if($prevLetter) {
                   if($counter == 14) {
                        echo "</ol>";
                        echo "</div><!--Close floated-left-->";
                        echo "<div id=\"floated-right\">";
                   }
                   else {
                        echo "</ol>";
                   }
              }
              echo "<h3>$currLetter</h3>";
              echo "<ol>";
              $prevLetter = $currLetter;
              $count++;
         }                                                                
         echo "<li><a href=\"{$row['link']}\">{$row['title']}</a></li>";
    }
    echo "</ol>";
    echo "</div><!--Close floated-right-->";
    echo "<div class=\"clear\"></div><!--Clear floated-left and floated-right-->";
  18. I have a website on which I embed videos. Whenever I embed a video, I add a description. The description is mainly for the search engines. Without the description, the page would only contain the embedded video, the site navigation and links to related videos.

    Having to write a description for each video is tedious. I am therefore considering omitting the video descriptions. But, then, my pages would only contain videos and links.

    I am very aware of the importance of textual matter for SEO. However, browsing the Web, I have found quite a few very popular websites that only present videos and no text whatsoever apart from video comments.

    What do you think would happen if I were to stop adding video descriptions? Would it be SEO suicide?

  19. Looks and works pretty good.

     

    Some suggestions:

    Create a search for your videos.

    Make your site logo clickable back to your home page.

    Make video preview images clickable to your video pages.

    It was odd to see http://www.selfhelpvids.com/browse/1 versus only http://www.selfhelpvids.com/browse/, maybe can change it without page numbering and redirect to page 1

    Your links for content are ok...I suppose...don't care for the number being included, might want to think of the future though and if really want those included in there when numbers begin to grow. Although this does help preventing a duplicate named post link. I guess it really depends just how many videos planning on doing.

    Video list page can become quite large if continue adding more videos.

    Category: Vids » Intelligence , does having Vids >> have any purpose?

    You may want your About and Contact page up top with the other tabs, could be missed in the footer.

     

    Those are my observations, not bad though.

     

    Brilliant review!

     

    I will certainly create a video search facility.  Either that or I will wait until my site gets more popular and get Google Custom Search.

     

    I also plan on adding a video rating feature and commenting feature on the video page.

     

    "Vids >>" differentiates videos from documentaries, which begin with "Docs >>".

     

    I didn't want to include the number in the URL, either, but it allows users to find the video with just the number. In other words, to find a specific video, users don't have to enter the whole address, just the number. The number also helps me to locate the video in the database.  It will not get very large because I will only be adding what I feel are high-quality videos to the site.

     

    Thank you for your suggestions and feedback! ;D

  20. Looks good to real good to me and it worked well, I didn't read your last sentence of the first post so I was missing the link to the site at first. The logo on the bottom may be too big but this is just a small small issue to me.

     

    Thank you for the feedback!

     

    Anyone else got an opinion?

     

    If the professionals (i.e., many of you guys) say that it's of an okay standard, then I will be very happy.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.