从数据库中读取URL无法正常工作

I have some urls for a pdf that I want to read from the database. But when I try to echo the result of my query, I get no result at all.

I'm trying to read the data with the following code:

(artikeldb.php)

//  content
$attachment             = "SELECT * FROM `site_attachments` WHERE parent_id = '".$attachmentcr[0]['parent_id']."' ";
$attachmentcon          = $conn->query($attachment);
$attachmentcr           = array();
while ($attachmentcr[]  = $attachmentcon->fetch_array());

This is where I want to read the results.

(content.php)

$pdf = $attachmentcr[0]['url'];

echo $attachmentcr[0]['url'];
echo $pdf;

But neither of those echoes work.

I want to read the url that belongs to the correct article (using parent_id , which is the same as id in site_content).

What am I doing wrong?

Did you try var_dump($attachmentcon = $conn->query($attachment))? What is returned after the query?