IamSuchANoob Posted April 25, 2011 Share Posted April 25, 2011 Hi. idea: View image from /skins/ folder. The id for the image is taken from mysql DB field called PlayerDefaultSkin So, lets say a user has 240 in the field in database and in /skins/ folder I have image called 240.png What I want is to php read from PlayerDefaultSkin field and view the image from /skins/ Right now I have this: query to update: `PlayerDefaultSkin` = $data[PlayerDefaultSkin]' and the output code <img src="skins/<?php echo '$PlayerDefaultSkin' ?>.png"> which simply doesnt work and is probably very wrong. So can anyone help me with this? Link to comment https://forums.phpfreaks.com/topic/234677-view-image/ Share on other sites More sharing options...
spiderwell Posted April 25, 2011 Share Posted April 25, 2011 i dont think you need the single quotes around the echo statement, but you do need them around the $data array, try $PlayerDefaultSkin = $data['PlayerDefaultSkin']; <img src="skins/<?php echo $PlayerDefaultSkin; ?>.png"> also check src path, is it /skins/ or just skins/ Link to comment https://forums.phpfreaks.com/topic/234677-view-image/#findComment-1205967 Share on other sites More sharing options...
IamSuchANoob Posted April 25, 2011 Author Share Posted April 25, 2011 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/crpnet/domains/c-rp.net/public_html/UCPbeta/myaccount.php on line 53 Here is how the query looks right now: mysql_query("UPDATE users SET `Hobby` = '$data[Hobby]', `Phone` = '$data[Phone]', `Gender` = '$data[Gender]', `Level` = '$data[Level]', `AdminLevel` = '$data[user_level]', `Job` = '$data[Job]', `Country` = '$data[Country]', `MoneyInBank` = '$data[MoneyInBank]', `Age` = '$data[Age]', `PlayerMoney` = '$data[PlayerMoney]', $PlayerDefaultSkin = $data['PlayerDefaultSkin']; WHERE id='$_SESSION[user_id]' ") or die(mysql_error()); I think query works, it does output 240 as neccesary, problem is somewhere in here <img src="skins/<?php echo $PlayerDefaultSkin; ?>.png"> but then again, what do I know? Link to comment https://forums.phpfreaks.com/topic/234677-view-image/#findComment-1205972 Share on other sites More sharing options...
spiderwell Posted April 25, 2011 Share Posted April 25, 2011 ok sorry i misread your part about the update, so ignore that part , revert the query back. what does it actually echo in the image tag when you view source? Link to comment https://forums.phpfreaks.com/topic/234677-view-image/#findComment-1205975 Share on other sites More sharing options...
IamSuchANoob Posted April 25, 2011 Author Share Posted April 25, 2011 http://hello.net/UCPbeta/skins/.png Link to comment https://forums.phpfreaks.com/topic/234677-view-image/#findComment-1205977 Share on other sites More sharing options...
IamSuchANoob Posted April 25, 2011 Author Share Posted April 25, 2011 Fixed. <img src="skins/<?php echo $row_settings ['PlayerDefaultSkin']; ?>.png"> Link to comment https://forums.phpfreaks.com/topic/234677-view-image/#findComment-1205991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.