Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-08-2004, 08:58 PM Strip Spaces
jake5253's Avatar
Average Talker

Posts: 27
Location: Pennsylvania, USA
Trades: 0
Hi.

SubProfile Guest Book script seems to be not cooperating when i attempt a stripspaces command. I've tried and tried and cant get it to strip the spaces from the "screen name" field.

***note: Screen Name field was named 'email' simply because I used this script for another guestbook in which I didn't need/want aim screennames. Now, I want the screen names, and no email so i plan to just leave it as 'email' as no one but me will see the code after it's working! Since e-mail addresses dont have spaces, i didn't worry about stripping them when i made the old script; however, since AIM allows spaces, i need them removed, or changed to "+" in my database and 'behind the scenes' but shown without the 'computer jargon' when shown as a link. (ex the link can be "this+contains+spaces" but i need it to be printed to the user as "this contains spaces") AIM doesn't seem to acknowledge there's a space in a link if it's not shown as +, it would just see the above link as "this", minus the "contains spaces"."

I hope you understand what my problem is and can help me!

Thanks!
~Jake

PHP Code:
<?php
$dbhost 
"localhost";  // this is mostly "localhost"
$databees "guest";  // this is the name of your database
$dbusername "root"// this is your username
$dbpassword "5253"// this is your password


/* Form to add entries */
?>
<table><form method="post" action="sign.php">
<tr><td><b>Name:</b></td><td><input type="text" name="naam" STYLE="BORDER: black 1px solid; WIDTH: 144px; height: 15px; color:black; font-size: xx-small; background: white;" size="25"></td></tr>
<tr><td><b>Screen Name:</b></td><td><input type="text" name="email" STYLE="BORDER: black 1px solid; WIDTH: 144px; height: 15px; color:black; font-size: xx-small; background: white;" size="25"></td></tr>
<tr><td><b>Comments:</b></td><td><textarea type="comment" name="commentaar" STYLE="overflow:hidden; BORDER: black 1px solid; color: black; WIDTH: 144px; height: 80px; font-size: small; background: white"; cols="35" rows="8"></textarea></tr>
<tr><td> </td><td><input type="submit" name="posten" value="ok"><input type="reset" name="opnieuw" value="reset"></td></tr>
</form></table><?


/* connecting to the database */
if ($HTTP_POST_VARS['posten']) {
mysql_connect($dbhost,$dbusername,$dbpassword); 
mysql_select_db($databees);

/* Let's check that the necesarry fields are filled in */
/* btw, || is OR */

if (($naam <> "") && ($commentaar <>"")){
    
/* Let's strip html tags out of the posts, so bad 1337 h4x0rZ can't abuse the guestbok with dirty HTML tags */ 
$naam strip_tags($naam);
$website strip_tags($website);
$email strip_tags($email);
$commentaar strip_tags($commentaar);

/* Good! Let's add it to the database :) */
$insert "INSERT INTO guestbook (naam,website,email,commentaar) VALUES ('$naam','$website','$email','$commentaar')"
$query mysql_query($insert)or die(mysql_error());

echo 
"Successful!";
} else {
echo 
"You need to fill in your name and your comments!";
}
}
jake5253 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-08-2004, 09:12 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Well I don't know what you're talking about lol But I'll try.

Insert the AIM names with the spaces in tact. ie: "screen name".

When it's time to put it in a URL, just use url_encode() to produce something like: "screen+name".
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 08-08-2004, 09:17 PM
jake5253's Avatar
Average Talker

Posts: 27
Location: Pennsylvania, USA
Trades: 0
now when you say "just use url_encode()" you mean to use it in the form of....?

the line that produces the link in the viewing page is
PHP Code:
echo "<tr><td><b>Screen Name: </b></td><td><a href=\"aim:goim?screenname=".$list['email']."\">".$list['email']."</a></td></tr><br>"
think you could perhaps point me in the direction of how to insert url_encode() into that line?

Thanks
jake5253 is offline
Reply With Quote
View Public Profile
 
Old 08-08-2004, 09:19 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
url_encode() just takes any string and encodes it into a URL (meaning spaces become + etc)

That line would become:
PHP Code:
echo "<tr><td><b>Screen Name: </b></td><td><a href=\"aim:goim?screenname=".url_encode($list['email'])."\">".$list['email']."</a></td></tr><br>"
Thus url_encode($list['email']).
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 08-08-2004, 10:12 PM
jake5253's Avatar
Average Talker

Posts: 27
Location: Pennsylvania, USA
Trades: 0
Ah. Thanks soo much, though I had an error, it seems to only work when i use urlencode rather than url_encode. Makes no sense to me, but at least it works now.
Thanks again!
jake5253 is offline
Reply With Quote
View Public Profile
 
Old 08-08-2004, 10:18 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Probably because it is indeed urlencode and not url_encode My bad
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Strip Spaces
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42161 seconds with 12 queries