Select a table from a database (SQL Error)???

Discussion in 'MySQL' started by techspott, May 1, 2010.

  1. #1
    Im getting this error on my site:

    Database error.
    
    [01/05/2010 19:21:40] MySQL: Invalid Query: SELECT count(FriendID) from ava_friends where UserID =1 SQL error: 0 ()
    Code (markup):
    The Php Code is like this:

    <?php 
    	$friendsql = "SELECT count(FriendID) from ava_friends where UserID =".$profile['id'];
    	$DB->query($friendsql);
    	list($FriendCount) = $DB->next_record();
    ?>
    PHP:
    Can somebody help me...?
     
    techspott, May 1, 2010 IP
  2. Lam3r

    Lam3r Active Member

    Messages:
    235
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Try:
    
    <?php
        $friendsql = "SELECT 'count(FriendID)' from ava_friends where UserID =".$profile['id'];
        $DB->query($friendsql);
        list($FriendCount) = $DB->next_record();
    ?>
    PHP:
    Untested, let me know.
     
    Lam3r, May 2, 2010 IP
  3. techspott

    techspott Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Now Im getting this error,
    
    Database error.
    
    [03/05/2010 10:23:32] MySQL: Invalid Query: SELECT 'count(FriendID)' from ava_friends where UserID =1 SQL error: 0 ()
    
    PHP:
     
    techspott, May 2, 2010 IP