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 01-03-2010, 01:34 AM   #1 (permalink)
The Contributor
 
Join Date: Feb 2007
Posts: 64
Thanks: 9
Killswitch is on a distinguished road
Default Having trouble with PDO

I am having a bit of trouble with an SQL statement and really don't know why.

Basically I am updating a forums information in the database. Everything is fine until I use certain characters.

For whatever reason, I can use moderators and administrators, but not moderators and administrators ONLY. Trespassers will be violated.

If it manages to update, the ONLY part of that string and on turns into >, so it reads moderators and administrators >.

Before going into the database I am using trim(htmlspecialchars($form_data, ENT_QUOTES)) and using them in a prepared query. I really don't understand what could be causing this and never ran into this problem before.

If it helps, the field this is getting inserted into is called desc (which I had probs with before, had to use `desc` to get it to work) which is just a text type field in mysql.
Killswitch is offline  
Reply With Quote
Old 01-03-2010, 02:22 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Code please? Preeettttty please? (Is this long enough vBulletin? huh? HUHHH?)
delayedinsanity is offline  
Reply With Quote
Old 01-03-2010, 02:54 AM   #3 (permalink)
The Contributor
 
Join Date: Feb 2007
Posts: 64
Thanks: 9
Killswitch is on a distinguished road
Default

Alright, this is the portion that is Updating, with a little bit of cleaning ( its for an admin area that honestly I will be the only one messing with ). Also note the $form_data is an array of the form fields via Xajax... so $form_data['title'] really is input name=title etc...

PHP Code:
// Setup and preclean some vars
            
$title trim(htmlspecialchars($form_data['title']));
            
$url $this->string_to_url($form_data['url']);
            
$parent = (int)$form_data['parent'];
            
$access serialize($form_data['access']);
            
$post_access serialize($form_data['post_access']);
            
$desc trim(htmlspecialchars($form_data['desc'], ENT_QUOTES));
            
            
// Attempt to insert data
            
$q $this->db->prepare("UPDATE forums SET `title` = ?, `url` = ?, `parent` = ?, `access` = ?, `post_access` = ?, `desc` = ? WHERE id = ?");
            
                
$q->bindParam(1$title);
                
$q->bindParam(2$url);
                
$q->bindParam(3$parentPDO::PARAM_INT);
                
$q->bindParam(4$access);
                
$q->bindParam(5$post_access);
                
$q->bindParam(6$desc);
                
$q->bindParam(7$idPDO::PARAM_INT);
                
            
// Check results
            
if ( ! $q->execute() OR ! $q->rowCount() > 0)
            {
                
$message '<div class="error"><p>Sorry, but we could not update this forum</p></div>';
            } 
Essentially (since some code was left out), if it couldnt process or no effected results, then I return the Sorry message, otherwise it tells me everything went fine, let me send you to this location now.

I just can't pinpoint what would cause this, as it seems either the ! or . , ' is causing it (well ' is out now due to ENT_QUOTES).

UPDATE - Problem not solved, but it seems to be the word 'only' screwing everything up. I have tried removing this word and it works correctly, but when I use 'only' in it it wont work.

Last edited by codefreek : 01-03-2010 at 03:05 PM. Reason: PHP tags added, Please Use The Right tags. Thank you.
Killswitch 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble!!! KingOfTheSouth General 13 02-06-2009 01:17 AM
Having trouble with md5() code_junkie Advanced PHP Programming 7 02-05-2009 06:41 PM
having trouble updating with mysql sarmenhb Absolute Beginners 7 11-18-2008 07:49 AM
Having trouble learning MySQL database codes... Aaron Absolute Beginners 24 05-08-2008 07:11 PM
Having trouble with Custom Function "isImage" Orc General 4 12-30-2007 12:19 AM


All times are GMT. The time now is 02:39 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