<?php
include('core.php';
$con=mysqli_connect("localhost","username","pass","db");
if (!$con)
{
die('Connection Error (' . mysqli_connect_errno() . ' '
. mysqli_connect_error());
}
$title=songtitle(); //taken from core.php
echo "Now playing: $title ";
echo "<br /><br />";
$sep = explode('-', $title);
echo "Album: $sep[0] <br /> Song: $sep[1] <br /> Artist: $sep[2]";
echo "<br /><br />";
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$res = "SELECT `url` FROM `songs` WHERE (`album` = '" . $album . "' AND `title` = '" . $song . "' AND `artist` = '" . $artist . "'"; // I am pretty sure something is wrong in this line.
$sql = mysqli_query($con,$res);
$row = mysqli_fetch_array($sql,MYSQLI_ASSOC);
print $row["url"]; //No RESULT
mysqli_free_result($sql);
mysqli_close($con);
?>
<?php
include('core.php';
$con=mysqli_connect("localhost","username","pass","db");
if (!$con)
{
die('Connection Error (' . mysqli_connect_errno() . ' '
. mysqli_connect_error());
}
$title=songtitle(); //taken from core.php
echo "Now playing: $title ";
echo "<br /><br />";
$sep = explode('-', $title);
echo "Album: $sep[0] <br /> Song: $sep[1] <br /> Artist: $sep[2]";
echo "<br /><br />";
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$res = "SELECT `url` FROM `songs` WHERE (`album` = '" . $album . "' AND `title` = '" . $song . "' AND `artist` = '" . $artist . "'"; // I am pretty sure something is wrong in this line.
$sql = mysqli_query($con,$res);
$row = mysqli_fetch_array($sql,MYSQLI_ASSOC);
print $row["url"]; //No RESULT
mysqli_free_result($sql);
mysqli_close($con);
?>
<?php
include('core.php';
/*
* Define SQL_HOST, SQL_DB, SQL_USER & SQL_PASS
*/
function pdo_create()
{
$con = "mysql:host=" . SQL_HOST . ";dbname=" . SQL_DB . ";charset=UTF8";
$pdo = new PDO($con, SQL_USER, SQL_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
}
$title=songtitle(); //taken from core.php
$sep = explode('-', $title);
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$query = "SELECT url FROM songs s WHERE s.album = :album AND s.title = :song AND s.artist = :artist";
$pdo = pdo_create();
if(!$pdo){
die("Error");
}
$stmt = $pdo->prepare($query);
$stmt->bindParam(":album", $album);
$stmt->bindParam(":song", $song);
$stmt->bindParam(":artist", $artist);
if($stmt->execute()){
$url = $stmt->fetchColumn(0);
$stmt->closeCursor();
}else{
//error
}
?>
<?php
include('core.php';
/*
* Define SQL_HOST, SQL_DB, SQL_USER & SQL_PASS
*/
function pdo_create()
{
$con = "mysql:host=" . SQL_HOST . ";dbname=" . SQL_DB . ";charset=UTF8";
$pdo = new PDO($con, SQL_USER, SQL_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
}
$title=songtitle(); //taken from core.php
$sep = explode('-', $title);
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$query = "SELECT url FROM songs s WHERE s.album = :album AND s.title = :song AND s.artist = :artist";
$pdo = pdo_create();
if(!$pdo){
die("Error");
}
$stmt = $pdo->prepare($query);
$stmt->bindParam(":album", $album);
$stmt->bindParam(":song", $song);
$stmt->bindParam(":artist", $artist);
if($stmt->execute()){
$url = $stmt->fetchColumn(0);
$stmt->closeCursor();
}else{
//error
}
?>
<?php
include('core.php';
$con=mysqli_connect("localhost","username","pass","db");
if (!$con)
{
die('Connection Error (' . mysqli_connect_errno() . ' '
. mysqli_connect_error());
}
$title=songtitle(); //taken from core.php
echo "Now playing: $title ";
echo "<br /><br />";
$sep = explode('-', $title);
echo "Album: $sep[0] <br /> Song: $sep[1] <br /> Artist: $sep[2]";
echo "<br /><br />";
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$res = "SELECT `url` FROM `songs` WHERE (`album` = '" . $album . "' AND `title` = '" . $song . "' AND `artist` = '" . $artist . "'"; // I am pretty sure something is wrong in this line.
$sql = mysqli_query($con,$res);
$row = mysqli_fetch_array($sql,MYSQLI_ASSOC);
print $row["url"]; //No RESULT
mysqli_free_result($sql);
mysqli_close($con);
?>
<?php
include('core.php';
$con = new mysqli("localhost","username","pass","db");
if(!$con)
{
echo 'Could not connect to the database!'; // Use this if you are releasing your website publicly I would recommend lol
die();
}
$title=songtitle(); //taken from core.php
echo 'Now playing: ' . $title;
echo '<br /><br />';
$sep = explode('-', $title);
echo 'Album: ' . $sep[0] . ' <br /> Song: ' . $sep[1] . '<br /> Artist: ' . $sep[2] . ';
echo "<br /><br />";
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$res = "SELECT `url` FROM songs WHERE (`album` = '" . $album . "' AND `title` = '" . $song . "' AND `artist` = '" . $artist . "'"; // I am pretty sure something is wrong in this line.
$sql = $con->query($con,$res);
$row = $con->fetch_array($sql, MYSQLI_ASSOC);
print $row["url"]; //No RESULT
$mysqli_stmt->free_result($sql);
mysqli_close($con);
?>
error_reporting(E_ALL);
<?php
include('core.php';
$con = new mysqli("localhost","username","pass","db");
if(!$con)
{
echo 'Could not connect to the database!'; // Use this if you are releasing your website publicly I would recommend lol
die();
}
$title=songtitle(); //taken from core.php
echo 'Now playing: ' . $title;
echo '<br /><br />';
$sep = explode('-', $title);
echo 'Album: ' . $sep[0] . ' <br /> Song: ' . $sep[1] . '<br /> Artist: ' . $sep[2] . ';
echo "<br /><br />";
$album = trim($sep[0]);
$song = trim($sep[1]);
$artist = trim($sep[2]);
$res = "SELECT `url` FROM songs WHERE (`album` = '" . $album . "' AND `title` = '" . $song . "' AND `artist` = '" . $artist . "'"; // I am pretty sure something is wrong in this line.
$sql = $con->query($con,$res);
$row = $con->fetch_array($sql, MYSQLI_ASSOC);
print $row["url"]; //No RESULT
$mysqli_stmt->free_result($sql);
mysqli_close($con);
?>
$res = "SELECT `url` FROM 'songs' WHERE (`album` =? AND `title` =? AND `artist` =?)";
if($stmt = $con->prepare($res))
{
$stmt->bind_param("sss", $album, $title, $artist);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_ASSOC);
// Do stuff here
}
error_reporting(E_ALL);
$res = "SELECT `url` FROM 'songs' WHERE (`album` =? AND `title` =? AND `artist` =?)";
if($stmt = $con->prepare($res))
{
$stmt->bind_param("sss", $album, $title, $artist);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_ASSOC);
// Do stuff here
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.