Page 1 of 1
View Source Function
Posted: Wed Jun 19, 2002 12:48 pm
by icesolid
I have a small scripts section on my site, and I show the source code for each script right out of the database onto the script page using the hightlight_string(); function.
The only thing that sucks is that some of the scripts push out my tables on my site and make it look real <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>. I have also tried the show_source(); function, and that does the exact same thing (obviously).
So I guess what I am asking is if there is anyway to make it so that when the source code is printed out, it does not override my tables and push them way out.
Posted: Wed Jun 19, 2002 1:14 pm
by Zmodem
I don't have any experience with this function, but would it help if you specified specific lengths for your table, rather than using a percentage?
Like this:
<table width="300">
instead of:
<table width="50%">
I never use percents
Posted: Thu Jun 20, 2002 12:46 pm
by icesolid
I never use percents on my current design. So that can not be it.
Got any other ideas.

Posted: Thu Jun 20, 2002 1:08 pm
by Junk Guy
Wrap the output with
<PRE>...</PRE>
?
Posted: Thu Jun 20, 2002 1:10 pm
by e+
it's very strange, maybe it's an issue with having so many nested tables? I've tried to follow them in the source but I couldn't see why they seem to ignore your 'width='?
Posted: Thu Jun 20, 2002 1:19 pm
by twigletmac
Does highlight_string() not line wrap? (I can't seem to get on php.net to find out). If it doesn't that's probably why it's breaking your tables.
Mac
Posted: Thu Jun 20, 2002 1:35 pm
by e+
found it!
in
Title: Edit MySQL Records
Category: Databases
Date: Saturday, April 6, 2002
on line 57 of the output you have a great big long mysql query
$result = mysql_query("UPDATE users SET name='$name',email='$email',phone='$phone' WHERE id=$id");
But there are no spaces in it so it can't word wrap, so it forces the table to be to wide. If you put a space in yourself at the appropriate point it will wrap ok. It might have been easier to debug without all the font tags, a bit of CSS would save you a lot of coding.

Still no help
Posted: Fri Jun 21, 2002 11:59 am
by icesolid
No, none of your ideas have worked. The <pre></pre> thing just makes all the code print out without any wrapping, so its worse.
Any one else with an idea?
P.S. e+ I am not talking about the script code in my database. I am talking about when I go to print out that code, how do I make it so it will not push out my tables.
Posted: Fri Jun 21, 2002 12:45 pm
by e+
If you put spaces after the commas in your code it will work fine (or at least for the example I found). It's still perfectly acceptable code but it won't force the cell to be so wide. Because you have one VERY long string of letters the cell can't stay within the width you have told it to be so it's overiding your width command and making the cell as wide as the longest string of letters (the sql query). Once you put spaces in after your commas it will be able to wrap the text within the cell and not force it to resize. I know this works because I have done it to the source I captured from your page.
Posted: Fri Jun 21, 2002 12:57 pm
by will
actually i believe the problem to be with the PHP functions. they convert all spaces to . Therefore all lines become incredibly long strings (with no spaces)... the only place for the function to wrap is at the end of the line. try looking at the source that either PHP function outputs...you should see what i'm talking about.
as far as a way around this? write a wrapper that converts the back to spaces? very inefficient and dirty, but it would work.
Posted: Fri Jun 21, 2002 1:07 pm
by e+
I'm not lying to you all it really does work if you put a space after the commas, viewsource edit it and see for yourselves. With regards the non breaking spaces it doesn't matter because the browser interprets these as spaces and is happy to wrap them.

Posted: Fri Jun 21, 2002 1:28 pm
by will
i'm assuming you mean adding spaces after the commas in his mysql call? that may work fine for that line, but what about any other long ones. i too have a 'viewsource' page on my site, and it simply will not break a block of text to wrap it. it will see the space between an HTML tag and it's attribute, but not with blocks of text... they are all converted to and won't budge.
<edit>
ok, well i found out why it's not working for me....not sure if it will apply to the issue that started this thread. i am echo()ing out rather large strings, and it is the text blocks in these that won't break. if you "?>" out of your PHP code, do your large blocks of pure HTML, and then "<?php" back in, it wraps
</edit>