PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello Everyone. I really try to figure things out before asking. Please HELP I'm into this 2 days now.
I've abbreviated the entire code to what must be relevant replicating the exact error from the full program.
Here it is with the issue commented on line #24
Notice that the error message says it found the error on line 43 of a file named "debug.php" -- is that the name of the file you are showing here? And how are you "reloading" the page, with the browser refresh button?
califdon, sorry-
Yes the file above is debug.php that i'm showing.
This is the mysql_error message You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE type='flyin' GROUP BY EXTRACT(YEAR FROM dues_paid)' at line 3
Which puts it, in my experience, at FROM $MemberDbTableName the same variable php say's is undefined.
Using the html Submit button line 57
OK, I think I now see what you're doing. The first time you load the page, you get no error, right? Your form is blank, then when the user fills in the form and submits, its action= is blank, so it calls the same script again, and this time you get the error. Is that what happens? I think what is going on is that since you are using include_once, the second time the script is executed in the same user session, it doesn't include the file again, and it's in that file that you declare the variable. The database connection remains valid during the session, but not variables, whose scope is the script they are declared in. You should not be declaring your table name variable in the include file. Do that in the main script. Try that, I think it will clear up the problem.
You are SOOOOOOO! right
Just for a test I added $MemberDbTableName = 'members_beta'; after include_once 'Connect_Db.php';
and it's working.
My reason for $MemberDbTableName declared in Connect_Db.php is the php code runs for many websites and I only need to change Connect_Db.php when I have a new client.
Again Thanks califdon.
To wrap this up with a work-around that works for me I'm just sending $MemberDbTableName along with the success to renderform().
2 code changes later function renderform($notice, $MemberDbTableName) renderform('success', $MemberDbTableName);
cloudbase wrote:My reason for $MemberDbTableName declared in Connect_Db.php is the php code runs for many websites and I only need to change Connect_Db.php when I have a new client.
You couid have another php file that contains nothing but the one line assigning the value to the variable, then include (not include_once) that file in your script. Or another way would be to just read the content of a text file containing just the name of the table. Your script could then have a line like this: