1
WEREM
Cant query the MySQL database, HELP!
  • 2005/3/12 21:46

  • WEREM

  • Just popping in

  • Posts: 12

  • Since: 2005/3/12


Hi, I'm trying to query a database from a module (developed by myself). But when I try to query the database, with an insert string, I have nothing at all. blank I dont know wats happens
please help, heres me code.

php
include("../../mainfile.php");

global 
$xoopsDB;
$xoopsDB =& Database::getInstance();

$sql "INSERT INTO xoops_mi_modulo VALUES (0,'pablo', '0015634','12')";

$xoopsDB->query($sql);

if (!
$xoopsDB->query($sql) )
{
echo( 
$xoopsDB->error." : ".$xoopsDB->errno );




echo 
"respuesta=";
echo 
XOOPS_ROOT_PATH;
echo 
"&";
?>

It's suposed to insert a record in the table, but nothing is happens, the table is not touched.
The database is accese properly for XOOPS, all goes smoothly but this script.
I turn the PHP debug mode in preferences and this is what I get.
Quote:

Notice [PHP]: Undefined property: error in file
C:\www\webroot\modules\mimodulo\update_score.php line 13


What I' doing grong?

2
jdseymour
Re: Cant query the MySQL database, HELP!

For one why the double PHP tag at the beginning of your code?

Also the extra white space at the top of your code is that in the actual file, or does < ?php start at line 1?

3
dasdan
Re: Cant query the MySQL database, HELP!
  • 2005/3/13 10:39

  • dasdan

  • Just popping in

  • Posts: 29

  • Since: 2005/1/22


Quote:
I turn the PHP debug mode in preferences


why don't you switch on the SQL Debug mode instead of php debug?

does your insert query work when you execute him ie from your PHPmyadmin cp?

and you should use () after the xoopsDB-methods
$xoopsDB->error(), $xoopsDB->errno(),

$result $xoopsDB->query($sql);
   if (!
$result){
    
$error = array('msg' => $xoopsDB->error(), 'data' => $sql'errno' => $xoopsDB->errno());
        return 
$error;
    }else{
    return 
$result;
}


https://xoops.org/misc/api/kernel/database/XoopsMySQLDatabase.html#sec-methods

Hope this helps

4
Dave_L
Re: Cant query the MySQL database, HELP!
  • 2005/3/13 10:54

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


In addition to what the others have said, the XOOPS database class has a security feature that allows only SELECT queries when the request method is GET. Other queries, such as INSERT, are only allowed when the request method is POST, as it would be when processing a form request.

You can override that behavior by using queryF instead of query, but that should only be done in rare cases.

5
WEREM
Re: Cant query the MySQL database, HELP!
  • 2005/3/14 15:41

  • WEREM

  • Just popping in

  • Posts: 12

  • Since: 2005/3/12


Hey that's helps a lot, you're the best guys!!!!

6
WEREM
Re: Cant query the MySQL database, HELP!
  • 2005/3/14 19:55

  • WEREM

  • Just popping in

  • Posts: 12

  • Since: 2005/3/12


If I post this URL "http://mysite.com/modules/mimodule/test.php?var1=test&var2=test2&var3=test3&". I mean I do a POST instead a GET (I'm working in flash). Anyway is the same thins that submit an HTML form with 3 text field. How doi I get the data (text fields values) in xoops?

Thanx in advance.

7
Dave_L
Re: Cant query the MySQL database, HELP!
  • 2005/3/14 20:00

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Use $_GET['var1'] for a URL parameter. Use $_POST['var1'] for a field within a form whose request method is POST.

Login

Who's Online

447 user(s) are online (321 user(s) are browsing Support Forums)


Members: 0


Guests: 447


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