Jump to content

displaying images


garydt

Recommended Posts

I'm trying to display an image depending on who is logged in. The url is stored in the database but the image isn't dispolaying. The code-

 

 

$colname_Recordset1 = "-1";

if (isset($_SESSION['MM_Username'])) {

  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);

}

mysql_select_db($database_elvisdb, $elvisdb);

$query_Recordset1 = sprintf("SELECT * FROM userinformation WHERE usernm = %s", GetSQLValueString($colname_Recordset1, "text"));

$Recordset1 = mysql_query($query_Recordset1, $elvisdb) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

$colname_Recordset2 = "-1";

if (isset($_SESSION['MM_Username'])) {

  $colname_Recordset2 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);

}

mysql_select_db($database_elvisdb, $elvisdb);

$query_Recordset2 = sprintf("SELECT * FROM images WHERE usnm = %s", GetSQLValueString($colname_Recordset2, "text"));

$Recordset2 = mysql_query($query_Recordset2, $elvisdb) or die(mysql_error());

$row_Recordset2 = mysql_fetch_assoc($Recordset2);

$totalRows_Recordset2 = mysql_num_rows($Recordset2);

$img = $query_Recordset2;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<p><?php echo $row_Recordset1['why']; ?>

<?php echo $_SESSION['MM_Username']; ?></p>

<p><?php echo $row_Recordset1['album']; ?></p>

<p><?php echo $row_Recordset1['song']; ?></p>

<p><?php echo $row_Recordset2['imageName']; ?></p>

<p><img src="<?php echo $img; ?> "></p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

 

mysql_free_result($Recordset2);

?>

 

Link to comment
https://forums.phpfreaks.com/topic/43229-displaying-images/
Share on other sites

$query_Recordset2 is your sql query, so...

 

$img = $query_Recordset2;

 

Will not store the image within $img.

 

You would be looking at something more like....

 

$img = $row_Recordset2['img'];

 

PS; You really ought to think about dropping Dreamweaver if your trying to actually learn PHP. That is some terrible code.

Link to comment
https://forums.phpfreaks.com/topic/43229-displaying-images/#findComment-209927
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.