Variable isn't recognized(or brain freeze)

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Wally
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Jun 15, 2008 4:51 pm

Variable isn't recognized(or brain freeze)

Post by Wally » Sat Nov 03, 2012 3:53 pm

I'm JUST starting with on-rev scripting so I'm guessing the answer to my question is something very simple and basic.

I'm using 2 irev files with a form on each to go to a 3rd page which will display(hopefully) a large table with data from a mySQL database table.

The 1st form produces say "Team Stats"(user selected of 2 options) in $_GET["whichtypestats"] and the 2nd form produces say "b_fall_division_players"(user selected of 6 options) in $_GET["division"] I can "print" both variables on the 3rd page. The b_fall_division_players is the name of a table in my on-Rev database.

This is part of the URL on the 3rd page:
whichtypestats=team+stats&division=b_fall_division_players<p&submit=Get+The+Stats

The 3rd page uses an include file which has 6 if-then statements that try to create an SQL statement which will pick the appropriate table(b_fall_division_players")

One of the 6(the user can choose from 6 options) statements looks like this:
if $_GET["division"] = "b_fall_division_players" then
put "SELECT * FROM b_fall_division_players;" into tsql
end if

The statement doesn't execute and I get: revdberr,Query was empty

If I comment out like the below, the Query is successful and the data is put into a table on the 3rd page:
--if $_GET["division"] = "b_fall_division_players" then
put "SELECT * FROM b_fall_division_players;" into tsql
--end if

I posted this question on the on-Rev forum but that forum seems to be abandoned by livecode developers.

This has to be something simple?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Variable isn't recognized(or brain freeze)

Post by sturgis » Sat Nov 03, 2012 4:08 pm

If you're looking for "b-fall_division_players" but the url string is "b_fall_division_players<p" Since it would fail every time, nothing is placed into tSql so the query is empty. If you comment out the if/else, tsql is no longer empty and has a valid select statement so it works fine.
whichtypestats=team+stats&division=b_fall_division_players<p&submit=Get+The+Stats
At least this is my best guess without seeing more code.

Wally
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Jun 15, 2008 4:51 pm

Re: Variable isn't recognized(or brain freeze)

Post by Wally » Sat Nov 03, 2012 7:12 pm

Thanks, I didn't notice the <p in the url string - the brain freeze I predicted in the post title.

I've tracked down where the <p is coming from. I'll explain to possibly help others.

The 1st page is what produces the $_GET["division"] = b_fall_division_players. The url string of the 2nd page has division=b_fall_division_players , no <p.

In order to pass $_GET["division"] to the 3rd page I HAD on the 2nd page:
<input name="division" type="hidden" value=<?rev put $_GET["division"] ?>

I replaced it with :<input name="division" type="hidden" value='<?rev put $_GET["division"] ?>'
(Notice the ' character that was added to the above line)

After this, the <p doesn't appear in the url string of the 3rd page and the Query now produces the appropriate data depending on which division the user input.

Thank You for pointing me in the right direction!!

Post Reply