Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    343

    Problemi estrazione username

    buonasera a tutti, spero che tra di voi qualcuno possa darmi una mano
    perché non so più dove sbattere la testa ;(

    Ho una classe che vi posto due script mi dovrebbero restituire il messaggio con la foto e ok, ma non mi restituisce l'username ma l'id e l'username non mi viene fuori...

    Spero davvero che qualcuno mi illumini o mi dica cosa sbaglio .

    Classe functions

    Codice 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 u.username FROM users AS u WHERE u.uid = u.uid AND u.uid = u.username )  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;
                     
        }

        

    }

    ?>

    La query incriminata

    Codice 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 u.username FROM users AS u WHERE u.uid = u.uid AND u.uid = u.username )  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;
            
        } 
    dove la recupero ..

    Messages

    Codice 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();
    if(isSet(
    $_POST['update']))
    {
    $update=$_POST['update'];
    $data=$Wall->Insert_Update($uid,$update);

    if(
    $data)
    {

    $uid_fk=$_GET['uid'];
    $uid_fk=$_GET['username'];
    $msg_id=$data['msg_id'];
    $message=tolink(htmlentities($data['message']));
    $time=$data['created'];
    $username=$data['uid_fk'];
    $username=$data['username'];


    $nome_file_vero=$data['nome_file_vero'];
    $face=$Wall->Gravatar($uid);
    //$commentsarray=$Wall->Comments($msg_id);
    ?>

    <div class="stbody" id="stbody<?php echo $msg_id;?>">
    <div class="stimg">
    [img]<?php echo $face;?>[/img]

    </div> 
    <div class="sttext">
    [url="#"]" title='Delete update'>X[/url]
    [b]<?php echo $username ;?>[/b] <?php echo $message;?>


    <div class="sttime"><?php time_stamp($time);?> | [url='#']' title='Comment'>Comment [/url]</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]<?php echo $face;?>[/img]
    </div> 
    <div class="stcommenttext" >
    <form method="post" action="">
    <textarea name="comment" class="comment" maxlength="200"  id="ctextarea<?php echo $msg_id;?>"></textarea>


    <input type="submit"  value=" Comment "  id="<?php echo $msg_id;?>" class="comment_button"/>
    </form>
    </div>
    </div>
    </div> 
    </div>
    <?php
    }
    }
    ?>
    load_messages

    Codice PHP:
    <?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'];
     
    $username=$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]<?php echo $face;?>[/img]
    </div> 
    <div class="sttext">
    [url="#"]" title="Delete update">X[/url]
    [b]<?php echo $username;?>[/b] <?php echo $message;?>
    <div class="sttime"><?php time_stamp($time);?> | [url='#']' title='Comment'>Comment [/url]</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]<?php echo $face;?>[/img]
    </div> 
    <div class="stcommenttext" >
    <form method="post" action="">

    <textarea name="comment" class="comment" maxlength="200"  id="ctextarea<?php echo $msg_id;?>"></textarea>


    <input type="submit"  value=" Comment "  id="<?php echo $msg_id;?>" class="comment_button"/>
    </form>


    </div>
    </div>


    </div> 

    </div>


    <?php

      
    }
    ?>

  2. #2
    Nel codice postato non si capisce assolutamente nulla! Dici che la query incriminata si trova nel metodo Updates(), peccato però che esso non venga invocato da nessuna parte, poi semplicemente buttando un occhio ho notato:

    Codice PHP:
    ...
    if(
    $data)
    {

    $uid_fk=$_GET['uid'];
    $uid_fk=$_GET['username']; 
    ... 
    Magari un po' di attenzione in più nella stesura del codice...
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    343
    ...
    if($data)
    {

    $uid_fk=$_GET['uid'];
    $uid_fk=$_GET['username'];
    ...
    Hai proprio ragione ma prova e riprova mi saro' dimenticato di levarlo, ma non penso che il problema sia questo


    Nel codice postato non si capisce assolutamente nulla! Dici che la query incriminata si trova nel metodo Updates(), peccato però che esso non venga invocato da nessuna parte, poi semplicemente buttando un occhio ho notato:

    Se noti qui nel messages trovi

    $update=$_POST['update'];
    $data=$Wall->Insert_Update($uid,$update);



    Codice 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();
    if(isSet(
    $_POST['update']))
    {
    $update=$_POST['update'];
    $data=$Wall->Insert_Update($uid,$update);

    if(
    $data)
    {

    $uid_fk=$_GET['uid'];
    $uid_fk=$_GET['username'];
    $msg_id=$data['msg_id'];
    $message=tolink(htmlentities($data['message']));
    $time=$data['created'];
    $username=$data['uid_fk'];
    $username=$data['username'];

    e penso che richiami esattamente la query che trovi in functions


    Codice 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 u.username FROM users AS u WHERE u.uid = u.uid AND u.uid = u.username )  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
             
        }

  4. #4
    Io vedo che viene chiamato il metodo Insert_Update():

    Codice PHP:
    ...
    $data=$Wall->Insert_Update($uid,$update);
    ... 
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.