ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Warning mysqlfetchassoc


  • 2005-08-21 10:30:46

    Warning mysqlfetchassoc

    When I try to add a new content page - get the following warnings: Any advice would be nice. thanks.

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /export/home/WebPages/Development/ATutor/include/classes/ContentManager.class.php on line 147

    Warning: Cannot modify header information - headers already sent by (output started at /export/home/WebPages/Development/ATutor/include/classes/ContentManager.class.php:147) in /export/home/WebPages/Development/ATutor/include/lib/editor_tab_functions.inc.php on line 161

  • 2005-08-22 12:33:24

    More info

    To be more specific about the problem:

    When I add a content page by keying in a title and some content into the html applet - I submit and I get the above listed warnings which force me to use my back buttom to return to the ATutor interface.

    I should note - that the content page does get created as it shows in the course outline. I can edit and submit changes to these pages with out any warnings. Just the initial creation throws warnings.

    This warning appears to be an avoidable programming issue.

    Any thoughts?

  • 2005-08-22 14:55:37

    the offending code

    $sql = "SELECT LAST_INSERT_ID() AS insert_id";
    $result = mysql_query($sql, $this->db);
    $row = mysql_fetch_assoc($result);
    $cid = $row['insert_id'];

  • 2005-08-22 15:06:18

    possible solution

    $sql = 'SELECT max(content_id) as insert_id from at_content';

    $result = mysql_query($sql, $this->db)

    if($result && mysql_num_rows($result)==1){
    $row = mysql_fetch_assoc($result);
    $cid = $row['insert_id'];
    }
    else
    {//some code }

  • 2005-08-23 12:11:35

    platform specs

    OS - Solaris 2.8
    PHP 4.3.8
    Apache 2.0.49
    MySQL 3.23.49

    Any advice would be muchly appreciated.

  • 2005-08-23 16:28:19

    solution

    I substituted code at line 147 of ContentMangerClass...

    $sql = "SELECT LAST_INSERT_ID() AS insert_id";
    $result = mysql_query($sql, $this->db);
    $row = mysql_fetch_assoc($result);
    $cid = $row['insert_id'];

    for .....

    $cid = mysql_insert_id();

    No warnings - seems to work for now.