11
Dave_L
Re: XOOPS/SQL Question
  • 2004/7/22 19:06

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I don't know what $eh is. If it's not defined as an object, I would expect to see the "Call to a member function on a non-object" error.

The backquotes (``) around the table name are unnecessary here, but don't hurt anything. They're only needed if the table name contains spaces or possibly other special characters.

For SELECT, either query() or queryF() should work. queryF() is only needed if you're doing a non-SELECT query and the request method is not POST. query() is the preferred one to use.

Are you sure you're not leaving out the table name prefix, as skalpa mentioned?

Could you post a larger chunk of your code (not too large)? Maybe something else is wrong, and causing the query to fail.

12
Casey
Re: XOOPS/SQL Question
  • 2004/7/22 20:28

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Sure, I can post as much code as you want. I intend to distribute this module free/open source when its done. At the moment I'm just trying to get something that works before I polish it. Its intended to allow admins to manage a guest list for an event (with RSVPs and such). At the moment inserting into the database with either my old method (above) or the given method (also above) both work with the offending lines commented out.
The table name is xoops_caseyguestlist
xoops_ will later be changed to be the prefix as in the documentation.

Here's the relevant function for (eventually) outputting a table of guests.

function OutputGuestList()
{
    print(
" n");
    print(
"n");
    
$result $xoopsDB -> query("SELECT * FROM xoops_caseyguestlist LIMIT 0,30");
    while (
$row $xoopsDB->fetchArray($result)) 
    {
        print 
"ID:".$row{'id'}." Name:".$row{'name'}." ".$row{'zip'}."
"
;
    }

    print(
"
Name:Street1:Street2City:State:ZipEdit:Delete
n"
);
}


If there is any other code that might be relevant let me know and I'll put it up here.

Edit: Up until a couple days ago I used C++/perl so its entirely possible I pulled off some little PHP no-no that I haven't realized.

13
Mithrandir
Re: XOOPS/SQL Question

you are in a function scope, hence globally available variables are not available there.

You will need to add a
global $xoopsDB;

before you use it.

14
Dave_L
Re: XOOPS/SQL Question
  • 2004/7/22 20:50

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Array elements are accessed using [], not {}. (Unlike Perl, associative arrays in PHP are accessed the same way as indexed arrays.)

print "ID:".$row{'id'}." Name:".$row{'name'}." ".$row{'zip'}."
"
;


should be

print "ID:".$row['id']." Name:".$row['name']." ".$row['zip']."
"
;


Actually, I would write it (for improved readability) as

print "ID:{$row['id']} Name: {$row['name']} {$row['zip']}n";

15
Casey
Re: XOOPS/SQL Question
  • 2004/7/23 19:46

  • Casey

  • Just popping in

  • Posts: 14

  • Since: 2004/7/18


Ahh! Thanks everyone for your help. I knew something odd must be happening when nothing I was trying was working. I'll have to remember that for next time :).

-- Casey

Login

Who's Online

559 user(s) are online (139 user(s) are browsing Support Forums)


Members: 0


Guests: 559


more...

Donat-O-Meter

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

Latest GitHub Commits