0

I have the following problem:

onclick=langedit('".$carray2['example']."','".$carray2['id']."')

$carray2['example'] is a string containing "ABOUT US" with space, and this is the output in HTML:

onclick='langedit('Contact" us','9')="">

My PHP code :

else {
$cquery2 = mysql_query ("SELECT id,example,".$startlan." FROM language WHERE example = '$word'");
$carray2 = mysql_fetch_array($cquery2);
if($carray2[$startlan] == '') {
if($_SESSION['view'] == 'admin' && isset($_SESSION['siteshow'])){
echo  "<span class='langedit' id='langedit".$carray2['id']."' onclick=langedit('".$carray2['example']."','".$carray2['id']."')><img src='images/sys/edit.png' > </span>";
return $carray2['example'];
}else{
return $carray2['example'];
}
}

I don't know what's happening, the langedit function does not work because of this.

3
  • You're going to need to add more code. Commented Sep 28, 2012 at 15:41
  • Have you tried running that line? It doesn't generate the output you've given. You're going to need to show us more code than that. Commented Sep 28, 2012 at 15:44
  • P.S when i edit my DB and insert into here AboutUs instead of About Us it works perfectly Commented Sep 28, 2012 at 15:49

1 Answer 1

2

Cover the langedit call on onclick with double quotes

onclick=\"langedit('".$carray2['example']."','".$carray2['id']."')\"

Otherwise if $carray2['example'] is About Us, the onclick attribute becomes onclick=langedit('About which is an invalid function call.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.