# \[php\] force an html line to be all on one line

**URL:** https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983
**Category:** programming
**Created:** [July 18, 2004, 8:17pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983 "2004-07-18T20:17:19Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bunjiquo](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@bunjiquo](https://forum.kirupa.com/u/bunjiquo)
#### Post date: [July 18, 2004, 8:17pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/1 "2004-07-18T20:17:19Z")

</div>

I have an annoying error while trying to get javascript rollovers to work in php.

when my code is generated it splits the javascript onto multiple lines and this causes unterminated string constant errors in IE.

my php code is:-

```php

echo "<td width=\"205\" rowspan=\"3\" valign=\"top\"><a href=\"#\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('$row[ppcode]','','$row[rollover]',1)\"><img src=\"$row[pic]\" name=\"$row[ppcode]\" width=\"205\" height=\"154\" border=\"0\"></a></td>";

```

which in my editor is all on one line.

The html it generates is split over multiple lines and i dont know why.

the splits always come just after a value that has been called from MySQL db.

Is there a way i can force the line to generate as 1 line of code??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 8:50pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/2 "2004-07-18T20:50:43Z")

</div>

perhaps at the end of your mysql result you have a line break like  
or something?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 8:55pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/3 "2004-07-18T20:55:13Z")

</div>

definitely not that. ive checked… but my mistakes are normally that stupid!

Ive played with the code a bit and found that if i add in

```php

$row[ppcode] = $ppcode;
$row[pic] = $pic;
$row[rollover] = $rollover;

```

the code is all on one line but it doesnt call the info from the db so the pics dont show

Is there a way i can implement this style in and make it work?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:02pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/4 "2004-07-18T21:02:23Z")

</div>

try replacing \r and  
with nothing using str\_replace 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:12pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/5 "2004-07-18T21:12:53Z")

</div>

> [@bunjiquo](#):
>
> definitely not that. ive checked… but my mistakes are normally that stupid!
> 
> Ive played with the code a bit and found that if i add in
> 
> ```php
> 
> $row[ppcode] = $ppcode;
> $row[pic] = $pic;
> $row[rollover] = $rollover;
> 
> ```
> 
> the code is all on one line but it doesnt call the info from the db so the pics dont show
> 
> Is there a way i can implement this style in and make it work?

the reason that that returns nothing is because you are setting them to nothiing lol, flip it around.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:23pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/6 "2004-07-18T21:23:09Z")

</div>

tried

```php

$strippers = array("
","\r"," ");
str_replace($strippers, "",$row[ppcode]);
str_replace($strippers, "",$row[pic]);
str_replace($strippers, "",$row[rollover]);

```

didnt make an difference. I just dont get why its putting in a line break after the row information is inserted!

Altho my code seems to line break after every item that is put in from the db, regardless of being in the jscript or not??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:41pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/7 "2004-07-18T21:41:09Z")

</div>

thanks for that yeldarb! im tired at looking at this!

Still no good though. The switching them round means that the things from the db are assigned to those new variables but still the code is split over multiple lines…

This is annoying me now! LOL

do you think it could simply be length that is forcing a text wrap? I didnt think it was possible but maybe some weird setting somewhere on the server?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:47pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/8 "2004-07-18T21:47:22Z")

</div>

try using mysql\_fetch\_row instead of mysql\_fetch\_array (i assume that’s what you are using) then use the column numbers instead of the column names (ie for the first column $row[0]) I’ve always used that and never had a problem with line breaks.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 9:51pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/9 "2004-07-18T21:51:59Z")

</div>

ok, ill try that yeldarb

Ive just rewritten my javascript bit to pull shorter entries from the db.

This way, obviolsy the pics dont load so i cant check the rollovers BUT… the line of code is all on one line!

so perhaps it is length of the strings? i really hope i dont have to rename all my files and change my db entries ☹

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 18, 2004, 10:12pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/10 "2004-07-18T22:12:59Z")

</div>

tried mysql\_fetch\_row (i was using array) and no difference. exactly the same problem.

Gonna contact my host to see if they have some kind of setting to force a line break after so many characters or something…

really dont want to rename it all!

note to self…

never use really long filenames!

cheers for the suggestions, If theres any more keep them coming!!

bunji

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:17pm UTC](https://forum.kirupa.com/t/php-force-an-html-line-to-be-all-on-one-line/57983/11 "2004-07-23T20:17:08Z")

</div>

WOO HOO!

solved! after many hours of heart ache i have found my solution! It seems that when my MySQL database was typed each entry had a carriage return in it (not actually visible just an ‘ive pressed enter here’) . therefore when called it added a new line into the HTML! so…on deletion of these it all works!

Anyone know of any way to strip invisible carriage returns?😛
