html - PHP replacing blank images with a default one -


having 1 of brain fade moments morning. have following php:

$imgset = $result->fields[6]; if ($imgset = '') {     $imgset = 'logo'; } else {      $imgset = $result->fields[6]; } echo '<img id="imgdisp" src="/img/'.$imgset.'.jpg" />'; $imgset = ''; 

where looks see if result database blank , if so, should put in logo.jpg instead of whatever result is. reason though, not want work , being blind, cannot see why not. still blank images in html , filenames of "/img/.jpg" though $imgset still passing through blank. values not null in sql either, blank entries inputted inputbox using _post in form elsewhere.

cheers help

ben

this:

 if ($imgset = '') { 

is setting $imgset empty. use comparison instead:

 if ($imgset == '') { 

your else not needed since in case $imgset set $result->fields[6];.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -