TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 01-24-2008, 12:58 PM   #21 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 700
Thanks: 2
Salathe is on a distinguished road
Default

Quote:
Originally Posted by danielneri View Post
Whoa wait: side note

mysql_result is deprecated?! what replaced it? and when?

wow where have I been...
mysql_result isn't depreciated but here's a note from the PHP manual:
When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mysql_result().
__________________
Salathe is offline  
Reply With Quote
Old 01-24-2008, 11:13 PM   #22 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 818
Thanks: 163
Orc is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
mysql_result isn't depreciated but here's a note from the PHP manual:
When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mysql_result().
Well then a tutorial I read was wrong, and I hate them all.
__________________
Wax on, Wax off
Orc is offline  
Reply With Quote
Old 01-25-2008, 05:59 PM   #23 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 445
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by Alan @ CIT View Post
mysql_result() isn't officially depreciated as far as I know.

Alan
As Salathe said, it indeed is not depreciated. I use if for large queries. For example, when using queries like "LIKE" and "WHERE".
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-31-2008, 08:00 PM   #24 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 81
Thanks: 49
StevenF is on a distinguished road
Default

I've just created another guest book with the same code for practice. I'll probably do it a few times until I can write it from memory. I do have one questions though. Some one told me when setting the variables from the form, to use this:

Code:
$yourname = addslashes($_POST['yourname']);
	$email = urlencode(addslashes($_POST['Email']));
	$website = urlencode(addslashes($_POST['website']));
	$comment = htmlentities(addslashes(strip_tags($_POST['comment'])));
The only thing with that is, when it's submitted it's displaying the email and website like bellow:

Quote:
Steven%40hotmail.com

http%3A%2F%2Fgoogle.com
Now, I could fix it by removing the urlencode, addslashes and htmlentities, but I was told to add that in. Do I really need it?
StevenF is offline  
Reply With Quote
Old 01-31-2008, 08:24 PM   #25 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 445
Thanks: 49
ReSpawN is on a distinguished road
Default

You can use the function urldecode() to decode your encoded URL string. I've never used it on an email or such but that's me. addslashes() should suffice. And those can be decoded with stripslashes() as you might know. addslashes() only escapes quote tags and such. For extra security, I advice you to use mysql_real_escape_string for your queries and even sprintf() if you want to be on the safe side.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
StevenF (01-31-2008)
Old 01-31-2008, 08:43 PM   #26 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 81
Thanks: 49
StevenF is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
You can use the function urldecode() to decode your encoded URL string. I've never used it on an email or such but that's me. addslashes() should suffice. And those can be decoded with stripslashes() as you might know. addslashes() only escapes quote tags and such. For extra security, I advice you to use mysql_real_escape_string for your queries and even sprintf() if you want to be on the safe side.
Thanks for your reply.

At first read that made no sense to me what so ever. After a second time things started to click! I had been using addslashes to encode all of the fields, however, I didn't know how to (or that I had to) decode them. I've now used stripslashes and urldecode to decode the strings.

I've also used mysql_real_escape for my queries but haven't heard of sprintf() before.

PS: How easy is it to make a variable a hyperlink?

Last edited by StevenF : 01-31-2008 at 09:12 PM.
StevenF is offline  
Reply With Quote
Old 02-01-2008, 08:12 PM   #27 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 482
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Wildhoney has written a great article about securing queries with sprintf() - TalkPHP - Securing your MySQL Queries with Sprintf

As for making a variable into a hyperlink, I'm not sure what you mean, but:

PHP Code:
$myVariable 'http://www.example.com/index.php';
$anotherVar '<a href="http://www.talkphp.com">TalkPHP.com!</a>';
echo 
'http://www.example.com/index.php?page=' $pageVar
Hopefully one of those is what you where after?

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 02-02-2008, 01:22 PM   #28 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 81
Thanks: 49
StevenF is on a distinguished road
Default

Thanks Alan, I'll have a read over that article!

I'm not sure if the hyperlink thing is possible, but I'll try and explain what I'm looking for: I have a name field and a website field in the form. The data entered in those fields are stored as variables and entered into a database. I then display the information on another page.

When clicking the persons name, I would like that to link to the website they entered in form. This is an example, but totally wrong:

Code:
<a href="$website" alt="" ><?php echo $guestsname; ?></a>
Basically, linking the persons name to the value stored in the variable.
StevenF is offline  
Reply With Quote
Old 02-02-2008, 04:08 PM   #29 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 265
Thanks: 2
TlcAndres is on a distinguished road
Default

<a href="<?=$website;?>" alt="" ><?php echo $guestsname; ?></a>

Would work..I believe
TlcAndres is offline  
Reply With Quote
The Following User Says Thank You to TlcAndres For This Useful Post:
StevenF (02-04-2008)
Old 02-04-2008, 05:19 PM   #30 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 81
Thanks: 49
StevenF is on a distinguished road
Default

Quote:
Originally Posted by TlcAndres View Post
<a href="<?=$website;?>" alt="" ><?php echo $guestsname; ?></a>

Would work..I believe
Thank you. When I link that, it's trying to access the page through localhost, which means it's not finding it. Why's it doing that?
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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


All times are GMT. The time now is 03:24 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0