-1

I have an "uploads" folder that according to the database with php and mysql shows some videos, the problem is that in localhost it works, but when I insert the files in the file manager of the host (000webhost), the host cannot recognize the path "uploads", this is full code, the problem is in the video src at the end of the code.

<?php
require_once("config.php");
$result=' ';
$cerca=$_POST["cerca"];
$sql = "SELECT * FROM artisti WHERE nome like '%".$cerca."%'";

$result = $conn->query($sql);

if ($result->num_rows > 0)
{
  //echo "<h1>Artisti trovato</h1>";
  while ($row = $result->fetch_assoc()) {
    $ID=$row["ID"];
    $nome=$row["nome"];
    $link=$row["link"];
    $album=$row["album"];
    //echo "<h2>ID: "."$ID"."</h2>";
    //echo "nome: "."$nome"."<br>";
  }
}
else {
  echo "nessun artista trovato";
  $conn->close();
  exit;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Utopia-Playlist</title>
    <!--Reset css per ogni broswer-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" integrity="sha512-NmLkDIU1C/C88wi324HBc+S2kLhi08PN5GDeUVVVC/BVt/9Izdsc9SVeVfA1UZbY3sHUlDSyRXhCzHfr6hmPPw==" crossorigin="anonymous" />
    <!--Script scroll-->
    <script src="https://unpkg.com/scrollreveal@4.0.0/dist/scrollreveal.min.js"></script>
    <!--Icone-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
    <!--Icona tab di google-->
    <link rel="icon" href="Fulmine viola bianco.png">
    
    
    <link rel="stylesheet" href="hero.css">
    <link rel="stylesheet" href="nav.css">
    <link rel="stylesheet" href="playlist1.css">


    <style>
        @import url('https://fonts.googleapis.com/css2?family=Overpass&display=swap');
        </style>
    
</head>
<body>
<!--NavBar-->
<header class="he">
    <h1 class="developers">Utopia Playlist</h1>
    <nav>
        <div class="listanav">
            <li class="icon"><a href="index.html">Home</a></li>
                <li><a href="#">Playlist <i class="fas fa-caret-down"></i></a>
                    <ul class="submenu">
                        <li><a href="consigli.html">Consigli</a></li>
                        <li>
                            <a href="playlist.html">Consigli-DV</a>
                        </li>
                        <li> <a href="top.html">Top 50</a></li>
                    </ul>
                </li>
                <li><a href="contact.php">Contattaci</a></li>
            </div>
            </div>

    </nav>
    <a href="loginpage.php"><button type="button" class="accedi">Accedi</button></a>
</header>

<!--Hero--> <!-- class="btn" -->
    <div class="hero">
        <div class="hero-cn scroll">
            <p class="intro-text">ASCOLTA I NOSTRI CONSIGLI!</p>
            <?php echo "<h1 class=grande-text>"."$nome"."</h1>"?>
            <?php echo "<a class=btn href=$album>Scopri di più</a>" ?>

        </div>

        <video autoplay muted loop class="vd">
            <source src="uploads/<?php echo $link?>" type="video/mp4" >
        </video>

    </div>
Dharman
  • 26,923
  • 21
  • 73
  • 125
Alvin
  • 1
  • **Warning:** You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/32391315) – Dharman May 22 '22 at 18:39

1 Answers1

0

maybe there are some that you should check again:

  1. The $link variable hasn't gotten the value it got
  2. Placement of folders is not the same right
  3. Check the connection whether it is connected to the hosting database or not
SlametS24
  • 26
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 22 '22 at 21:40