为什么我的变量为NULL? 试图将mysql查询的结果放入变量中

Ok so Im trying to select a link from my db, get the text from the page, parse it and put that in a different column on the same row and repeat. I keep getting an error saying "file_get_contents(): Filename cannot be empty" So I figured its the variable that represents the link must be empty. Did a mysql_fetch_row($result); and sure enough, my $link_result is NULL. I dont understand why though. Help? Heres the code so far:

$x = 1;

    for ($y=1;$y=1201;$y++)
    {
    $query1 = "SELECT adlink, key  FROM usedcars WHERE key = $x";

    mysqli_query($conn, $query1);

    $link_result = mysqli_query($conn, $query1);

    file_get_contents($link_result);
    $text_holder = file_get_contents($link_result);

    return_between($text_holder, "postingBody", "<!-- .posting -->", EXCL);
    $final_text = return_between($text_holder, "postingBody", "<!-- .posting -->", EXCL);

    $query2 = "INSERT INTO usedcars (adtext) VALUES ($final_text) WHERE key = $x";

    mysqli_query($conn, $query2);
    echo "<font size='18' color='#FFFF00'>Placing text from $link_result into database</font><br>"; 

    $x++;
    }

Im obviously very new so any help is GREATLY appreciated.

You don't use file_get_contents to fetch those values

Use mysqli_fetch_*

$link_result = mysqli_query($conn, $query1);

$result = mysqli_fetch_assoc($link_result);

If you're expecting multiple rows then use a while():

while($row = mysqli_fetch_assoc($link_result)) {
    $link = $row['adlink'];
}

key is mysql reserve words. use bacticks around it

 $query1 = "SELECT adlink, `key`  FROM usedcars WHERE `key` = $x";

and to fetch the value use mysqli_fetch_array or mysqli_fetch_assoc

This line is wrong

$query2 = "INSERT INTO usedcars (adtext) VALUES ($final_text) WHERE key = $x";

and you can not use where clause in insert statement. But you can do some thing like this, i think you need update query instead of insert.

Like this

$query2 =UPDATE usedcars SET adtext ='$final_text' WHERE `key` = $x;

I am not sure about PHP but in your SELECT statement you are using a reserve word key which must be escaped using backtique like

SELECT adlink, `key`  FROM usedcars WHERE `key` = $x

Again, your INSERT statement format is wrong as pointed below. You don't use WHERE clause in INSERT statement.

INSERT INTO usedcars (adtext) VALUES ($final_text) WHERE key = $x
                                                    <-- Here

I think you meant to do an UPDATE rather like

UPDATE usedcars SET adtext = $final_text WHERE `key` = $x