Results 1 to 3 of 3

Thread: lil problem here guys, is data type conversion the answer??

  1. #1
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default lil problem here guys, is data type conversion the answer??

    k to me this sounds a bit wierd based on the fact that on declaration of variables you dont set data types

    i.e int $varname, you just go ahead and whatever you want in var name without setting a type in php. but i've been having this lil problem.

    PHP Code:
    $socialsecurity 123456789;
    $date date('y');
    $manid $socialsecurity $date 
    manid should be equal to 123456789 + the year wich is 05 making it 12345678905 now when i pass that value for manid into my object constructor { yes, i'm using object orientation in php} and assign it to the id for the person object the value is a completely different thing it becomes 21226.... [ cant remember the exact value ] but i really don't understand the problem.

    i tried making the id being the socialsecurity alone i.e [123456789] and it was passproperly and assigned properly an in the object the value was the same, but when i concatanate it with the date i get that other number.

    so i was thinking is it a situation where i'm concatanating 2 different datatypes bing an int and a date , would i need to convert both to strings [ cuase i have no problem with storing it in the backend as a string aslong as the data is accurate.

    so if ne body know how to covert form date to string or better yet the contents of a variable to a string let me know please. if you havene suggestions toma problem i welcome it.
    Last edited by death_knight; Jan 20, 2005 at 09:39 AM. Reason: forgot a tag

  2. #2
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re: lil problem here guys, is data type conversion the answer??

    you are doing something wrong in the code. check the code again. The code above works, you are doing something wrong at some other point. check each point.

  3. #3
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default Re: lil problem here guys, is data type conversion the answer??

    I fixed it, all i did was change the data type for the field accepting the data in the mysql backend. i changed it from an int to a varchar. i think it was becuase i was concatanating a date with an integer and tryng to store it in one field.

Posting Permissions

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