Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 995505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:44:04+00:00 2026-05-16T06:44:04+00:00

I have a site based on php/mySQL where publishers had inserted a lot of

  • 0

I have a site based on php/mySQL where publishers had inserted a lot of youtube videos in a specific database column copiyng/pasting youtube embed codes. There is a wide variance of the codes reflecting the variations google made during time. Different sizes of the player window is the main variation. Now I need to uniform all the windows, but I don’t know where to start. What I need to reach is something like a regexp to eliminate all the not necessary code from the various entries (i.e. convert all embed codes in their corresponding youtube url?) and then create a script to generate the player code runtime…
Some help to look where to start?
Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:44:05+00:00Added an answer on May 16, 2026 at 6:44 am

    New Complete Solution:

    <?php
    //your bad code which you want to sanitize
    $BadCode = '<object width="640" height="385">
    <param name="movie" value="http://www.youtube.com/v/TvJsRX9SKUo?fs=1&hl=it_IT"></param>
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/TvJsRX9SKUo?fs=1&hl=it_IT" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>
    </object>';
    
    
    //Get Youtube Video ID
    preg_match('#(?<=youtube\.com/v/)\w+#', $BadCode, $matches);
    $VideoID = $matches[0];
    
    
    //New Correct and consistent embed code template. Create whatever consistent template you want. Then all your videos will follow this template. Change the place where video-id appears as [VIDEOID]
    $template = '<object type="application/x-shockwave-flash" style="width:450px; height:366px;" data="http://www.youtube.com/v/[VIDEOID]?showsearch=0&amp;fs=1">
    <param name="movie" value="http://www.youtube.com/v/[VIDEOID]?showsearch=0&amp;fs=1" /><param name="allowFullScreen" value="true" />
    </object>';
    
    //Insert our VideoID into this template.
    $GoodCode = str_replace('[VIDEOID]', $VideoID, $template);
    
    //Display code for testing
    echo $GoodCode;
    
    //Update your database table (please change variables yourself)
    //mysql_query("update tablename set YoutubeCode = '".$GoodCode."' where ID={$ID}");
    ?>
    

    Old Summarized Answer:

    [Regex for extracting video ID]. After getting video ID, you have the video ID. Use this ID to generate a clean consistent code for all your videos. Then, update the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a php/mysql based application which has slightly different instances for a number
Using PHP and MySQL, I am integrating a site with a wiki based on
I have an PHP based Youtube clone system installed on our server. The same
I have an existing, non-framework-based PHP/MySQL website. It has a simple security model, with
I have a PHP based site with dynamic pages , such as /page.php?ID=1. The
I have an online game that is PHP & MySQL based (PHP 5.2.9 &
Scope: PHP-mysql based site, using memcached. Caching issue is mostly about prices. Because of
The Zend Framework based site I have been working on is now being migrated
I have an MVC-based site, which is using a Repository/Service pattern for data access.
I currently have a download site for my school that is based in .net.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.