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?

Try using addslashes function to escape single quotes, like below


This might fix your problem

Dear Suresh,
What is the job of this function addslashes and is this part of javascript?

Dear Suresh,
I have tried your method but is the same I get the same error too.

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.

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>

If you can copy and paste the browser view source code from error line, we might help you quickly.

Dear Suresh,
For the benefit of everyone this helped solve it echo “<input type=\“checkbox\” onClick=\“selectAndUpdate('” . $row1[size] . “')\”>”;