SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unterminated String Literal

    Dear All,
    I am setting dynamically a function call in my php as like this onClick=selectAndUpdate('".$row1[serialNo]."','".$row1[bC]."','".$row1[size]."','".$row1[pattern]."'); Then when I run I get this error unterminated string literal selectAndUpdate('EA13','GY','210/60R. That means my third value from the db got problem due to the slash right? How to overcome this?

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Location
    Perundurai, Tamilnadu, India
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using addslashes function to escape single quotes, like below

    onClick=selectAndUpdate('".addslashes($row1[serialNo])."','".addslashes($row1[bC])."','".addslashes($row1[size])."','".addslashes($row1[pattern])."');
    This might fix your problem

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Suresh,
    What is the job of this function addslashes and is this part of javascript?

  4. #4
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Suresh,
    I have tried your method but is the same I get the same error too.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Suresh,
    What is the job of this function addslashes and is this part of javascript?
    No - it is a part of the PHP that is generating the JavaScript.

    You don't actually need to add that to fix your PHP error though - which is somewhere further along in the code where you have a missing quote to terminate the string that starts with "');.....<-- missing " somewhere here.

    If you were to post the entire PHP statement that has the error it might be easier to spot the missing quote. We can't spot it in the code you did post because all the ones in that part of the statement are where they are supposed to be.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Felgall,
    Below is the fullcodes. So can hint where is the wrong? Thank you.

    echo "<tr id='gridRow'>
    <td >$count</td>
    <td><input type='checkbox' name='sNo' value='' onClick=selectAndUpdate('".addslashes($row1[serialNo])."','".addslashes($row1[bC])."','".addslashes($row1[size])."','".addslashes($row1[pattern])."'); /></td>
    <td> {$row1[serialNo]}</td>
    <td> {$row1[hB]}</td>
    <td> {$row1[bC]}</td>
    <td> {$row1[size]}</td>
    <td> {$row1[pattern]}</td>
    <td> {$row1[etatus]}</td>
    </tr>";

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Location
    Perundurai, Tamilnadu, India
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can copy and paste the browser view source code from error line, we might help you quickly.

  8. #8
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Suresh,
    For the benefit of everyone this helped solve it echo "<input type=\"checkbox\" onClick=\"selectAndUpdate('" . $row1[size] . "')\">";


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
  •