I am trying to make a basic song info page, and my only problem is the SQL. I keep getting this message:
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /var/www/tts/recommend-action.php on line 33
Here is my code:
<?php
session_start();
ini_set("display_errors",true);
ob_start();
$host = "localhost";
$user = "root";
$pass = "[MYPASSWORD]";
$db = "[MYDATABASE]";
$tb = "recommendation";
$link = mysqli_connect($host, $user, $pass, $db) or die("Failed to connect.");
$song = $_POST['song'];
$album = $_POST['album'];
$artist = $_POST['artist'];
$linkitunes = $_POST['linkitunes'];
$artwork = $_POST['albumPic'];
$song = stripslashes($song);
$album = stripslashes($album);
$artist = stripslashes($artist);
$link = stripslashes($linkitunes);
$artwork = stripslashes($artwork);
print "<br /><br /><b>User ID: </b>" . $_SESSION['user_id'] . "<br /><b>Song: </b>$song<br /><b>Album: </b>$album<br /><b>Artist: </b>$artist<br /><br />";
$sql = "INSERT INTO recommendation (user_id, artist, song, album, artwork, linkitunes) VALUES (" . $_SESSION['user_id'] . ", $artist, $song, $album, $artwork, $linkitunes);";
$postrec = mysqli_query($link, $sql);
if ($postrec == true) {
print "sucess";
}
else {
print "<br /><br />failed";
}
ob_flush();
?>
I cannot find a solution. Help is very greatly appreciated.