troubleshooting Question

Javascript with PHP error

Avatar of crash_master25
crash_master25 asked on
11 Comments1 Solution376 ViewsLast Modified:
Hi to everybody...

I don't know if this question is ok here, because have javascript and PHP... I have a strange situation here, I'm makeing a banner rotator, and the banners are extracted from a database with php. this is the code of the rotator:

function rotate(i) {
  switch (i) {
  $X = 1;
  $Num_filas = mysql_num_rows($resultado);

  While ($fila=mysql_fetch_assoc($resultado))
    $Foto = $fila["Foto"];
      $IDP = $fila["Album"];
    case <?=$X?>:
      BANNER.innerHTML = "<a href=\"#\" onClick=\"'album.php?ID=<?=$IDP?>&SID=<?=$SID?>', 'NoLink', 'scrollbars=yes,resizable=no,width=570,height=500,left=200,top=150')\"><img border='0' src='upload/<?=$Foto?>' width='300' height='120' border='0'><a>";
        if ($X + 1 <= $Num_filas){
          echo $X + 1;
        } else {
          echo 1;
        }?>)", 15000);
if ($X < $Num_filas) {
  $X = $X + 1;
} else {
  $X = 1;

the banner rotates ok, but when I open the page in a new window show me an error and when I see the source code this is that I look:

function rotate(i) {
  switch (i) {
    case 1:
      BANNER.innerHTML = "<a href="\?PHPSESSID=7413614ddff68683a5ad023d4acee605""#\" onClick=\"'album.php?ID=6&SID=7413614ddff68683a5ad023d4acee605', 'NoLink', 'scrollbars=yes,resizable=no,width=570,height=500,left=200,top=150')\"><img border='0' src='upload/img3ed3aa59ef1d6.jpg' width='300' height='120' border='0'><a>";
      setTimeout("rotate(2)", 15000);
    case 2:
      BANNER.innerHTML = "<a href="\?PHPSESSID=7413614ddff68683a5ad023d4acee605""#\" onClick=\"'album.php?ID=7&SID=7413614ddff68683a5ad023d4acee605', 'NoLink', 'scrollbars=yes,resizable=no,width=570,height=500,left=200,top=150')\"><img border='0' src='upload/img3ed3b35fb0a61.jpg' width='300' height='120' border='0'><a>";
      setTimeout("rotate(1)", 15000);
      alert("Invalid Interval!");
if you see, the problem is that in the first \" of the href= it change with the ?PHPSESSID=7413614ddff68683a5ad023d4acee605 and I don't know why... do you have any idea???

Bruno Chavez

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros