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
https://forums.phpfreaks.com/topic/64709-shared-whiteboard-problem/
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()); 
}

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.