Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Server-side Scripting _ Image file not loading

Posted by: tudsy Jan 18 2017, 08:38 AM

Hi

I am trying to assign prices (a number) to each bmp file. At the moment, the sound is loading correctly but the image is not. The code is shown below. Any help will be appreciated.

Thanks. biggrin.gif


<!DOCTYPE html>

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">



<script>

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-908952-3', 'auto');
ga('send', 'pageview');
ga('require','linkid');
</script>






<script>

var personsnamejs ='AdrianTudini';

var personpicture = personsnamejs + '.jpg';





var personpath = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/' + personsnamejs + '/' + personpicture;


function setvar(){



var x = document.getElementById('Title');
x.style.color = '#00FF00';
x.style.fontSize ='36px';

document.getElementById('PersonImage').src = personpath;


var z = document.getElementById('PlaySound');
z.style.color = '#00FF00';
z.style.fontSize ='24px';

var t = document.getElementById('paypal');
t.style.color = '#00FF00';
t.style.fontSize ='24px';

var u = document.getElementById('freename');
u.style.color = '#00FF00';
u.style.fontSize ='20px';

var v = document.getElementById('freeaddress');
v.style.color = '#00FF00';
v.style.fontSize ='20px';

document.getElementById('def').innerHTML = 'Click-Tap dropdown menu to view/select ' + personsnamejs + " 's Art";

document.getElementById('PersonImage').src = personpath;



document.getElementById('paypal').innerHTML ="* Your name and email address will not be sold or traded.";




};
</script>









<script type='text/javascript'>

function linkSound(picname,personname)
{

if(picname != 'default')
{

soundfile = picname.replace('w.bmp','.mp3');


var soundfilepath = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/' + personname + '/Sound/' + soundfile;



document.getElementById('Sound').src = soundfilepath;





}


};</script>


<script>

function changePic(picname,personname)
{

if(picname != 'default')
{





var path = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/' + personname + '/Graphic/' + picname;





var myimg = document.getElementById('myImage');



var newImage = new Image();
newImage.src = path;



newImage.onerror = function()
{
alert('There was a problem loading the Image file! - Please try again');
myimg.style.height = '';
myimg.src = '';
}
newImage.onload = function()
{

myimg.src = path;










var y = document.getElementById('Price');
y.style.color = '#00FF00';
y.style.fontSize ='36px';



document.getElementById('Price').innerHTML= 'Price of Art ( without a watermark )(USD): $' + Priceofart;







document.getElementById('form').action = "process.php?username=<?php echo $Name ?>&email=<?php echo $Email ?>"+ "&Person=" + personsnamejs + "&Price=" + Priceofart + "&Graphic=" + picname.replace('w.bmp','.bmp');

}

}
};

</script>








<title>ECOVIB2D&copy;</title>
</head>
<body onload='setvar();' style='background-color: #660000'>








<table align='centre' border='0' width='965'>
<tbody>
<tr>
<td bgcolor='#660000' width='189px'><img height='90' src='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/ecovib2d1.jpg' width='90' /></td>
<td bgcolor='#660000' width='500px'>
<p align='center' id ='Title'>ECOVIB2D&copy;</p>



<div id='google_translate_element'></div><script type='text/javascript'>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script><script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'></script>





</td>
</tr>
</tbody>
</table>












<table align='center' style=' background-color: #660000'>
<tbody>







<tr>


<td align='left'>


<img src= '' id='PersonImage' width='450' height='450'>


</td>


<td>












<select name='Graphic_select' id='Graphic_select' onchange='changePic(this.value,personsnamejs);linkSound(this.value,personsnamejs);'>


<option value ='default' id = 'def' style='height:120px;'></option>


<?php

$pname = "AdrianTudini";

$i=0;

foreach(glob("/home/ecovibdc/public_html/ECOVIB2D/MYART/".$pname."/Graphicw/*w.bmp") as $files1){

$files1 = basename($files1);


$priceofart = array("2","304","32","104","345","45","56","89","78","98","345","987", "56","67","89","765","765","34","532","76","98","987","765","321");




echo "<option value='{$files1}'.' '.'($'.'{$priceofart[$i]}'.')'>{$files1} ($ {$priceofart[$i]})</option>";

$i=$i+1;





}
?>


<script>

var x = document.getElementById('Graphic_select').selectedIndex;

document.getElementById('Graphic_select').value='{$files1}';




Priceofart = <?php $priceofart[x]; ?>;
</script>


</select>

















<img id='myImage' src=path height='450' width='450'>

<p align='center' id='PlaySound' >Play the sound with my art in mind</p>



<center><audio id='Sound' controls><source src=soundfilepath type='audio/mpeg'>You cannot play the sound in the browser.</audio></center>
<br>

<br>

</td>
</tr>
</table>













<center> <p id='Price'> </p></center>








<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post" starget="_top">



<p align='center' id='freename'>Enter Full Name:</p>

<p align='center'><input id='Nameofperson' maxlength='50' name=username size='50' type='text' /></p>

<p align='center' id='freeaddress'>Enter Email-Address:</p>

<p align='center'><input id='e-address' maxlength='50' name=email size='50' type='text' /></p>





<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NAHTXLUQDVU2Y">
<input type="image"
src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form></center>





<p align='center' id='paypal'></p>

<p align='center' class='style8'><a href='http://ecovib2d.blogspot.com.au'>Back to Ecovib2ds blog</a></p>


<p align='center'><span class='style8'><a href='mailto:tudsy@ecovib2d.com.au'>Send me Mail</a></span></p>









</body>
</html>

Posted by: Christian J Jan 18 2017, 10:22 AM

Are you having trouble with the javascript or the PHP?

In any case, please reformat the code example in a more readable way. Also remove irrelevant parts, such as the Google analytics script.

Posted by: pandy Jan 18 2017, 11:28 AM

And don't use BMP on the web. IE may load them (it used to, don't know how it is today), other browsers won't (or at least they didn't...).

You can use GIF, JPG and PNG. Depending of what kind of art it is, you should convert the images to JPG or PNG. JPG will be smaller, but you loose a little quality. It's good for photographs and similar images where the quality loss isn't noticeable.

Posted by: Christian J Jan 18 2017, 03:31 PM

Actually BMP images seem to be well supported nowadays, but the file size usually becomes very large since they can't be compressed.

Posted by: pandy Jan 18 2017, 04:32 PM

Really? What for?

Posted by: Christian J Jan 18 2017, 04:53 PM

No idea, according to https://w3techs.com/technologies/details/im-bmp/all/all BMP is only used by 0.3% of all websites, so it can't be for compatibility.

Posted by: pandy Jan 18 2017, 05:02 PM

Interesting site. Is it trustworthy?

Posted by: Christian J Jan 18 2017, 05:20 PM

No idea, but it's quoted by e.g. https://www.w3.org/International/questions/qa-who-uses-unicode.en.html

OTOH it lacks its own Wikipedia page, even though a few other wikipedia pages use it as a source: https://en.wikipedia.org/wiki/Special:Search?search=w3techs.com

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)