Jump to content

PNewCode

Members
  • Posts

    315
  • Joined

  • Last visited

Community Answers

  1. PNewCode's post in PHP and Regex revisiting and stuck was marked as the answer   
    Update...
    For anyone that comes here to find an answer, I was making some coffee and it hit me... I should define the first part, then make it a full url to strip the video id, and THEN put it in the rest to get the title. And after about 20 min of mangling it, this is the solution that works

     
    $ytvideo1 = $link; $linkurl = "$ytvideo1"; parse_str( parse_url( $linkurl, PHP_URL_QUERY ), $vid ); preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $linkurl, $match); $youtube_id = $match[1]; $preurl = "https://www.youtube.com/watch?v=$match[1]"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $preurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); $document = htmlspecialchars($output); curl_close($ch); $line = explode("\n", $document); $judul = ""; foreach($line as $strline){ preg_match('/\<title\>(.*?)\<\/title\>/s', $strline, $hasil); if (!isset($hasil[0]) || $hasil[0] == "") continue; $title = str_replace(array("<title>", "</title>"), "", $hasil[0]); } echo $title; ////// This shows the title of the video from any youtube link  
  2. PNewCode's post in PHP Mysql and Javascript - Copy paste for loop was marked as the answer   
    Just to share, I found a completely different set up that works. This follows the rules that Requinix said, but structured different.

     
    <script> function myFunction(el) { var hidden = el.previousElementSibling; hidden.style.display = 'block'; hidden.select(); hidden.setSelectionRange(0, 99999) document.execCommand("copy"); hidden.style.display = 'none'; } </script> <input type='text' style='display:none;' value='NOW PLAYING: " . $row["movie"] . " - Requested By - " . $row["name"] . " - Link: " . $row["link"] . "'> <button onclick='myFunction(this)' >Copy</button>  
  3. PNewCode's post in force video full screen on rotation was marked as the answer   
    I found this handy litle gem after a 2 hr nap and 4 cups of coffee in case anyone else happens to find it useful. Added this then made an outside containing div. Works perfectly!

     
    <script> var launchFullScreen = function(el) { // alert('launching'); // var el = $el[0]; if (el.requestFullscreen) { console.log('requestFullscreen'); el.requestFullscreen(); } else if (el.mozRequestFullScreen) { console.log('mozRequestFullScreen'); el.mozRequestFullScreen(); } else if (el.webkitRequestFullscreen) { console.log('webkitRequestFullscreen'); el.webkitRequestFullscreen(); } else if (el.msRequestFullscreen) { console.log('msRequestFullscreen'); el.msRequestFullscreen(); } else { console.log('no full screen'); } }; var exitFullscreen = function() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } }; // window.addEventListener('orientationchange', function() { window.screen.orientation.onchange = function() { console.log(window.screen.orientation); if (this.type.startsWith("landscape")) { // document.querySelector("#containvid").webkitRequestFullscreen(); launchFullScreen(document.querySelector("#containvid")); } else { // document.webkitExitFullscreen(); exitFullscreen(); } }; var containvid = document.querySelector("#containvid"); var video = document.querySelector("video"); var controls = document.querySelector("#controls"); var play = document.querySelector("#play"); var fullscreen = document.querySelector("#fullscreen"); play.onclick = function() { if (video.paused) { video.play(); play.innerHTML = "pause"; } else { video.pause(); play.innerHTML = "play_arrow"; } }; fullscreen.onclick = function() { if (document.webkitFullscreenElement != containvid) { containvid.webkitRequestFullScreen(); window.screen.orientation.lock("landscape"); fullscreen.innerHTML = "fullscreen_exit"; } else { document.webkitExitFullscreen(); fullscreen.innerHTML = "fullscreen"; } }; // document.onwebkitfullscreenchange = function() { // if (document.webkitFullscreenElement != containvid) { // fullscreen.innerHTML = "fullscreen"; // } // }; </script> <div id="containvid"> <div id="twitch-embed"></div> </div>  
  4. PNewCode's post in echo an array to show selected images from mysql was marked as the answer   
    For anyone else that may come to see this, here is the solution. Credit goes to a friend that I just got lucky enough to rarely see online

     
    if (!empty($row["emotes2"])) { $selectedImages = $row["emotes2"]; // This should be a string like "3.png", "4.png", "5.png" $imageArray = explode(", ", $selectedImages); // Convert the string to an array foreach ($imageArray as $emotes2) { echo "<img src='img-picker/images/" . trim($emotes2, ' "') . "' width='35'/>"; } } else { echo ''; }  
  5. PNewCode's post in php mysql image upload issue was marked as the answer   
    I figured it out. I was trying to add stuff to the wrong if statement. Instead I just changed the following, and now it works

     
    if (isset($_POST["submit"])) { $pname = ""; if(!empty($_FILES["file"]["name"])){ $allowed_img = array('gif', 'png', 'jpg', 'jpeg');  
  6. PNewCode's post in php mysql date picker to varchar to date... Oh boy, this one might be a challenge was marked as the answer   
    @Barand I also just saw something about a date fetch and thought I'd give it a try. I can't believe that this worked. I just made it to work with my page. But I would very much appreciate some education on WHY this is working? I like to learn instead of just copy and paste stuff.

    $datefetch = date("m/d/Y");
    $sql = "SELECT * FROM `retirees` WHERE `birthday` = '$datefetch'";
  7. PNewCode's post in How to prevent direct url with php and mysql was marked as the answer   
    AND IT'S DONE!
    I want to thank everyone that gave so much awesome education and help on here. Between that and an unreal amount of research, I present to you the working solution. I hope this helps anyone else that might be at my level (inexperienced and new)

    I put this at the top of the page and TADA it works!

    First it checks if the person is logged in. If not then they are sent to the login page.
    Then when they return to this page, it checks if "yes" is in the "salecheck" column for their id
    If it is, then they see the rest of the page
    If it is not, then they get sent to a "nono.php" page that tells them they don't have access and the option to purchase the access
    Once they purchase it, then "yes" is entered in the database for their id, and they can see the contents of that page

    I COULD NOT HAVE DONE THIS WITHOUT YOU ALL! THANK YOU! (and now I need a nap)

    THANK YOU ALL AGAIN! I APPRECIATE YOU ALL VERY MUCH!!!
     
    <?php session_start(); include_once "configure.php"; if (!isset($_SESSION['id'])){ header("location: login.php"); }else{ $hostname = "localhost"; $username = "Removed for posting"; $password = "Removed for posting"; $dbname = "Removed for posting"; $conn = mysqli_connect($hostname, $username, $password, $dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } $user_id = $_SESSION['id']; $sql = "SELECT * FROM users WHERE id = '$user_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $modcheck = $row["salecheck"]; } } else { echo "0 results"; die(); } if($salecheck == "yes"){ }else{ header("location: nono.php"); } } ?> ////// here is the gobblty gook html that will show the extra sales perks on the same page as the scripting above //////  
  8. PNewCode's post in How can I trigger css on click? was marked as the answer   
    @requinixyes in a way. However I found a trick in the depth of the internet that makes it exactly how I want it (this might be what you were talking about I'm not sure). I added
     
    66% { opacity:0; } Between the 0% and 100% and it allows a delay. I had to lengthen the time of total animation to make it work but it's perfect.
×
×
  • 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.