1
Casey
XOOPS/SQL Question
  • 2004/7/21 21:00

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


$result = $xoopsDB -> query('SELECT * FROM `thetesttable` LIMIT 0, 30');

I want to select all data from (what i've named in this case thetesttable. The table exists and can be edited with PHP admin. I am able to add to it using:
$result = $xoopsDB -> query("INSERT INTO etc...")

Even when I attempt to select a single table, it fails. I've read the php and MySQL documentation and as far as I can figure out, this has something to do with the way XOOPS accesses the database?

For the moment I just want this:
$result = $xoopsDB -> query('SELECT * FROM `thetesttable`');
to work. If anyone could help me that would be great.

-- Casey

2
dheltzel
Re: XOOPS/SQL Question
  • 2004/7/21 21:50

  • dheltzel

  • Not too shy to talk

  • Posts: 164

  • Since: 2003/1/8 1


Quote:

Casey wrote:
$result = $xoopsDB -> query('SELECT * FROM `thetesttable` LIMIT 0, 30');

-- Casey


Try queryF instead, like this:

$result = $xoopsDB -> queryF('SELECT * FROM `thetesttable` LIMIT 0, 30');

Dennis

3
Casey
Re: XOOPS/SQL Question
  • 2004/7/22 0:32

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Fatal errorCall to a member function on a non-object in /var/www/localhost/htdocs/modules/caseyguestlist/index.php on line 85


That's the error I get returned, where line 85 is:
$result $xoopsDB -> queryF('SELECT * FROM `thetesttable` LIMIT 0, 30');


If I comment that line out everything (except what deals with $result) works.

-- Casey

4
skalpa
Re: XOOPS/SQL Question
  • 2004/7/22 7:39

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Quote:
$result = $xoopsDB -> query('SELECT * FROM `thetesttable` LIMIT 0, 30');


$result $xoopsDB->query('SELECT * FROM ' $xoopsDB->prefix('thetesttable'), 300);


The db class is defined in /class/database/mysqldatabase.php, check it out, the source file is documented / commented

skalpa.>

5
Casey
Re: XOOPS/SQL Question
  • 2004/7/22 12:00

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Ok, its nice to know where the db class documentation is. That said, I've looked through it and what you're suggesting looks right to me, however, I'm still getting the same error.

This leaves me in the position that I can add records to the database using:
$result $xoopsDB -> query("INSERT INTO `xoops_caseyguestlist` (name, street1, street2, city, state, zip) VALUES ('$name', '$street1', '$street2', '$city', '$state', '$zip')");

but can't get them out with any of the suggested code.

6
ChadK
Re: XOOPS/SQL Question
  • 2004/7/22 13:42

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Not sure why you're trying to return a result but use this:
Quote:
$sql = "INSERT INTO `xoops_caseyguestlist` (name, street1, street2, city, state, zip) VALUES '$name', '$street1', '$street2', '$city', '$state', '$zip')";
$xoopsDB->queryF($sql) or $eh->show("0013");

7
dheltzel
Re: XOOPS/SQL Question
  • 2004/7/22 15:17

  • dheltzel

  • Not too shy to talk

  • Posts: 164

  • Since: 2003/1/8 1


Try this:

$result = $xoopsDB -> queryF("SELECT * FROM thetesttable LIMIT 0, 30");

I don't think it likes quotes arounf the tablename, and I usually use " instead of ', but I'm not sure that matters.

Dennis

8
Casey
Re: XOOPS/SQL Question
  • 2004/7/22 16:27

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Chad: That part works fine. I'm using result there just to make sure the operation was successful. Your method uses $eh. Is that error handler? That sounds more convenient. Presumably 0013 returns the MySQL error?

I'll have to try it without the quotes tonight and see how that works out.

9
ChadK
Re: XOOPS/SQL Question
  • 2004/7/22 17:18

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


yes yes and yes. :) Try it, you'll like it.

10
Casey
Re: XOOPS/SQL Question
  • 2004/7/22 18:24

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Fatal error: Call to a member function on a non-object in /var/www/localhost/htdocs/modules/caseyguestlist/index.php on line 85

Same thing.

Is there some difference with me using XOOPS 2.0.7 between what y'all are saying and what I should be doing? I have read tons of PHP documentation for the past couple days and it seems that the stuff I've been doing should work - as well as y'alls suggestions, and yet nothing is working out.

Login

Who's Online

252 user(s) are online (176 user(s) are browsing Support Forums)


Members: 0


Guests: 252


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