Jump to content

weirdest problem ive encountered..


Rifts

Recommended Posts

ok what in the world is going on here...

 

I have a simple javascript code to switch out the text between a div there are 4 rotations

 

the text that is being switched is populated from my DB using php.

 

now the weird part.

 

in my DB i'm using longtext now If the text in the db is all one paragraph everything works fine but if there is any type of line break or new paragraph the script wont rotate at all.

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/218214-weirdest-problem-ive-encountered/
Share on other sites

No no errors at all.

 

here is the code.. so yeah if i change ANY of the 4 text fields and add a break at all it just doesn't rotate.

<?

include 'dbconfig.php';

$result = mysql_query(" SELECT * FROM featured where active='2' ");
while($row = mysql_fetch_array($result))
	  {
			$text2 = $row['text'];
			$img2 = $row['image'];
	  }
$result = mysql_query(" SELECT * FROM featured where active='3' ");
while($row = mysql_fetch_array($result))
	  {
			$text3 = $row['text'];
			$img3 = $row['image'];
	  }
$result = mysql_query(" SELECT * FROM featured where active='4' ");
while($row = mysql_fetch_array($result))
	  {
			$text4 = $row['text'];
			$img4 = $row['image'];
	  }
$result = mysql_query(" SELECT * FROM featured where active='1' ");
while($row = mysql_fetch_array($result))
	  {
			$text1 = $row['text'];
			$img1 = $row['image'];
	  }
	  
	  
?>

<script type="text/javascript">

var test=new Array();
  test[0]='<?= $text2; ?>';
  test[1]='<?= $text3; ?>';
  test[2]='<?= $text4; ?>';
  test[3]='<?= $text1; ?>';


var speed=5000;
var q=0;

function showQuote() {

     document.getElementById("tests").innerHTML=test[q];
     q++;
if(q==test.length) {
     q=0;
  }
}
setInterval('showQuote()',speed);

</script>
   

 

for example if i change one of the text fields from

 

hello, welcome to my site

 

to

 

hello,

welcome to my site

 

 

it breaks it

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.