php ~ array modification

IamMrRayIamMrRay Otis, MA
edited April 2007 in Internet & Media
I have a nearly complete e-commerce site that I am working on, except I ran into a little road block currently. I have a weak point when it comes to arrays.

What I am trying to do is take any combination of values from a form on a previous page and then take those values out of the array and then concatenate them into a query string.

So far I have the implode working.

But beyond that, I am not sure if it is just making extra work.

I was thinking that perhaps I could check the string for certain values and then just based on those being present, make the query based on what was detected. I think if I actually do it like this it will isolate user input from the query, and make a more secure form.

What do you think?

And would it really be necessary to still implode the array if I used the second idea?

Comments

  • IamMrRayIamMrRay Otis, MA
    edited April 2007
    wait i just got an idea based on the second thing I wrote:

    what if I just set up a bunch of conditionals like this:
    $arraything = stripslashes(trim($_GET));
    <?php
    if($arraything == "what we want"){
    $this_certain_section_of_query = "thing_searched_in_query =\'blah\'";
    }
    $query = "select * from blahblah where blahblahblah ='blahblahblahblah' and $this_certain_section_of_query";
  • a2jfreaka2jfreak Houston, TX Member
    edited April 2007
    Maybe giving an actual example would help. Also, enclose all your code inside [ php ] [ /php ] tags, but make sure you take out the spaces between the [ and ] brackets.
  • IamMrRayIamMrRay Otis, MA
    edited April 2007
    sry for the delay in my response. I ended up just doing a work around based on idea number 2 that I had. (and in the future I will remember to enclose them in the BB tags sry its been a while :P)
Sign In or Register to comment.