Jump to content

Recommended Posts

<?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 ::)

Link to comment
https://forums.phpfreaks.com/topic/157657-solved-image-not-echoing-to-browser/
Share on other sites

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.

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

 

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

<?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\" />";
   }
}
?>

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.

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! ^_^

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.