Originally posted by pete_bisby
Are you sure that the $VisitDate variable is being passed correctly, or is spelled correctly on the previous screen - PHP is case sensitive.
Yes.
Here's a quick rundown of what the script does (in order)...
- Extract data from a form
- Use that data to set variables, including $VisitType and $VisitDate
- Select appropriate DB based on $VisitType
- Update DB with data extracted from the form
- Display a confirmation message
In the confirmation message, I use both $VisitDate and $VisitType without any problems. However, I'll add in couple of printf statements to display the values being passed as $VisitDate and $VisitType at the time the database is supposedly selected.
Here is why I am confused...
If you look at the code above, the code that sets the DB is absolute (no variables involved). The only variable is in the if statement which controls which mysql_select_db is run. I put the echo statements in after each mysql_select_db call to make sure the code was running the correct branch of the if structure, which it is. So, because of the echo statements, I know that the code is following the correct branch of the if structure. The db names used in the mysql_select_db calls match the actual db names. I even commented out the if structure and tested each mysql_select_db call independantly - they work just fine. But as soon as I add back in the if, the switch never happens.