SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    shared whiteboard in javascript

    I am looking for a multi-user whiteboard (for personal use) similar to the one at http://www.danga.com/misc/jsdraw/xmlhttp.html. I have already tried Google. There are alot of them out there but non available for download to run on my site.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


  3. #3
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks g!!

  4. #4
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, I did everything in the tutorial and I can draw in the box but it doesn't "share" with other users and I get this monster error

    Code:
    Error updating the whiteboard: 
    [Error:
    name: TypeError
    message: Statement on line 476: Could not convert undefined or null to object
    Backtrace:
      Line 476 of linked script http://www.mywebsite.net/beta_web/beta_apps/test/whiteboard.js
        sessionId = (response.getElementsByTagName("session_id").item(0)).firstChild.data;
      Line 441 of linked script http://www.mywebsite.net/beta_web/beta_apps/test/whiteboard.js
        displayUpdates();
      At unknown location
        [statement source code not available]
    
    ]
    <br />
    <b>Fatal error</b>:  Call to a member function fetch_array() on a non-object in <b>/Library/Tenon/WebServer/WebSites/www.mysebsite.net/beta_web/beta_apps/test/whiteboard.class.php</b> on line <b>36</b><br />

    lines 475-478 of whiteboard.js
    Code:
      sessionId =
        response.getElementsByTagName("session_id").item(0).firstChild.data;  
      newLastDbLineId = 
        parseInt(response.getElementsByTagName("last_id").item(0).firstChild.data);
    lines 441-444 of whiteboard.js
    Code:
            displayUpdates();  
          }
          catch(e)
          {
    lines 33-36 of whiteboard.class.php
    Code:
        $check_load = 'SELECT SUM(length) total_length FROM whiteboard';
        // execute the SQL query
        $result = $this->mMysqli->query($check_load);
        $row = $result->fetch_array(MYSQLI_ASSOC);

  5. #5
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Changed 33 - 36(38) to this
    Code:
    $check_load = 'SELECT SUM(length) total_length FROM whiteboard';
    // execute the SQL query
    $result = $this->mMysqli->query($check_load);
    if(! $result = $this->mMysqli->query($check_load)) { 
    die( $mysqli->error()); 
    }
    When I do that I get this error (twice).

    Code:
    Error updating the whiteboard: 
    ERRNO: 8
    TEXT: Undefined variable: mysqli
    LOCATION: /Library/Tenon/WebServer/WebSites/www.mysite.net/beta_web/beta_apps/test/whiteboard.class.php, line 37
    ERRNO: 8
    TEXT: Undefined variable: mysqli
    LOCATION: /Library/Tenon/WebServer/WebSites/www.mysite.net/beta_web/beta_apps/test/whiteboard.class.php, line 37
    Line 37 of whiteboard.class.php
    Code:
    die( $mysqli->error());
    If I'm reading the script correctly that means it's failing to reach my database. Correct?

    Top half of whiteboard.class.php 1 - 40
    Code:
    <?php
    // load configuration file
    require_once('config.php');
    // load error handling file
    require_once('error_handler.php');
    // class handles server side whiteboard support functionality
    class Whiteboard
    {
      // database handler
      private $mMysqli;
      // define the number of maximum records in the table
      private $mMaxLoad = 5000;
      
      /* constructor opens database connection */
      function __construct() 
      {   
        $this->mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);          
      }
      
      /* destructor, closes database connection */  
      function __destruct() 
      {
        $this->mMysqli->close();
      }
      
      /*
        The checkLoad method clears the whiteboard table if
        it contains more than a specified number of records
      */
      public function checkLoad()
      {
        // build the SQL query to get the number of lines
        $check_load = 'SELECT SUM(length) total_length FROM whiteboard';
        // execute the SQL query
        $result = $this->mMysqli->query($check_load);
    	if(! $result = $this->mMysqli->query($check_load)) { 
      die( $mysqli->error()); 
    }

  6. #6
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that certainly seems correct. Can you confirm your connection else where?


  7. #7
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can connect to my database with other php pages using MY db_con.php. I'm not sure how to alter the whiteboard.class.php to use my db_con.php.

    my db_con.php
    Code:
    <?
    $db_hostname = "localhost";
    $db_name = "my_data";
    $db_username = "user";
    $db_password = "pass";
    
    	$db_link = @mysql_connect($db_hostname, $db_username, $db_password);
    		$db_get = mysql_select_db($db_name, $db_link);
    
    ?>
    the config.php that came with the script
    Code:
    <?
    // defines database connection data
    define("DB_HOST", "localhost");
    define("DB_USER", "user");
    define("DB_PASSWORD", "pass");
    define("DB_DATABASE", "my_data");
    ?>
    the relevent part of whiteboard.class.php
    Code:
    // load configuration file
    require_once('config.php');
    // load error handling file
    require_once('error_handler.php');
    // class handles server side whiteboard support functionality
    class Whiteboard
    {
      // database handler
      private $mMysqli;
      // define the number of maximum records in the table
      private $mMaxLoad = 5000;
      
      /* constructor opens database connection */
      function __construct() 
      {   
        $this->mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);          
      }
      
      /* destructor, closes database connection */  
      function __destruct() 
      {
        $this->mMysqli->close();
      }
      
      /*
        The checkLoad method clears the whiteboard table if
        it contains more than a specified number of records
      */
      public function checkLoad()
      {
        // build the SQL query to get the number of lines
        $check_load = 'SELECT SUM(length) total_length FROM whiteboard';
        // execute the SQL query
        $result = $this->mMysqli->query($check_load);
        $row = $result->fetch_array(MYSQLI_ASSOC);

  8. #8
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you don't have mysqli? http://uk3.php.net/mysqli


  9. #9
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have mysqli, it was installed with itools. I'm not sure it's configured correctly though.
    Attached Images Attached Images

  10. #10
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would recommend peeraware's shared whiteboard if you run your site on windows. Whiteboard, chat support and document sharing in a shared workspace.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •