$image_id = $_GET['id'];

$select_fid_query = db_select('file_usage', 'fu')
->fields('fid')
->condition('id', $image_id, '=')
->execute();

$fid = $select_fid_query->fetchAssoc();

$select_image_query = db_select('file_managed', 'fm')
->fields('uri')
->condition('fid', $fid, '=')
->execute();

$uri = $select_image_query->fetchAssoc();

echo $uri;

this code is called using ajax. and it gives 500 HTTP Internal server error. I am using D7

Comments

Question

Hi,
Does your code return a result? In other words what value does $uri does contain? Can the value be converted to a string?

When in doubt, have the Leprechaun take care of it!

$uri contains uri of an

$uri contains uri of an image. this is an ajax call i.e. javascript function will call this piece of code and this piece of code is written inside mymodule.module inside a function that is called back from hook_menu. i have checked the code and it has no errors.

just for testing i just want to display the uri inside div tag. but it doesnt shows and gives 500 http error. later i will use this $uri for displaying the image.

Innoraft Solutions Pvt Ltd

$uri contains uri of an

$uri contains uri of an image. this is an ajax call i.e. javascript function will call this piece of code and this piece of code is written inside mymodule.module inside a function that is called back from hook_menu. i have checked the code and it has no errors.

just for testing i just want to display the uri inside div tag. but it doesnt shows and gives 500 http error. later i will use this $uri for displaying the image.

also i have change the code and used placeholders. my new code is like this:

$result = db_query('SELECT nid FROM node where nid = :nid', array(':nid' => 1));
$id = db_fetch_object($result);
echo $id->nid;

i have changed it a bit and made it simpler. but still the error is same. i dont where i am doing wrong? i must be missing something

Innoraft Solutions Pvt Ltd