PHP5 Help

Discussion in 'PHP' started by donteatchicken, Aug 2, 2006.

  1. #1
    After I upgraded to PHP5 this fuction no longer works, anyone have any idea why?

    function members_online()	{
    	$m_id=cookie_get("mem_id");
    	$m_pass=cookie_get("mem_pass");
    	login_test($m_id,$m_pass);
    	$page=form_get("page");
    	if(empty($page))	$page=1;
    	$start=($page-1)*20;
    	$sql_query="select mem_id from members where online='on' limit $start,100";
    	$res=sql_execute($sql_query,'res');
    	$p_sql="select mem_id from members where online='on'";
    	$p_url="index.php?mode=user&act=onlines";
    	show_header();
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="body lined">
      <tr>
        <td class="title">&nbsp;Online Members</td>
      </tr>
    <? if(mysql_num_rows($res)) { ?>
    <? $s=0; ?>
      <tr>
        <td class="body"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <? while($row==mysql_fetch_object($res)) { ?>
    <? if($s==0) { ?>
            <tr>
    <? } ?>
              <td valign="top" align="center" class="body"><b><? echo jans($row->mem_id, gender); ?></b></td>
    <? $s++; ?>
    <? if($s==5) { ?>
            </tr>
    <? $s=0; ?>
    <? } ?>
    <? } ?>
          </table></td>
      </tr>
      <tr>
        <td class="body" align="right"><? echo page_nums($p_sql,$p_url,$page,20); ?>&nbsp;&nbsp;</td>
      </tr>
    <? } else { ?>
      <tr>
        <td class="body" align="center">No members are online now!</td>
      </tr>
    <? } ?>
    </table>
    <?
    	show_footer();
    }
    PHP:

    Thanks..
     
    donteatchicken, Aug 2, 2006 IP
  2. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    oh could be dozen of things!
    is your php compiled with mysql extensions?? (mysql doesnt come by default with php5 btw)

    look into phpinfo for above

    also look into objects, and PDO for data acces, heres sample from my php5 user class (notice bound parameters )

    also look into MVC pattern
    
    
    	/**
    	 * retrieves a user
    	 *
    	 * @param int, $user_id
    	 * @param string, $user_hash
    	 */
    	public function retriveByUserIdAndHash( $user_id, $password ){
    		
    		
    		try {
    			$STMT = $this->DB->prepare("SELECT username, group_id, password
    										FROM users 
    										WHERE user_id = :user_id  
    										AND password = :password" );
    			
    	
    	
    			$STMT->bindParam( ":user_id", 	$user_id,	PDO::PARAM_INT );
    			$STMT->bindParam( ":password", 	$password,  PDO::PARAM_STR, 32);
    
    			
    			$STMT->execute();
    		
    			$user	=	$STMT->fetch(PDO::FETCH_ASSOC);
    		} 
    		catch (PDOException $e) {
    	   
    			Base::handleException($e);
    		}
    		
    		return $user;
    	}
    
    PHP:
     
    wwm, Aug 2, 2006 IP
    ahkip likes this.
  3. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do you get any errors? If not, try putting
    error_reporting(E_ALL);
    PHP:
    at the top of the PHP file. You should get some line numbers then. Or you can try some 'blah debugging' ( © Coderlinks :D ) . You put
    echo 'blah';exit;
    PHP:
    at different places and you can find out exactly where the error occurs.

    Thomas
     
    coderlinks, Aug 3, 2006 IP