I have a list of urls for images and I want to display a specific image every time the html page is loaded again. I have a url variable p whose value will be incremented by one every time the html page is loaded.
Below is the code I have:
<cfif p eq 1>
<cfset w="image1.png">
<cfelseif p eq 2>
<cfset w="image2.png">
<cfelseif p eq 3>
<cfset w="image3.png">
</cfif>
<img class="class1" src=<cfoutput>#w#</cfoutput>>
However, ColdFusion didn't seem to recognize cfoutput when it was in the tag?
Your code seems to be ok. I did a quick successfull test of the following code on trycf.com and it works:
<cfset P=RandRange( 1, 3)>
<cfif p eq 1>
<cfset w="https://picsum.photos/200/400">
<cfelseif p eq 2>
<cfset w="https://picsum.photos/300/300">
<cfelseif p eq 3>
<cfset w="https://picsum.photos/400/100">
</cfif>
<img class="class1" src=<cfoutput>#w#</cfoutput>>
So your issue doesn't seem to be in the code. To identify the problem you need to see the generated source code in your developer tools as mentioned by @luke in his comment. Look also through the developer tools network tab, if the images are being requested and loaded by your browser correctly. It's also likely that your browser is blocking the images from being displayed.
Still, I'd set the value of the images attribute src into double quotes and embrace the image tag completely with with the cfoutput tags (for better code readability), like so:
<cfoutput>
<img class="class1" src="#w#">
</cfoutput>