Firefox PHP

MySQL error

Posted by Steel Rat 
MySQL error
February 23, 2006 10:59PM
Ok, I'm doing a bit of hacking and running into a wall that doesn't make any sense.

Essentially I've added a text field to the phorum_groups table. The field name is desc (for description).

I had no trouble adding the Description textarea to the Edit A Group form using the proper class. And I can retrieve the description from the field and have it display in the textarea when going into edit mode. The problem is when updating the group when I have the desc field in the SQL update statement.

In the mysql.php file, phorum_db_save_group function, I added one field to the update. So the update line looks like this:

$sql="update {$PHORUM['groups_table']} set name='{$group['name']}', open={$group['open']}, desc='{$group['desc']}' where group_id={$group['group_id']}";

The part I added is:

, desc='{$group['desc']}'

Which is identical in syntax to the name set.

I always get an unspecified syntax error from the SQL execution. I've gone over it and over it, and can't figure out why. The syntax is correct. The only thing I can think of is that Phorum is somehow not liking a new field being added, but isn't telling me why. I have confirmed via debug statements that the $group["desc"] element is getting the data from the form post, and that the SQL statement is also getting the proper data.

For the table field, I've used the text, mediumtext, and longtext data types, but all of them react the same way.

Any ideas?

Steel Rat
[infinite-realities.com]
Re: MySQL error
February 24, 2006 02:27AM
please post the full error-message you got


Thomas Seifert
Re: MySQL error
February 24, 2006 01:16PM
Here is the MySQL error (hehe, wish you guys had BBCode activated):

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 'desc='Red Dwarf Game 1' where group_id=3' at line 1

And here is the actual SQL query as reported with a debug statement:

update phorum_groups set name='Red Dwarf: Smeg Off!', open=0, desc='Red Dwarf Game 1' where group_id=3

Steel Rat
[infinite-realities.com]
Re: MySQL error
February 24, 2006 01:24PM
desc is a reserved word in mysql
-> [dev.mysql.com]


Thomas Seifert
Re: MySQL error
February 24, 2006 01:32PM
Wow, really? I've used it numerous times before. At least I thought I had. Come to think of it I might have used things like short_desc or long_desc.

Thanks for that, though, I'll see if that works.

Steel Rat
[infinite-realities.com]
Re: MySQL error
February 24, 2006 01:48PM
Man I feel silly. desc is used by the Order By clause...

Steel Rat
[infinite-realities.com]
Re: MySQL error
February 24, 2006 01:55PM
That fixed it Thomas. Thanks! :)

Steel Rat
[infinite-realities.com]
Re: MySQL error
March 01, 2006 04:06PM
MySQL 4.1 and up got strict on reserved words. You can still use it, but you have to surround it with back tics `desc`

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Sorry, only registered users may post in this forum.

Click here to login