TGWSE_GY Posted May 11, 2009 Share Posted May 11, 2009 <?php session_start(); echo $_SESSION['Usr']; if (isset($_SESSION['Usr'])) { // Get database connection info include('config.php'); // Connect to Database $con = mysql_connect($Host, $Login, $Pass); mysql_select_db("login_ums", $con); // Get the username from the session $varUser = $_SESSION['Usr']; //Get the users CustID $GetCustID = mysql_query("SELECT CustID FROM login WHERE Usr = '$varUser'"); $CustID = mysql_fetch_array($GetCustID); $varCustID = $CustID['CustID']; //Get array of records from db holding the location of the users images $UsrImgArr = mysql_query("SELECT * FROM profile_user_images WHERE CustID = '$varCustID'"); $UsrImgs = mysql_fetch_array($UsrImgArr); echo $ImgCount = mysql_num_rows($UsrImgArr); if ($ImgCount > 0) { $I = 1; do{ $img = $UsrImgs['ImageLocation']; echo "<img src=\"php/content/includes/members_home/user_images/$img\" />"; echo $I; $I = $I + 1; } while ($I <= $ImgCount); } else { die(1); } } else { die(2); } ?> Okay in the loop it should be echoing each img location to the browser in the HTML <img src=""/> tag. I have tested the loop and it is going through the correct number of times, but the imgs are not displaying. Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/ Share on other sites More sharing options...
dreamwest Posted May 11, 2009 Share Posted May 11, 2009 Do you have the extension stored in the database too? <img src=\"php/content/includes/members_home/user_images/$img.".jpg\" /> also test to see if the image location has a value echo $UsrImgs['ImageLocation']; Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831359 Share on other sites More sharing options...
nblasgen Posted May 11, 2009 Share Posted May 11, 2009 dreamwest's comment made no sense to me. Can you show us what the output is? Edit -> View Source in your browser then paste the output here? I assume it's working just fine but your image links are invalid. But anyways, without the output there is nothing I can help you with. If the loop is working correctly it's nothing to do with the program. It's the database or the link. So yeh, post the output of that script. Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831393 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 dreamwest's comment made no sense to me. Can you show us what the output is? Edit -> View Source in your browser then paste the output here? I assume it's working just fine but your image links are invalid. That is *exactly* the point dreamwest made. Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831402 Share on other sites More sharing options...
TGWSE_GY Posted May 11, 2009 Author Share Posted May 11, 2009 thegayestever6<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />1<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />2<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />3<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />4<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />5<img src="php/content/includes/members_home/user_images/userimgs/thegayestever/01.jpg" />6 This is what the browser is outputting. Thanks Again Guys Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831521 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 So it does output but you have the path wrong. Try this - echo "<img src=/\"php/content/includes/members_home/user_images/$img\" />"; Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831559 Share on other sites More sharing options...
TGWSE_GY Posted May 11, 2009 Author Share Posted May 11, 2009 Okay now the images are displaying, thanks guys. Just one more issue the pointer is not moving to the next Array Element when processing multiple images, it is only grabbing the first image in the array. Can someone help shed some light on this problem. Here is the new code: <?php session_start(); echo $_SESSION['Usr']; if (isset($_SESSION['Usr'])) { // Get database connection info include('config.php'); // Connect to Database $con = mysql_connect($Host, $Login, $Pass); mysql_select_db("login_ums", $con); // Get the username from the session $varUser = $_SESSION['Usr']; //Get the users CustID $GetCustID = mysql_query("SELECT CustID FROM login WHERE Usr = '$varUser'"); $CustID = mysql_fetch_array($GetCustID); $varCustID = $CustID['CustID']; //Get array of records from db holding the location of the users images $UsrImgArr = mysql_query("SELECT * FROM profile_user_images WHERE CustID = '$varCustID'"); $UsrImgs = mysql_fetch_array($UsrImgArr); echo $ImgCount = mysql_num_rows($UsrImgArr); if ($ImgCount > 0) { $I = 1; do{ echo $img = $UsrImgs['ImageName']; echo "<img src=\"php/includes/content/members_home/user_images/perm_images/$varUser/$img\" />"; $I = $I + 1; } while ($I <= $ImgCount); } else { die(1); } } else { die(2); } ?> Thanks Again Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831647 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 <?php session_start(); echo $_SESSION['Usr']; if (isset($_SESSION['Usr'])) { // Get database connection info include('config.php'); // Connect to Database $con = mysql_connect($Host, $Login, $Pass); mysql_select_db("login_ums", $con); // Get the username from the session $varUser = $_SESSION['Usr']; //Get the users CustID $GetCustID = mysql_query("SELECT CustID FROM login WHERE Usr = '$varUser'"); $CustID = mysql_fetch_array($GetCustID); $varCustID = $CustID['CustID']; //Get array of records from db holding the location of the users images $UsrImgArr = mysql_query("SELECT * FROM profile_user_images WHERE CustID = '$varCustID'"); while ($UsrImgs = mysql_fetch_array($UsrImgArr)) { echo "<img src=\"php/includes/content/members_home/user_images/perm_images/$varUser/$img\" />"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831651 Share on other sites More sharing options...
premiso Posted May 11, 2009 Share Posted May 11, 2009 I am just throwing this out there... Are you sure that the path "php/content/includes/members_home/user_images" is correct. It looks a little odd to me. Can you effectively goto http://www.yoursite.com/php/content/includes/members_home/user_images/animage.jpg and pull up an image? If you cannot then you are not using the correct path. The path needs to be the URL path not the File Directory path. Take a look at that and see if that helps solve this. Sorry, it was already discussed and figured out, missed that post. Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831755 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 I am just throwing this out there... Are you sure that the path "php/content/includes/members_home/user_images" is correct. It looks a little odd to me. Can you effectively goto http://www.yoursite.com/php/content/includes/members_home/user_images/animage.jpg and pull up an image? If you cannot then you are not using the correct path. The path needs to be the URL path not the File Directory path. Take a look at that and see if that helps solve this. We already solved that problem, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/#findComment-831757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.