I've been searching and trying different solutions for about 3 hours, and now I'm caving and posting this question.
I have the following code;
<?php
include 'db.php';
$trackcd = $_GET['trackCD'];
$trackTitle = $_GET['trackTITLE'];
$duration = $_GET['secDuration'];
$artIDD = mysqli_query($conn, "SELECT artID FROM cd WHERE cdID=$trackcd");
$results = mysqli_query($conn, "SELECT artID, artName FROM artist WHERE artID=$artIDD");
$row = mysqli_fetch_assoc($results);
$sql = "INSERT INTO tracks (trackID, artID, artistName, trackCD, trackTITLE, secDuration) VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('iisssi', $trackID, $artIDD, $row["artName"], $trackcd, $trackTitle, $duration);
$result = $stmt->execute();
if(!$result) echo "Failed";
//header('Location: tracks.php');
?>
but on line 10;
$results = mysqli_query($conn, "SELECT artID, artName FROM artist WHERE artID=$artIDD");
I am getting the following error message;
Catchable fatal error: Object of class mysqli_result could not be converted to string in D:\xampp\htdocs\dashboard\inserttrack.php on line 10.
These queries each use a primary key, and only return one result, which I need for the INSERT query later. Most of the previous questions I have looked at suggest creating a loop, but I don't know how this will help me as I only get one result which I want to use later and does not need printing out.
The use of mysqli_query and $row = mysqli_fetch_assoc($results);
are things I have picked up from similar questions, but they have not solved my problem.