#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Denmark
    Posts
    82
    Rep Power
    15
    Hi

    The following code returns $colorDepth with the current colorDepth from javaScript - in my case it's 32.

    $colorDepth = "<SCRIPT LANGUAGE=JavaScript>document.write(window.screen.colorDepth)</script>"

    If I do a simple "echo $colorDepth;" it brings up "32".

    When I put the $colorDepth into this "code"

    $numberColors = pow(2,$colordepth);

    - it returns "1" but it should return "4294967296" - the number of colors on my computer.

    I guess PHP thinks that $colordepth is a textstring, and not a number - så how do I "convert" $colordepth into a "true" number.

    Thanks in advance
    Bee

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    Try to explicity cast the variable to a float like this:

    $colorDepth = "<SCRIPT LANGUAGE=JavaScript>document.write(window.screen.colorDepth)</script>"

    $colordepth = (float) $colordepth;

    $numberColors = pow(2,$colordepth);

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    Try..
    $colordepth = (int)$colordepth;
    to convert to an integer.

    Jus to see whether it is a string originally use..
    echo gettype($colordepth);

    Basil
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Denmark
    Posts
    82
    Rep Power
    15
    I'm having more trouble, but my new problem seems to answer my first question.

    when I first set $colorDepth it's a javascript function, and I quess that's why I can't use it directly in PHP.

    My new problem is, that I wan't to put my result into a MySQL DB, and when I do that the result in the database is:

    <SCRIPT LANGUAGE=JavaScript>document.write(window.screen.colorDepth)</script>

    - since this is what I actully defines $colorDepth to be.

    What confuses me is that when I "run" the page in the browser $colorDepth = 32 - but I guess that it's because the javascript is executed on the client, and when I try to put it into the database, the script is not being executed, since it's being executed on the server.

    Perhaps I have to summit my result through a form, before the values are accepted by PHP.

    Any/all suggestions are welcome

    /Bee

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    You can use javascript to write some hidden form fields.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <FORM>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    document.write("<INPUT TYPE="HIDDEN" VALUE=""+window.screen.colorDepth+"">");
    //-->
    </SCRIPT>
    </FORM>
    [/code]

    You then have to submit this form somehow.

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl

Similar Threads

  1. Flash in apache - wont work!
    By Fish_12345 in forum Apache Development
    Replies: 2
    Last Post: October 11th, 2004, 02:43 PM
  2. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 11:50 PM
  3. Experienced undergrad senior ... freelance work wanted
    By carrja99 in forum Hire A Programmer
    Replies: 0
    Last Post: January 29th, 2004, 12:32 AM
  4. I'll pay someone $150 to do some PHP work for me!
    By Noah Neiman in forum Hire A Programmer
    Replies: 16
    Last Post: January 23rd, 2004, 04:15 AM
  5. I need some specific php work done for my website
    By Noah Neiman in forum Hire A Programmer
    Replies: 1
    Last Post: January 21st, 2004, 12:31 AM

IMN logo majestic logo threadwatch logo seochat tools logo