0

So basically I want to fetch a youtube video id in PHP from URL and put it into a MySQL table, how can I achieve that?

I have this for the moment : (note that the fetched id is define by $vidid)

    <?php 
$conn = mysqli_connect('localhost', 'root', '', 'test');



if (!$conn) {
  die("Error connecting to database: " . mysqli_connect_error($conn));
  exit();
}

// sql to create table
$sql = "CREATE TABLE vidid (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
)";

if ($conn->query($sql) === TRUE) {
    echo "Table vidid created successfully";
} else {
    echo "Error creating table: " . $conn->error;
}

$conn->close();

?>

1 Answers1

0

All can be done by parse_url() http://php.net/manual/en/function.parse-url.php

P.S. Do not mix OOP with procedural.

indianiso1
  • 64
  • 4