Jump to content

shared whiteboard problem


matthewst

Recommended Posts

ok, I did everything in the tutorial at http://cristian.nexcess.net/ajax/whiteboard/ I can draw in the box but it doesn't "share" with other users and I get this monster error

 

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

  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

        displayUpdates();  
      }
      catch(e)
      {

 

lines 33-36 of whiteboard.class.php

    $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);

 

any ideas?

Link to comment
Share on other sites

Changed 33 - 36(38) to this

$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).

 

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

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

<?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()); 
}

Link to comment
Share on other sites

I think it may be a database connection issue. 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

<?
$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

<?
// 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

// 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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.