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";

    }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.