garydt Posted March 18, 2007 Share Posted March 18, 2007 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 More sharing options...
trq Posted March 18, 2007 Share Posted March 18, 2007 $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 More sharing options...
garydt Posted March 18, 2007 Author Share Posted March 18, 2007 Yes, I'd like to learn php. Which books\websites do you recommend? I did $img = $query_Recordset2['img']; and the image isn't showing. Link to comment https://forums.phpfreaks.com/topic/43229-displaying-images/#findComment-209943 Share on other sites More sharing options...
garydt Posted March 19, 2007 Author Share Posted March 19, 2007 i put $img = $row_Recordset2['img']; and the image still isn't displaying. What have I done wrong? Link to comment https://forums.phpfreaks.com/topic/43229-displaying-images/#findComment-210466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.