squiblo Posted August 24, 2009 Share Posted August 24, 2009 nothing is being echoed in this code, and no errors, notices or warnings are appearing <?php session_start(); if($_SESSION['myusername']){ ?> <?php $_SESSION['myusername']; $connect = mysql_connect("localhost","***","***") or die ("Couldn't connect"); mysql_select_db("***") or die ("Couldn't find db"); $username = isset($_SESSION['myusername']) ? $_SESSION['myusername'] : 'default_value'; $query = mysql_query("SELECT * FROM members WHERE username='$username'"); if (mysql_num_rows($query)==0){ die; }else{ $row = mysql_fetch_assoc($query); $location = $row['imagelocation']; if($location == ""){ echo ""; }else{ echo "<img src ='$location' width='110' height='110' border='1'><br>"; echo "Welcome " . ucwords(strtolower($_SESSION['myusername'])); } } ?> <?php } else { echo "<a href='login.php' style='text-decoration:none'><font color=#FFFF00>Sign in </a></font><font color=#FFFFFF><font color=#000000>/</font> Register</font>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/171576-confusing-problem/ Share on other sites More sharing options...
tekrscom Posted August 24, 2009 Share Posted August 24, 2009 You're evaluating if($_SESSION['myusername']) as a boolean.. I'm not positive what you are trying to do, but don't you need to change that to if(isset($_SESSION['myusername'])) at the top of your page? Quote Link to comment https://forums.phpfreaks.com/topic/171576-confusing-problem/#findComment-904787 Share on other sites More sharing options...
squiblo Posted August 24, 2009 Author Share Posted August 24, 2009 ive changed it a little bit so it may be easier to understand, i dont know how to get this to work properly, it is getting an image directory from mysql and the actual image is in ftp. <?php session_start(); if($_SESSION['myusername']){ $connect = mysql_connect("localhost","","") or die ("Couldn't connect"); mysql_select_db("") or die ("Couldn't find db"); $username = ($_SESSION['myusername']); $query = mysql_query("SELECT * FROM members WHERE username='$username'"); if (mysql_num_rows($query)==0){ die; }else{ $row = mysql_fetch_assoc($query); $location = $row['imagelocation']; if($location == ""){ echo ""; }else{ echo "<img src ='$location' width='110' height='110' border='1'><br>"; echo "Welcome " . ucwords(strtolower($_SESSION['myusername'])); } } } else { echo "<a href='login.php' style='text-decoration:none'><font color=#FFFF00>Sign in </a></font><font color=#FFFFFF><font color=#000000>/</font> Register</font>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/171576-confusing-problem/#findComment-904793 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.