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

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:-


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??

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

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


$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?

try replacing \r and
with nothing using str_replace :slight_smile:

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

tried


$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??

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?

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.

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 :frowning:

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

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?:stuck_out_tongue: