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
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-16-2008, 02:48 PM   #1 (permalink)
The Wanderer
 
Join Date: Oct 2008
Posts: 14
Thanks: 0
Lou_Gato is on a distinguished road
Default I need a little help with updating to a database record

I have tried to update data and for the most part it works, number one it can only be text no punctuation what so ever, if an apostrophe is used for example (i'm go) this is the error that is given

" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm go' at line 1"


and the second is that the page refresh causes it to re-update and blank out the database

how would i fix that?

please help it is driving me nuts..
thanks
Lou_Gato is offline  
Reply With Quote
Old 10-16-2008, 03:05 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

For the escaping of characters which conflict with MySQL, take a peak at the following two functions on PHP.net. They will help you very much in preventing those pesky errors:

As for the problem of reposting POST data, take a look at the following example I have created for you. This, I hope, explains it better than any number of words could! Please do ask any questions though if you're unsure.
Attached Files
File Type: php Post-Refresh.php (576 Bytes, 153 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-16-2008, 03:27 PM   #3 (permalink)
The Wanderer
 
Join Date: Oct 2008
Posts: 14
Thanks: 0
Lou_Gato is on a distinguished road
Default thanks for the fast response.. I am not sure i did it right.

edit_blurb.php

i have attached a copy of my code. dont laugh at my attempt..I have done enough of that for the both of us!!! j/k

but in all seriousness I am still unsure of it.. sorry I am really uneducated in php. the little i know is because of HAVING to trial and error it out.. lol

thanks again
Lou_Gato is offline  
Reply With Quote
Old 10-16-2008, 03:36 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I will assume you've got the session booleans (true and false) in the correct order. I have amended your code. Please try it now.
Attached Files
File Type: php Blurb.php (2.8 KB, 165 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-16-2008, 03:44 PM   #5 (permalink)
The Wanderer
 
Join Date: Oct 2008
Posts: 14
Thanks: 0
Lou_Gato is on a distinguished road
Default

now it wont post..lol.. this is too funny.. I appreciate it
Lou_Gato is offline  
Reply With Quote
Old 10-16-2008, 05:36 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I assume then that you have the booleans configured incorrectly. Basically the SESSION variable must be true to POST, and false once submitted. The value is returned to true again once you reload the actual form and then resubmit.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-16-2008, 06:21 PM   #7 (permalink)
The Wanderer
 
Join Date: Oct 2008
Posts: 14
Thanks: 0
Lou_Gato is on a distinguished road
Default

I am not sure that I understand what you mean.. I am truly sorry.. I copied it as you wrote it... and i dont get it posted.. maybe i am doing something wrong?!?!?
Lou_Gato is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 10:59 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design