Check out this image I did for school and this neat php page I did for fun

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

jjones

Lifer
Oct 9, 2001
15,424
2
0


<< I learned what I know now because of a hunger for solving the "puzzle" aspect of it all. Now, for some reason, it just seems like work. >>


That's why you should learn PHP. HTML design does get boring after a while but PHP is lots of fun and when you're writing scripts it does give you that puzzle aspect when you have to figure out the logical statements. It gets even more fun when you start using PHP as a database interface.

BTW, I never learned any programming in school but learned just by buying one or two books, visiting tutorial and reference sites, and then tearing apart web pages and scripts.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
some suggestions:

1) remove the escape character from quotes wwhen they're displayed on the page. having "cat's" show up as "cat\'s" doesn't look real good.

2) replace the < and > characters with < and > Look at the page again and you'll see what I mean :)

3) instad of replacing newlines with a space, try replacing them with "
". It keeps the formatting that the author wanted :)
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
notfred,
thanks for the input, I'll work on that.

what you mean replace them with "
" ?

currently I use file() to read the file into an array and then explode it, should I change it and just use a seperator for the comments also?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
it wasn't "" when I wrote it, damn fusetalk.

I meant to replace the < and > characters with &_lt; and &_gt; (remove the _'s...) and to replace newlines with <_br> (remove underscore again)

It's hard to show html encoding stuff on a forum :)
 

jjones

Lifer
Oct 9, 2001
15,424
2
0
Czar, on a tangent about the graphic, you can compress that rather large 109k png file in gif format to less than half that size without losing any quality.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
here's a little guestbook script I wrote a while back. It handles html tags nicely (script even lets you enable and disable html as you like).

It's not as pretty as your page is, but I think it handles text better (no offense to your script). Thought you might draw some inspiration from it. I'll send you the code for it if you like, but it's in perl :)
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
MrCodeDude,
Its just a simple script that writes one line with date, time, ip and a link to the page it was linked into a file. Then I just read the file and count the lines.

notfred,
ah I know what you mean, should I use str_replace or is there some function built in php that I can use?
I know my code isnt exactly great but it is great compared to some of my old stuff. I did a multi user video database using php and mysql and didnt quite finish it, and now when I look at the code I see that I must start all over again :p

jjones
I noticed that, originaly it was supposed to be a gif file but then I had some problem with photoshop so I just did it as a png file, will probably use fireworks if photoshop gives me trouble again.




sorry... was having some problem with the server computer so I decided to add a 10gb disk, it took a while
 

notfred

Lifer
Feb 12, 2001
38,241
4
0


<< notfred, ah I know what you mean, should I use str_replace or is there some function built in php that I can use? >>



no idea, in perl it's: $var =~ s/old_pattern/new_string/g;

I don't know PHP :)
 

Czar

Lifer
Oct 9, 1999
28,510
0
0


<<

<< notfred, ah I know what you mean, should I use str_replace or is there some function built in php that I can use? >>



no idea, in perl it's: $var =~ s/old_pattern/new_string/g;

I don't know PHP :)
>>


hehe, and all this time I thought you were some php genious, but than it turns out its just perl:p

thanks for thi tops though :)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0


<<

<<

<< notfred, ah I know what you mean, should I use str_replace or is there some function built in php that I can use? >>



no idea, in perl it's: $var =~ s/old_pattern/new_string/g;

I don't know PHP :)
>>


hehe, and all this time I thought you were some php genious, but than it turns out its just perl:p

thanks for thi tops though :)
>>



you can call it "just perl" if you like, but it's still a much better (and more versatile) language than PHP, in my opinion. :)

Oh, and which script works right, the perl one, or the PHP one? :p
 

Czar

Lifer
Oct 9, 1999
28,510
0
0


<< you can call it "just perl" if you like, but it's still a much better (and more versatile) language than PHP, in my opinion. :)

Oh, and which script works right, the perl one, or the PHP one? :p
>>


I dont know perl so I cant say which is better but from what I heard php us much easier to work with and perl is a chaotic bitch :p
sure sure, your works better, I admit that... but mine looks better neener neener :D
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Yeah, AOL is easy to work with, too :)

I'll admit, it's not the prettiest language in the world, though.

Excerpt from that guestbook script:

foreach my $line(@book_data){
unless($allow_html){
$line =~ s/</&lt;/g;
$line =~ s/>/&gt;//g;
$line =~ s/&lt;br&gt;/<br>/g;
}
$line =~ s/([^\t]*)\t\t/Name: $1 <br> Comments:<br> /;
$line =~ s/([^\t]*)\t([^\t]*)\t/Name: $1 <br> Email: <a href="mailto:$2">$2<\/a> <br>Comments: /;
$line =~ s/\t/<br><br><font size="1" face=\"Arial, Helvetica\"><b>/;
print "$line</b></font><hr><test>";
}


edit: damn, getting the text right on here is a pain....
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
see see, that looks like crap :p

Its like comparing Assembly(perl) to C(php), assembly might be way more powerful but its very hard to work with.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
looks better now, but not nearly as good as php :p

$line =~ s/</</g;
$line =~ s/>/>//g;
$line =~ s/
/
/g;

Is this the part that converts < to the other thing?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0


<< looks better now, but not nearly as good as php :p

$line =~ s/</</g;
$line =~ s/>/>//g;
$line =~ s/
/
/g;

Is this the part that converts < to the other thing?
>>



that unless statement is what removes html tags (well, not really removes them, just makes them show up as text rather than html formatting.)
 

TheOmegaCode

Platinum Member
Aug 7, 2001
2,954
1
0
you think you could post, or pm me your code? I wont steal it, I would just like to see a practical application of PHP. I like how you have your form post on the same page. All I get on php tutorial sites are <? { print('this is php') } ?> What's the point of echoing text? I learned HTML by looking at other peoples sites, but I can't look at server-side languages :(.
nice little page, and pic, btw...