viser brugerens billede.
Hej jeg har været så heldig at få mig et subdomæne hos en ven så jeg nu har database og det hele med, men jeg er stødt på et problem.På min startside har jeg et felt der hedder tilfældig bruger hvor den viser en tilfældig bruger fra siden. Den viser brugeren og skifter som den skal så der kommer en ny bruger, men den viser ikke brugerens billede. Hvis man er logget ind så viser den personen som er logget ind's billede og ikke fra den bruger som er vist i feltet tilfældig bruger. Hvis man ikke er logget ind så viser den mit nopic billede.
Bemærk: da jeg er ny til programmering er der sikkert mere en en fejl i min kode!
Min kode:
__________________________________________
<?php
session_start();
include "connect.php"; // Includere config.php
include "admin/check.php"; // Includere check.php som undersøger om man er ip bannet
$_SESSION['user']; //Indeholder selvf brugerens brugernavn.
$_SESSION['loggetind']; //Det er så den der fortæller om man er logget ind :)
?>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 570,top = 150');");
}
// End -->
</script>
</head>
<?php
$select_user = mysql_query("SELECT seneste FROM system")or die(mysql_error());
while($row = mysql_fetch_array($select_user)){
$seneste = $row['seneste'];
}
$select_user = mysql_query("SELECT * FROM members WHERE user = '$_SESSION[user]'")or die(mysql_error());
while($row = mysql_fetch_array($select_user)){
$id = $row['id'];
}
?>
<html>
<head>
<title>CoolBoom.dk/gokart - Dit Gokart site.</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<br>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="900" class="htable">
<tr>
<td class="logo"> </td>
</tr>
<tr>
<td class="menubg">
<a href="index" class="menu">Forside</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<a href="?side=news" class="menu">Nyheder</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<a href="java script:popUp('mobler/index.php')" class="menu">Møbellisten</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<a href="?side=user_list" class="menu">Brugerliste</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<a href="?side=regler" class="menu">Reglsæt</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<a href="?side=crew" class="menu">Redaktion</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<?php
if($_SESSION['login'] == "ok"){
?>
<a href="?side=logout" class="menu">Logud</a> <img src="/images/menu_splitter.jpg" align="absmiddle">
<?php
}
?>
</td>
</tr>
<tr>
<td class="submenu">
<!-- Fri tekst starter her -->
<h3><b><u>seneste:</u></b> <?=$seneste;?></h3>
<!-- Fri tekst stopper her -->
</td>
</tr>
<tr>
<td class="content">
<br>
<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
<tr>
<td><img src="/images/spacer.gif" height="1" width="10"></td>
<td width="194px" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="194">
<tr>
<td class="grayheader" style="padding-left:8px;">Community</td>
</tr>
<tr>
<td class="graybox" valign="top" style="padding:8px;">
<?php
if($_SESSION['login'] == "ok"){
$select_info = mysql_query("SELECT * FROM members WHERE user = '$_SESSION[username]'")or die(mysql_error());
while($row = mysql_fetch_array($select_info)){
$uid = $row['id'];
}
/*
0 = Alm Bruger
1 = Event-ansvarlig
2 = Jounalist
3 = Galleri-ansvarlig
4 = Møbelekspert
5 = Pixel-artist
6 = Moderator
7 = Ledelse
*/
?>
<li><a href="index.php?side=settings">»Din Forside</a></li>
<li><a href="index.php?side=tagwall">»tagwall</a></li>
<li><a href="index.php?side=indbakke">»Besked Central</a></li>
<li><a href="index.php?side=debat">»Debat</a></li>
<?
if ($_SESSION['admin_id'] >=1 && $_SESSION['admin_id'] <= 7) {
?>
<li><a href="index.php?side=admin/admin_funks">»Administration</a></li>
<?
}
?>
<li><a href="index.php?side=logout">»Log ud</a></li>
<?php
}
else {
?>
<form action="index.php?side=checklogin" method="post" class="loginform">
<lable class="inputlable">»Brugernavn:</lable>
<input type="text" name="user" class="input" value="" enabled/>
<lable class="inputlable">»Kodeord:</lable>
<input type="password" name="pass" class="input"/><br><br>
<input type="submit" name="submit" class="submit" value="Login" /><a href="index.php?side=register">Opret bruger</a>
</form>
<?
}
?>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="blueheader" style="padding-left:8px;">Tilfældig bruger</td>
</tr>
<tr>
<td class="allbox" valign="top" style="padding:8px;">
<?php
$select_user = mysql_query("SELECT * FROM members WHERE user = 'user'")or die(mysql_error());
while($row = mysql_fetch_array($select_user)){
$id = $row['id'];
$user = $row['user'];
$name = $row['name'];
$today_msg = $row['today_mag'];
}
include "connect.php"; // Alle oplysninger fra config.php bliver sendt herti
$sql = "select * from members order by rand() limit 1;";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
?>
<?php echo $row['today_msg'];?><br>
<a href="index.php?side=user_profiles&id=<? echo $row['id'];?>">Se Profil</a>
<?
$destination = "images/profile_pics/" . $id . ".jpg";
//Tjekker om profil billedet findes.
if(file_exists($destination)){
echo "<img src='" . $destination . "' width=\"75\" height=\"100\" /><br />";
}else{ //Hvis der ikke er noget profil billede. ?>
<img src="images/profile_pics/nopic.jpg"id="habuser2" />
<?php
}
}
?>
</span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="redheader" style="padding-left:8px;">Nyeste Tagwall indlæg!</td>
</tr>
<tr>
<td class="redbox" valign="top" style="padding:8px;">
<?php
include "connect.php"; // Alle oplysninger fra config.php bliver sendt hertil
$sql = "select * from tagwall order by id desc limit 1 ";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
?>
<? echo $row['user'];?> skrev D. <? echo $row['dato'];?><br><br>
<SPAN style="FONT-SIZE: 7pt"><? echo $row['besked'];?></SPAN>
<?php
}
?>
</td>
</tr>
</table>
</td>
<td><img src="/images/spacer.gif" height="1" width="5"></td>
<td width="80%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
<tr>
<td valign="bottom" align="right"><img src="/images/tlc.gif" width="4" height="4"></td>
<td class="content_top" width="100%"><img src="/images/spacer.gif" height="4" width="1"></td>
<td valign="bottom" align="left"><img src="/images/trc.gif" width="4" height="4"></td>
</tr>
<tr>
<td class="content_left"> </td>
<td class="content_text" width="100%" valign="top" style="padding: 10px;">
<?php //her starter vi vores side hvor alt skal vises
$side = addslashes($_GET['side']); // Lidt sikkerhed
if ($side) { // Hvis strengen $side er sat
if (file_exists("".$side.".php")) {
include("".$side.".php"); // Inkluder filen strengen peger på
} else {
include("fejl404.php");
}
} else { //Hvis strengen $side ikke var sat
include("forside.php"); //Inkluder forsiden
}
?>
<span class="content_left"></span><br>
</td>
<td class="content_right"> </td>
</tr>
<tr>
<td valign="bottom" align="right"><img src="/images/blc.gif" width="4" height="6"></td>
<td class="content_bottom" width="100%"><img src="/images/spacer.gif" height="1" width="1"></td>
<td valign="bottom" align="left"><img src="/images/brc.gif" width="4" height="6"></td>
</tr>
</table>
</td>
<td><img src="/images/spacer.gif" height="1" width="5"></td>
<td width="194px" valign="top">
<table cellpadding="0" cellspacing="0" border="0" align="center" width="194">
<tr>
<td class="greenheader" style="padding-left:8px;">Test</td>
</tr>
<tr>
<td class="allbox" valign="top" style="padding:8px;">
<?php /*
include "mobel_connect.php"; // Alle oplysninger fra config.php bliver sendt herti
$sql = "select * from random order by rand() limit 1;";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
?>
<? echo $row['navn'];?> - <? echo $row['pris'];?>Mønter & <? echo $row['hc'];?> Hc<br>
<?php
}*/
?>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="yellowheader" style="padding-left:8px;">Tilfældig link</td>
</tr>
<tr>
<td class="allbox" valign="top" style="padding:8px;">
<?php
include "connect.php"; // Alle oplysninger fra config.php bliver sendt herti
$sql = "select * from link order by rand() limit 1;";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
?>
<a href="http://<?=$row['link'];?>"><?=$row['navn'];?></a><br><br>
<?php
echo one_wordwrap($row['beskrivelse'], 24);
?>
<?php
}
?>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="pinkheader" style="padding-left:8px;">6 Nyeste brugere</td>
</tr>
<tr>
<td class="allbox" valign="top" style="padding:8px;">
<?php
include "connect.php"; // Alle oplysninger fra config.php bliver sendt herti
$sql = "select * from members order by id desc limit 6";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
?>
<a href="index.php?side=user_profiles&id=<?=$row['id'];?>"><?=$row['user'];?></a><br>
<?php
}
?>
</td>
</tr>
</table>
</td>
<td><img src="/images/spacer.gif" height="1" width="10"></td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td class="footer"> © 2009-2010 - Version 1.0.0 - Alle Rettigheder Forbeholdes. <a href="" onClick="this.style.behavior='url (#default#homepage)';this.setHomePage('http://coolboom.dk/'); return false;">» Gør til startside</a></td>
</tr>
</table>
</body>
</html>
<?php
function one_wordwrap($string, $length) {
$wrapped = '';
$word = '';
$html = false;
$string = (string) $string;
for($i=0;$i<strlen($string);$i+=1) {
$char = $string[$i];
/** HTML Begins */
if($char === '<') {
if(!empty($word)) {
$wrapped .= $word;
$word = '';
}
$html = true;
$wrapped .= $char;
}
/** HTML ends */
elseif($char === '>') {
$html = false;
$wrapped .= $char;
}
/** If this is inside HTML -> append to the wrapped string */
elseif($html) {
$wrapped .= $char;
}
/** Whitespace characted / new line */
elseif($char === ' ' || $char === "\t" || $char === "\n") {
$wrapped .= $word.$char;
$word = '';
}
/** Check chars */
else {
$word .= $char;
if(strlen($word) > $length) {
$wrapped .= $word."- ";
$word = '';
}
}
}
if($word !== ''){
$wrapped .= $word;
}
return $wrapped;
}
?>
___________________________________________________________
Hilsen Morten