Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Help! Images not displaying after uploading to live site


Go to End


2 Posts   2366 Views

Avatar
sheadawson

Community Member, 49 Posts

7 January 2011 at 8:01pm

Edited: 10/01/2011 12:08pm

Hi,

I have done a few SS sites now and found migrating to the live server from my localhost a breeze.. apart from this one!

Everything works fine except none of the images uploaded through the CMS are showing in the front or backend. When I try to view the images directly in the browser, ie. www.mysite.com/assets/Uploads/images/lessons.jpg I get this error:

[User Error] Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ClassName" IN ('Image','ImageGalleryImage','Image_Cached')) AND (ID = ) ORDER BY SortOrder ASC LIMIT 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY SortOrder ASC LIMIT 1' at line 1
GET /assets/Uploads/images/lessons.jpg

Line 526 in /home/loveviol/public_html/newtest/sapphire/core/model/MySQLDatabase.php

This is my page.php:;

<?php
class Page extends SiteTree {

	public static $db = array(
		'HeaderID' => 'Varchar(20)',
		'BGImageTopSpace' => 'Int',
	);

	public static $has_one = array(
		'BGImage' => 'Image',
		"Footer" => "WidgetArea",
	);
	
	public function getCMSFields(){
		Requirements::css( project() . "/css/admin.css");
		$fields = parent::getCMSFields();
		$fields->addFieldsToTab('Root.Content.Main', new TextField('HeaderID', 'HeaderID'));
		$fields->addFieldsToTab('Root.Content.BackgroundImage', new ImageUploadField('BGImage', 'Background Image'));
		$fields->addFieldsToTab('Root.Content.BackgroundImage', new NumericField('BGImageTopSpace', 'Space above background image'));
		return $fields;
	}
	
	public function MyBGImage(){
		if($image = $this->obj('BGImage')){
			$image->PageHeight = $image->getHeight() - 120 + $this->BGImageTopSpace;
			return $image;
		}		
	}
	
	public function LatestNews(){
		if($object = DataObject::get('NewsEntry', $filter='', $sort='', $join='', $limit=5))
		return $object;
	}
	
	public function Testimonials(){
		if($object = DataObject::get('Testimony', $filter='published = 1', $sort='SortOrder ASC', $join='', $limit=''))
		return $object;
	}

}
class Page_Controller extends ContentController 
{
	public function init() {
		Requirements::block('sapphire/thirdparty/prototype/prototype.js');
      	Requirements::block('sapphire/thirdparty/behaviour/behaviour.js');
      	Requirements::block('sapphire/thirdparty/scriptaculous/effects.js');
      	Requirements::block('cms/javascript/PageCommentInterface.js'); 
		Validator::set_javascript_validation_handler('none');
		Requirements::javascript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
		Requirements::javascript('mysite/javascript/script.js'); 
		parent::init();
	}
}

The images definitely exist as I can access them via FTP fine. Interestingly, if I comment out the function MyBGImage() function and attempt to view an image in the browser, I just get a 404 not found page instead of the error...

Thanks for any help here, bit stumped and really want to get this one wrapped up!

if it helps the page is currently available here [url=http://newtest.loveviolin.co.nz/]http://newtest.loveviolin.co.nz/

I have edited this to update the code and change the link..

Avatar
sheadawson

Community Member, 49 Posts

10 January 2011 at 12:33pm

Ok I have solved this..

No idea why but for some reason, at the bottom of my /assets/.htaccess:

# Turn the PHP engine off
php_flag engine off

Should have had:

<IfModule mod_php5.c>
	# Turn the PHP engine off
	php_flag engine off
</IfModule>