Problemi estrazione username

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
per vedere se si viene a capo del problema prova a fare a parte l'ultimo script che ti avevo inviato, con le modifiche sotto, lo esegui e mi sai dire cosa restituitscono i var_dump

PHP:
<?php
//****qui metti i dati di connessione
$q=mysql_query("SELECT user_1, user_2 FROM relationship WHERE user_1=$uid OR user_2=$uid AND amici='S'"); 
while($am=mysql_fetch_array($q)){ 
    $amici_grezzi[]=$am['user_1']; 
    $amici_grezzi[]=$am['user_2']; 
} 
var_dump($amici_grezzi);echo "<br><br>";
$amici=array_unique($amici_grezzi); 
var_dump($amici_grezzi);echo "<br><br>";
foreach($amici AS $valore){ 
    $q=mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages AS M, users AS U WHERE M.uid_fk=$valore"); 
    $row=mysql_fetch_array($q);
	/* ******************************************
	qui ho un piccolo dubbio
	essendo $row un array, $data diventa un array di array
	quindi per estrarre i dati si dovrebbe fare un doppio foreach o usare serialize/unserialize
	****************************************** */
    $data[]=$row;
} 
//quindi per verificare
var_dump($data);echo "<br><br>";
?>
questo perchè (salvo il dubbio) dovrebbe funzionare

dimentivavo: mettendo un valore effettivo al posto di $uid
 
Ultima modifica:

searedone

Utente Attivo
11 Giu 2010
508
0
0
Ciao,
vardump mi restituiscono

NULL
NULL
NULL

Senza mi da il form dove scrivere ma non mi pronta i post vecchi, e se ne faccio uno nuovo me lo pronta ma al refresh pagina bianca :(
 

minatore

Utente Attivo
25 Set 2007
410
0
0

Ciao, ho cercato di seguire la discussione, ed ho visto il db, non riesco a capire come relazioni le tabelle tra loro, visto che ad un certo punto borgo ha detto
meglio ricominciare da capo
in breve posto le tue tabelle
tab_user
Codice:
uid
fullname
username
tab_messaggi
Codice:
msg_id
messaggio
uid_fk
tab_relationship
Codice:
id
user1
user2
amico
la domanda che vorrei porti come fai ad avere relazioni tra tabelle senza una chiave esterna
può darsi che mi sono perso qualcosa nella discussione, me ne scuso, solo per capire
Ciao
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
Ciao,
grazie mille per l'interessamento ...

le tabelle in relazione sono comments

PHP:
CREATE TABLE IF NOT EXISTS `comments` (
  `com_id` int(11) NOT NULL AUTO_INCREMENT,
  `comment` varchar(200) DEFAULT NULL,
  `msg_id_fk` int(11) DEFAULT NULL,
  `uid_fk` int(11) DEFAULT NULL,
  `ip` varchar(30) DEFAULT NULL,
  `created` int(11) DEFAULT '1269249260',
  PRIMARY KEY (`com_id`),
  KEY `msg_id_fk` (`msg_id_fk`),
  KEY `uid_fk` (`uid_fk`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ;


messages

PHP:
CREATE TABLE IF NOT EXISTS `messages` (
  `msg_id` int(11) NOT NULL AUTO_INCREMENT,
  `message` varchar(200) DEFAULT NULL,
  `uid_fk` int(11) DEFAULT NULL,
  `ip` varchar(30) DEFAULT NULL,
  `created` int(11) DEFAULT '1269249260',
  PRIMARY KEY (`msg_id`),
  KEY `uid_fk` (`uid_fk`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;
 

minatore

Utente Attivo
25 Set 2007
410
0
0
Ciao, quibdi quello che nnon ti torna è questa parte di codice
PHP:
$q=mysql_query("SELECT user_1, user_2 FROM relationship WHERE user_1=$uid OR user_2=$uid AND amici='S'");  
while($am=mysql_fetch_array($q)){  
    $amici_grezzi[]=$am['user_1'];  
    $amici_grezzi[]=$am['user_2'];  
}
adesso vorrei capire quello $uid, cosa rappresenta la chiave primaria della tabella relationship
quindi se mettessi al posto di $uid una costante tipo 1 non dovrei avere problemi a farmi ritornare user_1 e user_2

spero di aver capito
Ciao
 
Ultima modifica:

searedone

Utente Attivo
11 Giu 2010
508
0
0
Ciao ..

$q=mysql_query("SELECT user_1, user_2 FROM relationship WHERE user_1=$uid OR user_2=$uid AND amici='S'");
while($am=mysql_fetch_array($q)){
$amici_grezzi[]=$am['user_1'];
$amici_grezzi[]=$am['user_2'];
}
In questa join non funzia nulla :( o meglio si forma il form per scrivere ma non mi pronta i risultati del db ....

mentre in questa che funziona correttamente ho il problema che se aggiungo U.username e users AS U al posto di postarmi solo il post dell'utente loggiato mi posta
il post per tutti gli utenti loggati, di contro se tolgo non mi da l'username di chi ha postato :(

cosi perfect ma no username

PHP:
class Wall_Updates {


    
     // Updates   	
	  public function Updates($uid) 
	{
	
		 $query = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created FROM messages M WHERE   M.uid_fk='$uid' OR M.uid_fk IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$uid' AND r.amico = 'S') OR M.uid_fk IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$uid' AND r.amico = 'S') order by M.msg_id desc  ") or die(mysql_error());     
		 while($row=mysql_fetch_array($query))
		$data[]=$row;
	    return $data;
		
    }

cosi i risultati per tutti gli users ... uffaaaa

PHP:
class Wall_Updates {


    
     // Updates   	
	  public function Updates($uid) 
	{
	
		 $query = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages AS M users AS U WHERE  M.uid_fk=U.uid and   M.uid_fk='$uid' OR M.uid_fk IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$uid' AND r.amico = 'S') OR M.uid_fk IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$uid' AND r.amico = 'S') order by M.msg_id desc  ") or die(mysql_error());     
		 while($row=mysql_fetch_array($query))
		$data[]=$row;
	    return $data;
		
    }
 

minatore

Utente Attivo
25 Set 2007
410
0
0
Ciao, sto provando a fare la query, ma non so
Codice:
$uid
cosa rappresenta, quale chiave primaria e se è presente in entrambe le tabelle
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
ciao

$uid è la chiave primaria della tabella users

PHP:
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `md5_id` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `full_name` tinytext COLLATE latin1_general_ci NOT NULL,
  `user_name` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_email` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_level` tinyint(4) NOT NULL DEFAULT '1',
  `pwd` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `address` text COLLATE latin1_general_ci NOT NULL,
  `country` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `tel` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `fax` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `website` text COLLATE latin1_general_ci NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `users_ip` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `approved` int(1) NOT NULL DEFAULT '0',
  `activation_code` int(10) NOT NULL DEFAULT '0',
  `banned` int(1) NOT NULL DEFAULT '0',
  `ckey` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `ctime` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_email` (`user_email`),
  FULLTEXT KEY `idx_search` (`full_name`,`address`,`user_email`,`user_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=58 ;
 

minatore

Utente Attivo
25 Set 2007
410
0
0
ciao

$uid è la chiave primaria della tabella users

PHP:
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `md5_id` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `full_name` tinytext COLLATE latin1_general_ci NOT NULL,
  `user_name` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_email` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_level` tinyint(4) NOT NULL DEFAULT '1',
  `pwd` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `address` text COLLATE latin1_general_ci NOT NULL,
  `country` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `tel` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `fax` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `website` text COLLATE latin1_general_ci NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `users_ip` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `approved` int(1) NOT NULL DEFAULT '0',
  `activation_code` int(10) NOT NULL DEFAULT '0',
  `banned` int(1) NOT NULL DEFAULT '0',
  `ckey` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `ctime` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_email` (`user_email`),
  FULLTEXT KEY `idx_search` (`full_name`,`address`,`user_email`,`user_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=58 ;

Aspetta, ma a te serve username della tabella user o user_1, user_2 della tanella relationship
per capire
Ascolta, se vuoi estrapolare user_1, user_2 in base all'id della tabella user ci vuole una chiave esterna nella tabella relationship, perchè da come ho capito, tu vorresti user_1 e user_2 che sarebbero gli amici con riferimento all'id della tabella user
Ciao
Borgo fatti sentire se sto in errore
Ciao
 
Ultima modifica:

searedone

Utente Attivo
11 Giu 2010
508
0
0
ti riposto la tabella users corretta....


PHP:
CREATE TABLE IF NOT EXISTS `users` (
  `uid` bigint(20) NOT NULL AUTO_INCREMENT,
  `md5_id` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `full_name` tinytext COLLATE latin1_general_ci NOT NULL,
  `username` varchar(255) COLLATE latin1_general_ci DEFAULT NULL,
  `user_email` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `email` varchar(100) COLLATE latin1_general_ci NOT NULL,
  `user_level` tinyint(4) NOT NULL DEFAULT '1',
  `pwd` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `address` text COLLATE latin1_general_ci NOT NULL,
  `country` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `tel` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `fax` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `website` text COLLATE latin1_general_ci NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `users_ip` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `approved` int(1) NOT NULL DEFAULT '0',
  `activation_code` int(10) NOT NULL DEFAULT '0',
  `banned` int(1) NOT NULL DEFAULT '0',
  `ckey` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `ctime` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `nome_file_vero` varchar(255) COLLATE latin1_general_ci NOT NULL,
  `tipo_file` varchar(255) COLLATE latin1_general_ci NOT NULL,
  `dati_file` longblob NOT NULL,
  `uid_fk` int(11) NOT NULL,
  PRIMARY KEY (`uid`),
  UNIQUE KEY `user_email` (`user_email`),
  UNIQUE KEY `username` (`username`),
  FULLTEXT KEY `idx_search` (`full_name`,`address`,`user_email`,`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=66 ;

vediamo se riesco a farti capire questa è una classe, la tabella relationship serve solo per far si che i post li vedano gli amici di un po' come fb o twitter.

nel messaggio postato si dovrebbe vedere la foto il nome dell'users (username ) e il mex ... ricavo tutto qui

PHP:
 <?php
//Srinivas Tamada http://9lessons.info
//Loading Comments link with load_updates.php 
foreach($updatesarray as $data)
 {
 $msg_id=$data['msg_id'];
 $orimessage=$data['message'];
 $message=tolink(htmlentities($data['message']));
  $time=$data['created'];
   $username=$data['username'];
 $uid=$data['uid_fk'];
 $face=$Wall->Gravatar($uid);
 $commentsarray=$Wall->Comments($msg_id);
?>

<script type="text/javascript"> 
$(document).ready(function(){$("#stexpand<?php echo $msg_id;?>").oembed("<?php echo  $orimessage; ?>",{maxWidth: 400, maxHeight: 300});});
</script>
<div class="stbody" id="stbody<?php echo $msg_id;?>">

<div class="stimg">
<img src="<?php echo $face;?>" class='big_face'/>
</div> 
<div class="sttext">
<a class="stdelete" href="#" id="<?php echo $msg_id;?>" title="Delete update">X</a>
<b><?php echo " <a href=\"profile.php?uid=$uid\"/>$username</a>";  ?></b> <?php echo $message;?>
<div class="sttime"><?php time_stamp($time);?> | <a href='#' class='commentopen' id='<?php echo $msg_id;?>' title='Comment'>Comment </a></div> 

<div id="stexpandbox">
<div id="stexpand<?php echo $msg_id;?>"></div>
</div>

<div class="commentcontainer" id="commentload<?php echo $msg_id;?>">


<?php include('load_comments.php') ?>





</div>
<div class="commentupdate" style='display:none' id='commentbox<?php echo $msg_id;?>'>
<div class="stcommentimg">
<img src="<?php echo $face;?>" class='small_face'/>
</div> 
<div class="stcommenttext" >
<form method="post" action="">

<textarea name="comment" class="comment" maxlength="200"  id="ctextarea<?php echo $msg_id;?>"></textarea>
<br />
<input type="submit"  value=" Comment "  id="<?php echo $msg_id;?>" class="comment_button"/>
</form>


</div>
</div>


</div> 

</div>


<?php

  }
?>

ma togliendo U.username e users U dalla query il nome dell'users username me lo perde , o meglio quando scrivo me lo posta ma quando refresh la pagina sparisce ...

asp ti posto anche la classe completa magari ti può' servire

PHP:
<?php



class Wall_Updates {


    
     // Updates   	
	  public function Updates($uid) 
	{
	
		 $query = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created  FROM messages M  WHERE   M.uid_fk='$uid' OR M.uid_fk IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$uid' AND r.amico = 'S') OR M.uid_fk IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$uid' AND r.amico = 'S') order by M.msg_id desc  ") or die(mysql_error());     
		 while($row=mysql_fetch_array($query))
		$data[]=$row;
	    return $data;
		
    }
    
    
    
	//Comments
	   public function Comments($msg_id) 
	{
	    $query = mysql_query("SELECT C.com_id, C.uid_fk, C.comment, C.created, U.username FROM comments C, users U WHERE C.uid_fk=U.uid and C.msg_id_fk='$msg_id' order by C.com_id asc ") or die(mysql_error());
	   while($row=mysql_fetch_array($query))
	    $data[]=$row;
        if(!empty($data))
		{
       return $data;
         }
	}
	
	//Avatar Image
	public function Gravatar($uid) 
	{
	    $query = mysql_query("SELECT nome_file_vero FROM `users` WHERE uid='$uid'") or die(mysql_error());
	   $row=mysql_fetch_array($query);
	   if(!empty($row))
	   {
	    $email=$row['email'];
	    $nome_file_vero=$row['nome_file_vero'];
        $lowercase = strtolower(nome_file_vero);
        $nome_file_vero = md5( $lowercase );
		$data="http://www.gravatar.com/avatar.php?gravatar_id=$imagecode";
		return $data;
         }
		 else
		 {
		 $data="default.jpg";
		return $data;
		 }
	}
	
	//Insert Update
	public function Insert_Update($uid, $update) 
	{
	$update=htmlentities($update);
	   $time=time();
	   $ip=$_SERVER['REMOTE_ADDR'];
        $query = mysql_query("SELECT msg_id,message FROM `messages` WHERE uid_fk='$uid' order by msg_id desc limit 1") or die(mysql_error());
        $result = mysql_fetch_array($query);
		
        if ($update!=$result['message']) {
            $query = mysql_query("INSERT INTO `messages` (message, uid_fk, ip,created) VALUES ('$update', '$uid', '$ip','$time')") or die(mysql_error());
            $newquery = mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages M, users U where M.uid_fk=U.uid and M.uid_fk='$uid' order by M.msg_id desc limit 1 ");
            $result = mysql_fetch_array($newquery);
			 return $result;
        } 
		else
		{
				 return false;
		}
		
       
    }
	
	//Delete update
		public function Delete_Update($uid, $msg_id) 
	{
	    $query = mysql_query("DELETE FROM `comments` WHERE msg_id_fk = '$msg_id' ") or die(mysql_error());
        $query = mysql_query("DELETE FROM `messages` WHERE msg_id = '$msg_id' and uid_fk='$uid'") or die(mysql_error());
        return true;
      	       
    }
	
	//Insert Comments
	public function Insert_Comment($uid,$msg_id,$comment) 
	{
	$comment=htmlentities($comment);
	   	    $time=time();
	   $ip=$_SERVER['REMOTE_ADDR'];
        $query = mysql_query("SELECT com_id,comment FROM `comments` WHERE uid_fk='$uid' and msg_id_fk='$msg_id' order by com_id desc limit 1 ") or die(mysql_error());
        $result = mysql_fetch_array($query);
    
		if ($comment!=$result['comment']) {
            $query = mysql_query("INSERT INTO `comments` (comment, uid_fk,msg_id_fk,ip,created) VALUES ('$comment', '$uid','$msg_id', '$ip','$time')") or die(mysql_error());
            $newquery = mysql_query("SELECT C.com_id, C.uid_fk, C.comment, C.msg_id_fk, C.created, U.username FROM comments C, users U where C.uid_fk=U.uid and C.uid_fk='$uid' and C.msg_id_fk='$msg_id' order by C.com_id desc limit 1 ");
            $result = mysql_fetch_array($newquery);
         
		   return $result;
        } 
		else
		{
		return false;
		}
       
    }
	
	//Delete Comments
		public function Delete_Comment($uid, $com_id) 
	{
	    $query = mysql_query("DELETE FROM `comments` WHERE uid_fk='$uid' and com_id='$com_id'") or die(mysql_error());
        return true;
      	       
    }

    

}

?>
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
Aggiungerei mannaggia a me quando mi sono impegolato con sta cosa ..

stavo facendo tutto a manina ma riscontrando qualche difficoltà a fare il commento al post della bacheca che funzionava egregiamente, sotto consiglio ho voluto utilizzare questa classe già pronta sistemandola a mio piacere .....

UFFAA infatti mi chiedo se forse sia un bene e se non sia meglio aprire un'altro post e chiedere come posso aggiungere i commenti al progetto originale ..

Accetto consigli

Per ora grazie mille @ Borgo, e @ Minatore
 

minatore

Utente Attivo
25 Set 2007
410
0
0
ma togliendo U.username e users U dalla query il nome dell'users username me lo perde , o meglio quando scrivo me lo posta ma quando refresh la pagina sparisce ...
Ciao, se è come dici, che perdi l'user al refresh dovresti metterlo in una variabile di sessione
allora il prblema non è più la query, ma mantenere sto benedetto user
spero di aver capito
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
Giusto ....

se vuoi ti posso far provare ....

il sito è on line ........ ti do un user e una pass di prova ... dimmi se la cosa ti potrebbe aiutare
 

minatore

Utente Attivo
25 Set 2007
410
0
0
Giusto ....

se vuoi ti posso far provare ....

il sito è on line ........ ti do un user e una pass di prova ... dimmi se la cosa ti potrebbe aiutare


Aspetta prima cerchiamo di mettere i dati che ti servono in una sessione, mi posti il codice dove ti ricavi questi dati che vuoi portare avanti
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
index.php

PHP:
<?php
error_reporting(0);
include_once 'includes/db.php';
include_once 'includes/functions2.php';
include_once 'includes/tolink.php';
include_once 'includes/time_stamp.php';
include_once 'session.php';

$Wall = new Wall_Updates();
$updatesarray=$Wall->Updates($uid);
?>
<!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>Version 3.0</title>
<link href="css/wall.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="js/jquery.oembed.js"></script>
 <script type="text/javascript" src="js/wall.js"></script>
</head>
<body>
<div id="wall_container">
<div id="updateboxarea">
<h4>What's up?</h4>
<form method="post" action="">
<textarea cols="30" rows="4" name="update" id="update" maxlength="200" ></textarea>
<br />
<input type="submit"  value=" Update "  id="update_button"  class="update_button"/>
</form>
</div>
<div id='flashmessage'>
<div id="flash" align="left"  ></div>
</div>
<div id="content">

<?php include('load_messages.php'); ?>



messages_ajax.php

PHP:
 <?php
 //Srinivas Tamada http://9lessons.info
//Load latest update 
error_reporting(0);
include_once 'includes/db.php';
include_once 'includes/functions2.php';
include_once 'includes/tolink.php';
include_once 'includes/time_stamp.php';
include_once 'session.php';
$Wall = new Wall_Updates();
if(isSet($_POST['update']))
{
$update=$_POST['update'];
$data=$Wall->Insert_Update($uid,$update);

if($data)
{
$msg_id=$data['msg_id'];
$message=tolink(htmlentities($data['message']));
$time=$data['created'];
$uid=$data['uid_fk'];
$username=$data['username'];
$face=$Wall->Gravatar($uid);
//$commentsarray=$Wall->Comments($msg_id);
?>
<div class="stbody" id="stbody<?php echo $msg_id;?>">
<div class="stimg">
<img src="<?php echo $face;?>" class='big_face'/>
</div> 
<div class="sttext">
<a class="stdelete" href="#" id="<?php echo $msg_id;?>" title='Delete update'>X</a>
<b><?php echo $username;?></b> <?php echo $message;?>
<div class="sttime"><?php time_stamp($time);?> | <a href='#' class='commentopen' id='<?php echo $msg_id;?>' title='Comment'>Comment </a></div> 
<div id="stexpandbox">
<div id="stexpand"></div>
</div>
<div class="commentcontainer" id="commentload<?php echo $msg_id;?>">
<?php// include('load_comments.php') ?>
</div>
<div class="commentupdate" style='display:none' id='commentbox<?php echo $msg_id;?>'>
<div class="stcommentimg">
<img src="<?php echo $face;?>" class='small_face'/>
</div> 
<div class="stcommenttext" >
<form method="post" action="">
<textarea name="comment" class="comment" maxlength="200"  id="ctextarea<?php echo $msg_id;?>"></textarea>
<br />
<input type="submit"  value=" Comment "  id="<?php echo $msg_id;?>" class="comment_button"/>
</form>
</div>
</div>
</div> 
</div>
<?php
}
}
?>

load_messages.php

PHP:
<?php
//Srinivas Tamada http://9lessons.info
//Loading Comments link with load_updates.php 
foreach($updatesarray as $data)
 {
 $msg_id=$data['msg_id'];
 $orimessage=$data['message'];
 $message=tolink(htmlentities($data['message']));
  $time=$data['created'];
   $username=$data['username'];
 $uid=$data['uid_fk'];
 $face=$Wall->Gravatar($uid);
 $commentsarray=$Wall->Comments($msg_id);
?>

<script type="text/javascript"> 
$(document).ready(function(){$("#stexpand<?php echo $msg_id;?>").oembed("<?php echo  $orimessage; ?>",{maxWidth: 400, maxHeight: 300});});
</script>
<div class="stbody" id="stbody<?php echo $msg_id;?>">

<div class="stimg">
<img src="<?php echo $face;?>" class='big_face'/>
</div> 
<div class="sttext">
<a class="stdelete" href="#" id="<?php echo $msg_id;?>" title="Delete update">X</a>
<b><?php echo " <a href=\"profile.php?uid=$uid\"/>$username</a>";  ?></b> <?php echo $message;?>
<div class="sttime"><?php time_stamp($time);?> | <a href='#' class='commentopen' id='<?php echo $msg_id;?>' title='Comment'>Comment </a></div> 

<div id="stexpandbox">
<div id="stexpand<?php echo $msg_id;?>"></div>
</div>

<div class="commentcontainer" id="commentload<?php echo $msg_id;?>">


<?php include('load_comments.php') ?>





</div>
<div class="commentupdate" style='display:none' id='commentbox<?php echo $msg_id;?>'>
<div class="stcommentimg">
<img src="<?php echo $face;?>" class='small_face'/>
</div> 
<div class="stcommenttext" >
<form method="post" action="">

<textarea name="comment" class="comment" maxlength="200"  id="ctextarea<?php echo $msg_id;?>"></textarea>
<br />
<input type="submit"  value=" Comment "  id="<?php echo $msg_id;?>" class="comment_button"/>
</form>


</div>
</div>


</div> 

</div>


<?php

  }
?>
 

minatore

Utente Attivo
25 Set 2007
410
0
0
index.php

PHP:
$username=$data['username'];

prova a mettere cosi
PHP:
$_SESSION['user'] = $data['username'];
poi all'inizio di ogni pagina non dimenticare di mettere questo
PHP:
session_start();
altrimenti la sessione non funziona
facendo in questo modo ti porti quel
Codice:
$data['username'];
dove vuoi
Ciao, vediamo se ne usciamo
Dimenticavo, prova a farti stampare $_SESSION['user'];
 
Ultima modifica:

searedone

Utente Attivo
11 Giu 2010
508
0
0

prova a mettere cosi
PHP:
$_SESSION['user'] = $data['username'];

dove intendi ???

intendi qui ???

PHP:
<?php
error_reporting(0);
include_once 'includes/db.php';
include_once 'includes/functions2.php';
include_once 'includes/tolink.php';
include_once 'includes/time_stamp.php';
include_once 'session.php';

$Wall = new Wall_Updates();
$updatesarray=$Wall->Updates($uid);
$username=$data['username'];  
?>
<!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>Version 3.0</title>
<link href="css/wall.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="js/jquery.oembed.js"></script>
 <script type="text/javascript" src="js/wall.js"></script>
</head>
<body>
<div id="wall_container">
<div id="updateboxarea">
<h4>What's up?</h4>
<form method="post" action="">
<textarea cols="30" rows="4" name="update" id="update" maxlength="200" ></textarea>
<br />
<input type="submit"  value=" Update "  id="update_button"  class="update_button"/>
</form>
</div>
<div id='flashmessage'>
<div id="flash" align="left"  ></div>
</div>
<div id="content">

<?php include('load_messages.php'); ?>
poi all'inizio di ogni pagina non dimenticare di mettere questo
PHP:
session_start();

Questo lo ho in tutte le pagine che richiamano lo script

PHP:
<?php
session_start();
$uid=$_SESSION['user_uid']; 
?>

esattamente qui
PHP:
  <?php 
error_reporting(0); 
include_once 'includes/db.php'; 
include_once 'includes/functions2.php'; 
include_once 'includes/tolink.php'; 
include_once 'includes/time_stamp.php'; 
include_once 'session.php';

devo aggiungerlo anche in loda_masseges che non c'è ???



altrimenti la sessione non funziona
facendo in questo modo ti porti quel
Codice:
$data['username'];

Così dovrebbe funzionare ovunque se lo scrivo anche in loda_messages ecc ecc
dove vuoi
Ciao, vediamo se ne usciamo

Speriamo di uscirne sto impazzendo
 

minatore

Utente Attivo
25 Set 2007
410
0
0

Ciao, vediamo di lavorare sulla pagina interessata cioè quella dove vorresti che apparisse username
prova afartelo stampare
 
Discussioni simili
Autore Titolo Forum Risposte Data
N Problemi estrazione / visualizzazione immagini dal database con PDO PHP 2
I winrar: problemi con l'estrazione dei file Windows e Software 7
grottafelix Problemi estrazione campo Classic ASP 23
N php problemi a visualizzare video PHP 3
T problemi con dati menu a tendina HTML e CSS 2
T problemi di connessione MySQL 2
M Upload immagine con javascript problemi con FormData() Javascript 1
F Problemi visualizzazione mappa Android studio Sviluppo app per Android 0
S Problemi Javascript + Aruba Javascript 2
A Problemi con move_uploaded_file PHP 7
M Problemi con la stampa dei valori in php PHP 1
L Problemi con il login PHP 2
L Problemi form Pagina php HTML e CSS 3
R Tutto su utf-8 ma ancora problemi con i caratteri speciali in mysql MySQL 1
Z problemi con foreach insert into PHP 10
B javascript per problemi con pdf e Safari Javascript 0
N Problemi kit videosorveglianza IP Cam e Videosorveglianza 0
M Problemi con creazione maschere Presentati al Forum 1
M Problemi con query a più tabelle PHP 3
R Problemi anomalo insermento in db PHP 9
S Problemi delle funzioni eliminate con PHP e MySQL PHP 4
S Problemi di un principiante PHP 3
M Problemi con blog Grav CMS (Content Management System) 0
F Problemi di visualizzazione di un sito su più browser WordPress 0
S Problemi di visualizzazione form contatti sito web HTML e CSS 2
S incoerenza di stampa. problemi con il magenta Photoshop 3
A problemi con paypall Java 1
A Problemi di accesso da remoto a Ipcam IP Cam e Videosorveglianza 5
michele81 [WordPress] problemi plug meteo api key WordPress 4
E Problemi in registrazione telecamere Dahua IP Cam e Videosorveglianza 6
S Problemi con modulo upload video php (help!) PHP 0
felino [Windows 8.1] Problemi con connessione WiFi Windows e Software 0
M [PHP] Problemi su inserimento array nel db PHP 7
E [PHP] problemi nuova riga con fwrite su piattaforma android PHP 5
M [PHP] Problemi di salvataggio su campo calcolato PHP 0
O [HTML] problemi con la regola "background-attachment: fixed" in EDGE HTML e CSS 0
M [PHP] Problemi con query unione PHP 11
M [PHP] Problemi con select PHP 6
Spown [WordPress] Problemi visualizzazione su più browser + voci menu in movimento WordPress 1
ANDREA20 [HTML] problemi con il footer HTML e CSS 1
D [MS Access] problemi con inserimento campo in una maschera MS Access 6
M [PHP] Problemi con il riconoscimento login. PHP 21
A [WordPress] problemi con xampp WordPress 2
M Problemi con database Apache/2.4.37 (Win32) OpenSSL/1.1.1a PHP/7.3.1 PHP 6
P Problemi comunicazioni Comunicazioni dallo Staff 8
G I problemi non vengono solo per nuocere Presentati al Forum 0
A Problemi Wi-Fi Fastweb Reti LAN e Wireless 4
C [WordPress] Url vulnerability e problemi sito da mobile WordPress 0
S [PHP] problemi con le sessioni PHP 3
B Problemi accesso Instagram Smartphone e tablet 1

Discussioni simili