1
corne
My own module
  • 2005/1/12 15:21

  • corne

  • Just popping in

  • Posts: 24

  • Since: 2005/1/12


Hi,

I'm trying to make my own module, only I get an error when inserting something in the database..

I'm using the following code to add something to the database:

$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("cervex_config")."(location, value) VALUES('config', 1)";


This is the first module I'm creating, I know I do something wrong, but I don't know how I must do it..

Anyone who sees what goes wrong??

(sorry for my English)

Greets Corne

edit:
Is there a tutorial or something for working with a database from XOOPS modules? Or does someone have an simple example?

2
ejuden01
Re: My own module
  • 2005/1/12 15:47

  • ejuden01

  • Not too shy to talk

  • Posts: 121

  • Since: 2004/4/5 1


When I do mine, I use sprintf:
$sql sprintf("INSERT INTO %s VALUES (%s, %u)"$xoopsDB->prefix("cervex_config"), 'config'1);
$xoopsDB->query($sql);

3
ackbarr
Re: My own module

as a matter of protection, XOOPS blocks any INSERT, UPDATE, or DELETE queries if the page was accessed via a GET request.
Only pages accessed via a POST request (a form submission) can modify the database.

4
phillipd
Re: My own module
  • 2005/1/13 21:26

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Is there a way to avoid this security issue, in a secure manner, of not allowing a insert,update,delete from a GET? I need to possibly do a insert when a user hits a page depending on if something exists in the DB. How would I do this?

Thanks

Doug P

5
ejuden01
Re: My own module
  • 2005/1/13 21:29

  • ejuden01

  • Not too shy to talk

  • Posts: 121

  • Since: 2004/4/5 1


Instead of calling $xoopsDB->query(), call $xoopsDB->queryF()

6
phillipd
Re: My own module
  • 2005/1/13 21:39

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


That works great, thanks!

Doug P

Login

Who's Online

90 user(s) are online (56 user(s) are browsing Support Forums)


Members: 0


Guests: 90


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits