Jump to content

Error: Object of class variant could not be converted to string


fred12ned

Recommended Posts

I get this error: Object of class variant could not be converted to string
and i don't know why
[code]<?php
class conn{
var $db;
function connect($dbname){
$this->db = new COM("ADODB.Connection");
$connstr = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=". realpath("./".$dbname.".accdb").";";
$this->db->open($connstr);
}
function getcolor($user){
$recordSet = $this->db->Execute("SELECT color FROM `User` WHERE Username='".$user."'");
$bob = $recordSet->Fields(0);
return $bob;
}
function checkusers(){
$result = $this->db->Execute("SELECT * FROM user");
while(!$result->EOF){
if(date('dHi')-$rs->Fields(2) > 5){
$this->db->Execute('DELETE FROM User WHERE User = "'.$rs->Fields(0).'"',$this->conn);
$this->db->Execute("INSERT INTO Chat (Username,Message) VALUES('Xbgh54tr','<b>".$rs->Fields(0)."</b> has left the chat')",$this->conn);
}
}
}
function getmsg($user){
$this->db->Execute("UPDATE `User` SET Tim = '".date('dHi')."' WHERE Username='".$user."'");
$result = $this->db->Execute("SELECT * FROM Chat");
$msg='';
while(!$result->EOF){
if ($result->Fields(0)!='Xbgh54tr')
$msg .= $row['user'].' - <font color="#'. $this->getcolor($result->Fields(0)) .'">'. $this->smilie($result->Fields(1)).'</font><br>';
else
$msg .= '<font color="#FFFF00">'.$result->Fields(1).'</font><br>';
}
$this->checkusers();
return $msg;
}
function sendmsg($user, $text){
$this->db->Execute("INSERT INTO chat VALUES('".$user."','".$text."')");
}
function smilie($text){
$rs = $this->db->Execute("SELECT Smilies FROM Smilies");
while(!$rs->EOF) {
$smilies[] = $rs->Fields(0);
$images[] = "<img src='smilies/" . $rs->Fields(1) . ".gif'>";
}
$text=str_replace($smilies, $images, $text);
return $text;
}
function newuser($user, $color){
$this->db->Execute("INSERT INTO Chat (Username, Message) VALUES('Xbgh54tr','<b>".$user."</b> has joined the chat')");
$date=date('dHi');
$this->db->Execute("INSERT INTO `User` (Username, Color, Tim) VALUES('".$user."','".$color."','".$date."')");
}
function changeuser($old, $new){
$this->db->Execute("UPDATE User SET user = '".$new."' WHERE user='".$old."'");
$this->db->Execute("INSERT INTO Chat VALUES('Xbgh54tr','<b>".$old."</b> has changed thier name to <b>".$new."</b>')");
}
}
?>[/code]
Link to comment
Share on other sites

[quote author=thorpe link=topic=123882.msg512689#msg512689 date=1169674078]
[code=php:0]if(date('dHi')-$rs->Fields(2) > 5){[/code]
[/quote]
$rs should be $result
All that does is finds out if the user has been inactive for 5 mins

I am using it like this
[code]<?php
require('access.php');
$con = new conn;
$con->connect('database');
$pop = $con->getmsg($_GET['user']);
echo $pop;
?>[/code]
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.