1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

javascript string -> php string

Discussion in 'PHP' started by SedNaX, May 14, 2007.

  1. #1
    I have declared a javascript string but it needs to be converted into a php string.. i have searched around a lot but i can't find the answer:confused:


    i have a string called String in javascript

    .....
    String
    </script>


    that string needs to be entered in a database, but therefore it needs to be stored into a php string.... how??
     
    SedNaX, May 14, 2007 IP
  2. xooMan

    xooMan Peon

    Messages:
    92
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    PHP and JavaScript are absolutely different things: PHP is server-side language, while JavaScript is client side. You have to somehow pass this string to PHP script with via GET or POST request.
     
    xooMan, May 14, 2007 IP
  3. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #3
    yes i know... i found something with sessions, but that didn't work for me.

    get and post are useless for me.. it works a bit like this:


    if a<2 it needs to add something, else it needs to insert a random name, declared in a 10,000 lines javascript.
     
    SedNaX, May 14, 2007 IP
  4. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As mentioned you'll need to find a different way to pass it.. most common ways are the following:

    GET
    POST
    Session
    Cookie

    **EDIT**

    This Google search should help :)
     
    CodyRo, May 14, 2007 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    before you give up, can you post the ( shortened, but working ) actual javascript, I see nico looking too, never say never ....
     
    krakjoe, May 14, 2007 IP
  6. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #6
    `here is the last bit, it should be enough i think :)
     
    SedNaX, May 14, 2007 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    ok lets try the whole javascript or a link to the live page then ....
     
    krakjoe, May 14, 2007 IP
  8. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #8
    SedNaX, May 14, 2007 IP
  9. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #9
    you can send any string from javascript to php using get,post etc method.
    example:request.open("GET", "page.php?string=" + string, true);

    you just catch it in the page.php using $_GET['string']
     
    coderbari, May 14, 2007 IP
    SedNaX likes this.
  10. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #10
    yes i tried that and it works. not exactly what i wanted but this way it does what i want also :)

    thanks!
     
    SedNaX, May 14, 2007 IP