SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unterminated string constant

    hello
    I have a php code which is:
    $bodier .= "setInterval('updateClock(\"$date2\",\"clock$x\")',1000);";

    I use it like this:
    <body onLoad="<?php echo trim($bodier) ; ?>">
    it produces:
    <body onLoad="setInterval('updateClock("2012-10-31 13:14:01","clock0")',1000);setInterval('updateClock("2012-08-30 13:10:31","clock1")',1000);setInterval('updateClock("2012-08-30 10:16:46","clock2")',1000);setInterval('updateClock("2012-08-30 10:17:28","clock3")',1000);setInterval('updateClock("2012-09-07 10:17:47","clock4")',1000);setInterval('updateClock("2012-08-30 10:18:27","clock5")',1000);setInterval('updateClock("2012-08-29 10:18:41","clock6")',1000);">

    and it products an error:
    Unterminates string constant

    What am I doing wrong

    I have also tried copying psting simpley the output as hardcoded instead of the php echo part

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,063
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You need to write out an escaped double quote, so your PHP code I believe should be
    PHP Code:
    $bodier .= "setInterval('updateClock(\\\"$date2\\\",\\\"clock$x\\\")',1000);"


Bookmarks

Posting Permissions

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