Confused about default values when using WHERE statement.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If no checkboxes are selected, then $condition_found shouldn't be true. Set it's initial value to false and that should be fixed.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
WLW
Forum Commoner
Posts: 41
Joined: Sat Aug 07, 2004 3:00 pm

Post by WLW »

Yup, setting that to "false" fixed the issue.

Regarding the SQL not being picked up, do you think this Dreamweaver-generated code has anything to do with it?

Code: Select all

$category1_rs_members = "%";
if (isset($_GET['category1'])) {
  $category1_rs_members = (get_magic_quotes_gpc()) ? $_GET['category1'] : addslashes($_GET['category1']);
}
There is a list of these that appear near the top of the code on my page. There is one for each variable used on the form EXCEPT the variables that we are adding. What do you think??
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

What do you mean by SQL not being picked up?

That code you showed does this:

Code: Select all

- Initializes $category1_rs_members to a value = "%",
- If there is a GET variable called "category1":
   - if get_magic_quotes_gpc() returns true, $category1_rs_members get's the value of the GET variable
    - otherwise $category1_rs_members gets the value of addslashes(the GET variable)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
WLW
Forum Commoner
Posts: 41
Joined: Sat Aug 07, 2004 3:00 pm

Post by WLW »

Does that mean then that I need to add similar phrases for the 6 new items we are working with?

Regarding the SQL problem... Ignor that. I fixed it. The new chunk of PHP code was in the wrong place on the page.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I wouldn't think so - that line really only escapes escape characters if it needs to. The escape characters we're putting in the variables we make won't be an issue.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
WLW
Forum Commoner
Posts: 41
Joined: Sat Aug 07, 2004 3:00 pm

Post by WLW »

Thank you very much pickle and feyd!! All is working as expected now. Let me know if you'd like to see the sample. :D
Post Reply