SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP & Javascript - Unterminated String Error

    Hello Folks;

    I have this slight problem with using Javascript with PHP - I get an error saying that there is an unterminated string.

    At the moment I'm using data pulled from the database and all is okay bar one row, for example I have this:

    Title

    The More You Cry, The Less We Care

    Story

    Did the Cafe Verona thing again last night, stumbling through
    a Vigilantes Of Love tune and then <a href="http://wwww.scottandrew.com/main/songs/the_big_lie">The Big
    Lie That Solves Everything</a>, which I'd never played live before.
    The crowd was really responsive, which made me feel as if I'd pulled a
    fast one, they fell for it, ha ha !
    Some really great performers last night.
    Bob Mould <a href="http://www.bayarea.com/mld/mercurynews/616102.htm">
    plays</a> the Great American Music Hall next Thursday.
    <a href="http://www.bayarea.com/mld/mecurynews/6153932.htm">
    Starving session drummers</a>. Now I feel bad.
    I had a looong post about the recent RSS flap and subsequent
    <a href="http://www.intertwingly.net/wiki/pie">Echo project</a>. But
    after reading it, I remembered why I don't write about this stuff on
    this site anymore. Geez, even <i>I</i> don't care what I think. But
    here's the summary anyway - Dear Echo project: no hard feelings, but
    you <i>blinked</i>, okay ? Okay.
    On a plane in two hours. wOOt.

    Anyways, the above was entered via myPhpAdmin as is, now here is some script which I've written. There is no problem at all in the way the OO works (since date and title output fine enough) which makes me wonder about those quotes in the story ?

    I have magic_quotes off though having them on makes no difference either ;( Just cannot seem to see what the problem is ?

    PHP Code:
    # connect to mysql database server
        $dbase = & new mySQLAccess('user', '', '', '');
        
        $dao = & new logDao($dbase);
        $result = $dao -> searchAll(' LIMIT 1');
        $params = false;
        #
        if($result -> rowCount()) {
            $params = array();  
            $dao -> processLogs($result);
            # access logs
            $iterate = & new arrayIterator($dao -> fetch());
                    
            while($row = $iterate -> getCurrent()) {
                $params[] = $row;
                # next iteration
                $iterate -> getNext();
            }
        }
        #
        $iterate = & new arrayIterator($params);
        
        while($row = $iterate -> getCurrent()) {
            #
            $id = $row -> getId();
            $date = getBasicDate($row -> getDate());
            $title = $row -> getTitle();
            $story = $row -> getStory();
            ?>
            string  = '<tr><td width="100%" align="left" height="24" valign="center"><?php echo($date); ?></td></tr>';
            document.write(string);
            string  = '<tr><td width="100%" align="left" height="24" valign="center"><?php echo($title); ?></td></tr>';
            document.write(string);
            string  = '<tr><td width="100%" align="left" height="24" valign="center"><?php echo($story); ?></td></tr>';
            document.write(string);
            <?php
            $iterate 
    -> getNext();    
        }    
        
    ?>
    Any help is always welcome.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    --BUMP--


  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm... Okay folks, getting somewhere...

    I need to put this into the database as is:

    PHP Code:
    <a href='http:\/\/www.mydomain.com'>Click Me</a
    For the script/Javascript to work, right ? From what I see of it, I need to escape ' and / which is fair enough although things don't work if the single quotes in the A anchor tag are also escaped...

    At the moment I also have made this change to the above script:

    PHP Code:
    .
    .
    $story addslashes($story);
    .

    Any thoughts ? ...

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved... Is there ain't nothing I can't do ?

  5. #5
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    . . . Is there ain't nothing I can't do ?
    Sure; use proper grammar.
    Of course, that's just my opinion. I could be wrong.


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
  •