PHP MySQL fetch and echo in textarea
<p>I am trying to fetch text from a specific column of a database (column is called "paste") relative to an url ID. Every column has an ID associated with it in a column called "id". As an example, I have a a data entry for the letter B in column "paste" with an ID of 7 in column "id".</p>

<p>So when the url is extended with "?id=7" the website is supposed to echo out the letter B in my textarea.</p>

<p>I've tried using mysql_fetch_array and echoing $row. Specifically I tried following the code from the "Getting a Row of Data using mysql_fetch_array" example on <a href="http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php" rel="nofollow noreferrer">this</a> link. </p>

<p>The sql query statement works, as I've tried it directly on my database via PHPMyAdmin. I've also verified that the ID in the url is able to be read by echoing $id.</p>

<pre><code>&lt;textarea type="text" name="paste" required autofocus rows="35" cols="150" wrap="off" maxlength="20000"&gt;
    &lt;?php
        // Login information and database
        $servername = "xxx";
        $username = "xxx";
        $password = "xxx";
        $dbname = "xxx";

        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);

        // Check connection
        if ($conn-&gt;connect_error) {
        die("Connection failed: " . $conn-&gt;connect_error);
        }

        $id = ($_GET['id']);

        if(isset($_GET['id']))
        {
            $query = "SELECT paste FROM pastebin WHERE id = $id";

            $result = $mysql_query($query) or die(mysql_eror());

            $row = mysql_fetch_array($result) or die(mysql_error());

            echo $row['paste'];

            $conn-&gt;close();
        }

    ?&gt;
&lt;/textarea&gt;&lt;br&gt;
</code></pre>