Quote from: fruitwerks at Dec 07, 2007, 01:14 PM
OK I have read this whole thread and I tried the example posted by awardle. I got past the unclosed comment error no prob. Do the tables always have to be manually created, or is there a way to check for and create new tables? I have some big plans for this but I need to see it working before I can start thinking
Anything that you can do in PHP you can do in these functions, and you can also make use of the MODx API as long as you start your function with global $modx;
I understand you can use PHP and the API - that is a given. I have little experience with MySQL, so we can say this is my first project I will be getting my hands dirty in with it.
For what I am wanting to do, I will need the ability to add fields from time to time. Once I get a feel for this I will be adding an image or two, dropdown selectors, ability to bind entries to form ’trees’. As usual when I start something new I miss something simple...
Using the example by awardle, I created the table with phpmyadmin. I was then able to submit the form, but I don’t think it stuck in the db. I’m convinced I made the table wrong. I didn’t see anything about how to make the initial table or what values the fields they need.
Do you mean Awardle’s Venues Snippet? If it works for Awardle, I assume that it would work for you, too (although I haven’t really reviewed it). If you post your code and table info we can take a look at it and see what might be the problem.
Try echoing $sql (and commenting out the rest of the script) to see what your query looks like. It appears that $result is not a valid reference, which probably means that your query is not being properly created. You can use the MODx dbAPI for a lot of what’s in Awardle’s snippet, btw, which might make it a little bit simpler to modify for your needs.
Er, no that won’t work. What I meant was to echo (or return) the value of $sql from the show venues snippet. So it’d be something like this:
<?php
$dbase = $modx->dbConfig['dbase'];
$table_prefix = $modx->dbConfig['table_prefix'];
$usernameid = $modx->getLoginUserID();
$sql = "SELECT *,modx_rsvp_venues.id as venue_id FROM $dbase.".$table_prefix."rsvp_venues,".$table_prefix."rsvp_events WHERE modx_rsvp_events.member_id = '" .$usernameid ."' AND modx_rsvp_venues.member_id = '" .$usernameid ."' ORDER BY venue_order ASC";
return $sql;
?>
That way you can see what’s causing the error.
Hmm well one thing I did think of last night is that my table prefix is fw_ for this site. The records are finding their way into the DB, but I don’t fully understand the query and I am fairly sure that is where all the troubles are.