Karma System: Database Error

Started by Tristan Perry, October 08, 2004, 01:21:50 PM

Previous topic - Next topic

Tristan Perry

Hello,
I have been hacking away at the Karma system, I'm adding an extra field to the log_karma table which stores what topic the karma was given in. I am then using this to display the following log file:
http://tauonline.org/karmalog.php

This is working great, if Karma is changed through a topic, although if Karma is changed via PM, the following error message is shown:

QuoteDatabase Error
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
File: /home/tauonli/public_html/forums/Sources/Karma.php
Line: 97

I assumed this was the variable '$topic' was blank and so I added the following piece of code to the Karma.php file:

if($topic == '') $topic == blank;

Now, I get the same database error, and the following PHP error at the top of my PM page (If I attempt to modify Karma):

QuoteNotice: Use of undefined constant blank - assumed 'blank' in X on line 93

What I have at the moment (Which is triggering these errors) is:

// Put it in the log.
if($topic == '') $topic == blank;
db_query("
INSERT INTO {$db_prefix}log_karma
(action, ID_TARGET, ID_EXECUTOR, logTime, topic)
VALUES ($dir, $_REQUEST[uid], $ID_MEMBER, " . time() . ','.$topic.')', __FILE__, __LINE__);


Line 93 is the line (if($topic == '') ..

Any help would be greatly apprecaited,
Tau Online

 

[Unknown]

Instead of blank, try:

if (empty($topic))
   $topic = 0;

-[Unknown]

Tristan Perry

Quote from: [Unknown] on October 08, 2004, 03:28:08 PM
Instead of blank, try:

if (empty($topic))
   $topic = 0;

-[Unknown]
Thanks, that worked great  :) You seem good at PHP, you should try making a message board system or something...or wait.  :D Anyway thanks a lot  :) Also does the function empty() check if the variable has been set, but has nothing it it?

Advertisement: