Jump to content

confusing problem


squiblo

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/171576-confusing-problem/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/171576-confusing-problem/#findComment-904793
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.