Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Insert not putting category in?

Quote Reply
Insert not putting category in?
Can anyone see the problem here? I don't get any SQL error, and it adds EVERYTHING *except* the "Category". If I print out $Category before the 'insert', it shows the corect value. It just doesn't want to insert it into the database :(

my $result = $DB->table('News_Articles')->insert( { Title => $Title, Short => $Short_Article, Date => $Date, Category => $Category, Image => $Image, TimeStmp => $TimeStmp, Full => $Full_Article } ) || &error("SQL Error: $GT::SQL::error");

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Insert not putting category in? In reply to
Are you sure your error routine is catching things? Try replacing it with just 'or die "Error: $GT::SQL::error";

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Insert not putting category in? In reply to
Tried that already. I know that it *should* catch SQL errors, cos it is catching 'Duplicate Entry for Date', and other stuff while I was developing it. I even tried editing the INSERT stuff so that it had a bad field name (Catgory, i,.e missing the 'e') .. and that didn't give any errors. Could it be mod_perl caching the old version of the script again? Maybe try giving mod_perl a reboot?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Insert not putting category in? In reply to
Hi,

It's not wise to develop under mod_perl, only run the final code under mod_perl. If you make any changes to any included library files (i.e. anything that is 'use' or 'require'), it will not get reloaded unless you restart mod_perl.

Try turning on debug, and seeing the SQL query that is being sent.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Insert not putting category in? In reply to
Actually, looking at it further, I don't think mod_perl is enabled on my linkssql.net site...

I double checked that the script is taking new changes ok by adding a 'duplicate check' bit of code (reports an error if a similar entry exists in the database). Could it be anything to do with the code above the statement? BTW, I've edited it a bit more now, so its in a couple of statements, instead of one long one;

Code:
# ok, if we have got this far, lets assume its ok to add the article...
use GT::Date;
GT::Date::date_set_format($Date_Format);
my $Date = GT::Date::date_get();
my $TimeStmp = GT::Date::timelocal();
my $Article_Table = $DB->table('News_Articles') || &error("SQL Error: $GT::SQL::error");
my $result = $Article_Table->insert( { Title => $Title, Short => $Short_Article, Date => $Date, Category => $Category, Image => $Image, TimeStmp => $TimeStmp, Full => $Full_Article } ) || &error("SQL Error: $GT::SQL::error");
if (!$result) { &error("SQL Error: $GT::SQL::error"); }

This is doing my head in! And there I was thinking the rewrite of my Ace_News plugin was going to be easy! That will serve me right for being too confident...lol

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Alex] Insert not putting category in? In reply to
BTW, I turned debug onto 2, and it didn't print any messages out. I don't think it is a case of the MySQL actually failing, cos the entry is put into the table; it just misses the 'Category' value. FWIW, this is the setup of my database table;

Title varchar(40)
Short varchar(50)
Full text
TimeStmp int(11) PRI 0
Index
Date text
Category text
Image text YES

I tried setting the 'Category' field to VARCHAR(255) too, and that didn't work either :/

Thanks for your suggestions so far :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Insert not putting category in? In reply to
Hmm, don't think you want this:

my $TimeStmp = GT::Date::timelocal();

Not sure about category, but errors should go to your error log (can view it through the control panel or in domain.com/logs/error_log).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Insert not putting category in? In reply to
What would you suggest for a unique Time Stamp? I tried using TimeStmp => \"NOW()", but for some reason that just put '2003' in in Unsure

>>>Not sure about category, but errors should go to your error log (can view it through the control panel or in domain.com/logs/error_log). <<<

I don't have the error_log option in my admin panel.. I see it for all the domains, excep LinksSQL.net :(

In SSH I see;

[linkssql@east logs]$ pwd
/home/linkssql/linkssql.net/logs
[linkssql@east logs]$ ls
2003-09-access_log.gz linkssql.net.access_log.14557.tmp stats/ stats-2003-09/
2003-09-error_log.gz linkssql.net.error_log.14557.tmp stats-2003-08/
[linkssql@east logs]$

I'm assuming there should be an error_log and access_log file there, which is why its not showing up in the admin panel? :/

Cheers

linkssql.net Email - Stats -

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Insert not putting category in? In reply to
Fixed it. Had to do a re-sync on the table Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!