Php function isnt working!
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Php function isnt working!

Hybrid View

  1. #1
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053

    Php function isnt working!

    Well it kind of does..


    $NewTicketType = $_POST['NEW_FK_TICKET_TYPE_ID'];
    $NewTicketSubType = $_POST['NEW_FK_TICKET_SUB_TYPE_ID'];
    $NewTicketID = LookUpIdById($NewTicketType,$NewTicketSubType);

    echo $NewTicketID;

    Now if I do that it doesnt work but if I put in
    $NewTicketID = LookUpIdById(1,1); it does work...

    I have already verified that $NewTicketType and NewTicketSubType are equal to 1 by echoing them too... Thoughts?
    Last edited by oofki; February 7th, 2008 at 03:56 PM.

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    Quote Originally Posted by oofki
    Thoughts?
    Check if $NewTicketType and $NewTicketSubType actually get assigned what you've POST'ed.

    Edit: oeps.. You've already checked that
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053
    Yeah its really frustrating im not sure if there is a way to force a variable to be an integer because maybe it is seeing it a string and wont work?

  4. #4
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Quote Originally Posted by oofki
    Yeah its really frustrating im not sure if there is a way to force a variable to be an integer because maybe it is seeing it a string and wont work?

    Does your function rely on them being integers? If so, you could use is_int (in an if statement) to verify that you have an integer and if you don't, you could use int to cast it to an integer... I forget what php considers values to be from a post.

    Example int usage:

    $x = "1";
    $y = (int)$x;

    is_int($x) is False
    is_int($y) is True
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  5. #5
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    What does that function look like (just the basics)?

    You could also force the conversion to integer with $integer = intval($somestring);
    Last edited by SirDice; February 7th, 2008 at 04:34 PM.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  6. #6
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053
    Well the function looks like:

    function LookUpIdById($parent_id,$child_id)
    {
    $where = "where PARENT_ID=$parent_id and CHILD_ID=$child_id ";
    return($this->LookUpOneColumn("ID",$where));
    }

    It works fine if i put in the numbers but not the variables like I said I will try that int function :-)

  7. #7
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    $where = "where PARENT_ID=$parent_id and CHILD_ID=$child_id ";
    Because of this it shouldn't really matter if $parent_id is a string or an integer as it all gets converted to strings anyway..

    Weird.. Try echo'ing the values inside the function.. See if that's different..
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  8. #8
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053
    i tried intval() and it still doesnt work!!!

  9. #9
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053
    Okay I figured it out. Basically the subtype that I had was already the ID that would be produced by that function and I did not need to even run it :-)

    Thanks for the thoughts SirDice and HtRegz :-D

  10. #10
    Senior Member
    Join Date
    Dec 2003
    Location
    LA, CA
    Posts
    292
    Just wanna add: NEVER TRUST YOUR USER

    http://www.php.net/addslashes

    http://www.php.net/strip_tags
    A mind full of questions has no room for answers

Similar Threads

  1. Developing a Port Scanner in Python
    By HTRegz in forum The Security Tutorials Forum
    Replies: 12
    Last Post: January 28th, 2006, 08:02 PM
  2. Ajax/Sajax/AjaxMonkey - the buzzwords of the web.
    By embro1001 in forum Other Tutorials Forum
    Replies: 0
    Last Post: July 16th, 2005, 06:25 PM
  3. Apache, PHP, MySQL with basic security settings.
    By nightcat in forum The Security Tutorials Forum
    Replies: 9
    Last Post: May 28th, 2005, 03:47 AM
  4. php mail function prob
    By journy101 in forum Newbie Security Questions
    Replies: 1
    Last Post: May 1st, 2003, 07:16 AM
  5. JavaScript - Three Chapters
    By jethro in forum Other Tutorials Forum
    Replies: 5
    Last Post: November 3rd, 2002, 03:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •