Jump to content

Help! Warning: mysql_fetch_row() expects parameter 1 to be resource


sleepnot

Recommended Posts

this Nofications appear..

 

Notice: Undefined index: id in C:\wamp\www\WAR\up3\view.php on line 4

 

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\wamp\www\WAR\up3\view.php on line 9

invalid id

 

this is my code.

 

<?php

    require ('dbconnect.php'); // Connect to database

 

    $id = $_GET['id']; // ID of entry you wish to view.  To use this enter "view.php?id=x" where x is the entry you wish to view.

 

    $query = "SELECT data, filetype FROM uploads where uploadid=$id"; //Find the file, pull the filecontents and the filetype

    $result = MYSQL_QUERY($query);    // run the query

 

    if($row=mysql_fetch_row($result)) // pull the first row of the result into an array(there will only be one)

    {

        $data = $row[0];    // First bit is the data

        $type = $row[1];    // second is the filename

 

        Header( "Content-type: $type"); // Send the header of the approptiate file type, if it's' a image you want it to show as one :)

        print $data; // Send the data.

    }

    else // the id was invalid

    {

        echo "invalid id";

    }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.