NukeXchange Network

          

Nuke Sites Link Directory
Nuke Fixes · NukeForums · NukeZone Hosting · NukeUnited · Nuke Sites · Nuke Skins · NukeLance
Nuke Resources
 :: Home  :: Downloads  :: Your Account  :: Forums  :: Advertise :: 
Login or Register
Main Menu
General
 Main
 AvantGo
 Banner_Clients
 cfaq
 Donations
 Downloads
 Forums
 Members_List
 Private_Messages
 Search
 Stories_Archive
 Submit_News
 Surveys
 Topics
 Web_Links
 Your_Account

Your Account
 Login
 Register
 Lost Pass

Modules
Quick Links
· CMS Focus
· Domain Names
. Game Quest
· Learning Linux
. MateMaker
· NukeFixes
· NukeForums
· NukeLance
· Nuke Sites
· Nuke Skins
· NukeZone Hosting
. SearchDevil
Other Options

Download Resources
· Nuke Downloads
· Add a Link
· New Files
· Top Rated
· Most Popular

Web Site Resources
· Nuke Sites
· Add A Site
· New Sites
· Top Rated
· Most Popular

Support
· NukeZone Hosting
· NukeSkins.com
· NukeForums.com
· phpnuke.org
· NukeFixes.com
Information
NukeForums
·decompressing EN-Book-Nuke.tar.tar
·How to allow spaces/gaps/"-" in allowed usernames
·How to Setup PHPNUKE on win2k
·cannot save changes
·voting?
·Nuke forum picture problem
·How to change smtp port on wampserver and windows
·yet another 301 redirect problem
·Image display? - newbie
·php nuke help

read more...
Top10 Links
· 1: Nuke Forums
· 2: PHPNukeFiles
· 3: NukeSkins
· 4: Nuke Templates
· 5: EcomJunk
· 6: MDesign
· 7: Windows Installation: PHP
· 8: FLASH-FOR-NUKE
· 9: Dezina
· 10: Global Dream News Sharing Portal!
Site Visitors
User Login:

Nickname:
Password:
Security Code: Security Code
Type Security Code Here:

Members List Membership:
Latest: qwertz
Today: 0
Yesterday: 1
Overall: 15102

Visitation:
Guests: 587
Members: 0
Total: 587


You are Anonymous user. You can register for free by clicking here
Sponsor Links
Game Quest Online - Games and more!
Game Quest Online - Games and more!

NukeResources :: View topic - [BBtoNuke] SQL syntax error using single quotes [SOLVED]
NukeResources Forum Index

NukeResources Forum Index -> Bug Reports -> [BBtoNuke] SQL syntax error using single quotes [SOLVED]
Post new topic  Reply to topic    View previous topic :: View next topic 
[BBtoNuke] SQL syntax error using single quotes [SOLVED]
PostPosted: Tue Jan 03, 2006 7:21 pm Reply with quote
Assgier
Resource Seeker
Resource Seeker
 
Joined: Jan 03, 2006
Posts: 10




Hello...

I'm currently experiëncing a very annoying problem; when someone tries to make a post on the forum with a ' (single quote) in it, an SQL syntax error appears. Posting double quote (") or `-characters works fine however...
This problem, which i think is a bug, is reproducable by trying to post something on the BBtoNuke board with a ' in it.
It also happens when trying to create a new topic with a ' in it's subject Sad

I've been searching the world for a fix or even an existing forum topic about it on various phpnuke support sites (phpnuke.org itself, nukecops and this site ofcourse) but until now it seems no one running a phpnuke site ever uses single quotes on it's forum Wink

The problem appeared after upgrading to PHPNuke 7.9 with patch 3.1 about a week ago.

Here's an example of the SQL syntax error:

Code:

DEBUG MODE

SQL Error : 1064 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 ''this is a test topic '')' at line 1

INSERT INTO nuke_bbposts_text (post_id, post_subject, bbcode_uid, post_text) VALUES ('525', 'test topic', '8e705b514c', 'this is a test topic '')

Line : 284
File : functions_post.php


The responsible piece from functions_post.php (for the PHP/SQL coders here):

Code:

$sql = ($mode != 'editpost') ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ('$post_id', '$post_subject', '$bbcode_uid', '$post_message')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '$post_message',  bbcode_uid = '$bbcode_uid', post_subject = '$post_subject' WHERE post_id = '$post_id'";
if (!$db->sql_query($sql))
{
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}

There's ofcourse some logic about why the syntax error appears, because the $post_subject variable is enclosed in 2 single quotes, so when there's another one in $post_subject itself, it will get confused...

The question is; how can it be solved? Is there an existing fix or is there something i can edit the functions_post.php file with?

Thanks in advance Smile

PHPNuke 7.9 with patch 3.1
BBtoNuke 2.0.19 (upgraded, but it didn't solve the problem)
See my signature for environment information.


Last edited by Assgier on Thu Jan 05, 2006 9:33 pm; edited 1 time in total

_________________
FreeBSD 6.0-RELEASE
Apache 2.0.55
PHP 4.4.1
MySQL 4.1.11
View user's profile Send private message
PostPosted: Thu Jan 05, 2006 9:31 pm Reply with quote
Assgier
Resource Seeker
Resource Seeker
 
Joined: Jan 03, 2006
Posts: 10




After few days without any replies, i decided to jump into it one last time myself and started searching for using single quotes in PHP scripts, inserting data into SQL tables...

After some time i found out about the PHP function addslashes(), which automatically detects any characters like the single quote that can possible be recognised by, for example, MySQL as a char with a purpose. When detected, it puts an escape sign (\) in front of it and continues parsing...

So when browsing the function_post.php code, i found out that the creators of phpBB have decided not to use that function and leave it to PHP itself...
Then i struggled upon the MAGIC_QUOTES_GPC feature of PHP. Since i'm using a pretty much default php.ini-recommended file for my configuration, the MAGIC_QUOTES_GPC function was disabled (the PHP founders say that it's better for performance if PHP scripts use the addslashes() and stripslashes() functions instead of depending on MAGIC_QUOTES_GPC).

I enabled MAGIC_QUOTES_GPC and all of a sudden the problem was solved..
Perhaps it would be an idea for the nukeresources.com guys to include pieces code like beneath in their BBtoNuke port Smile

Code:

if (!get_magic_quotes_gpc()) {
  $post_subject = addslashes($post_subject);
}

source: Daniel of phpfreakz.nl (Dutch)


Last edited by Assgier on Thu Jan 05, 2006 10:33 pm; edited 2 times in total
View user's profile Send private message
PostPosted: Thu Jan 05, 2006 10:22 pm Reply with quote
Evaders99
Resource Master
Resource Master
 
Joined: May 25, 2004
Posts: 1785




Interesting - good to know

_________________
- Star Wars Rebellion Network - Evaders Squadron Coding -

Need help? Nuke Patched Core, Coding Services, Webmaster Services
View user's profile Send private message Visit poster's website AIM Address
[BBtoNuke] SQL syntax error using single quotes [SOLVED]
 NukeResources Forum Index -> Bug Reports
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 4 Hours  
Page 1 of 1  

  
  
 Post new topic  Reply to topic     



Powered by phpBB © 2001-2005 phpBB Group.     Theme created by Vjacheslav Trushkin.
There have been 138 unique hit(s) in the past 24 hours.
Forums ©
Nuke Sites Link Directory


Best viewed with a Browser
All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2001 - 2007 by NukeResources.com
You can syndicate our news using the file .backend.php or ultramode.txt
PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.28 Seconds

:: Eos phpbb2 style by Cyberalien :: PHP-Nuke theme by www.nukemods.com ::