1
sinus
what do i need to INSERT into database?
  • 2005/7/19 11:11

  • sinus

  • Just popping in

  • Posts: 27

  • Since: 2005/6/11


hello,

i have been trying to figure out why INSERT statements using the XOOPS DB API wont work... SELECT statements work with no problem...

im thinking that i need valid credentials before i can write something in the database... maybe you could give me some info about it???

thanks.
any reply would help.

2
Dave_L
Re: what do i need to INSERT into database?
  • 2005/7/19 11:53

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


The method query() only accepts SELECT queries unless the request method is "post", as it normally is for form submittals.

This is a security feature.

You can use method queryF() in place of query() to do non-SELECT queries from a "get" request, but that should only be done if it's not practical to use a form. If you do this, it's especially important that you do your own security checks, such as sanitizing user input.

3
sinus
Re: what do i need to INSERT into database?
  • 2005/7/20 1:45

  • sinus

  • Just popping in

  • Posts: 27

  • Since: 2005/6/11


ah nice. thanks. i will test it later today.

so,
$xoopsDB->query("INSERT INTO table ... VALUES (".$_POST['username'].", ".$_POST['address'].")");

will work assuming that the $_POST vars are "clean"?

thanks for the info though. very useful for me.
PS: it was not documented in the FAQ...

Login

Who's Online

457 user(s) are online (378 user(s) are browsing Support Forums)


Members: 0


Guests: 457


more...

Donat-O-Meter

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

Latest GitHub Commits