FAP SUPPORT - "Could Not Insert New Entry"


Subject: FAP SUPPORT - "Could Not Insert New Entry"
Whenever I try to upload a picture, I always seem to get this:

Could not insert new entry

"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 's DAVID!', '2', '45e10284', 'David', '1169754455', '1', '1')' a

INSERT INTO phpbb_album (pic_filename, pic_thumbnail, pic_title, pic_desc, pic_user_id, pic_user_ip, pic_username, pic_time, pic_cat_id, pic_approval) VALUES ('943e2f670438d699ac704c819ab073c0.jpg', '943e2f670438d699ac704c819ab073c0.jpg', 'A Photo Of Me.', 'It's DAVID!', '2', '45e10284', 'David', '1169754455', '1', '1')

Line : 1204
File : album_upload.php"



Any suggestions on what to do? I'm using PHPBB 2.0.22

Any help is greatly appriciated!

David.

Subject: Re: "Could Not Insert New Entry"
Ok. Now, I'm not completely sure if this will TOTALLY solve my problem, but I deleted the .htaccess files in album_mod/upload and all of it's subfolders. I went back to my album, and tried to upload the picture and it worked fine. However, I had this problem yesterday, and I just reset all my settings under Config in the Admin panel, and things started working, but today it messed up again. I'm seeing if this works. We'll see.

I reply with any updates.

Subject: Re: "Could Not Insert New Entry"
Hi, I think this problem is rather related to using apostrophe's in the title and not htaccess.

The fix for this is below:

Code: [Download] [Hide]
  1.  
  2. open album_upload.php  
  3.  
  4. FIND  
  5. $pic_title = str_replace("'", "''", htmlspecialchars(trim($_POST['pic_title'])));  
  6.  
  7. $pic_desc = str_replace("'", "''", htmlspecialchars(substr(trim($_POST['pic_desc']), 0, album_config['desc_length'])));  
  8.  
  9. $pic_username = (!$userdata['session_logged_in']) ? substr(str_replace("'", "''", htmlspecialchars(trim($_POST['pic_username']))), 0, 32) : str_replace("'", "''", $userdata['username']);  
  10.  
  11.  
  12. REPLACE WITH:  
  13.  
  14. $pic_title = addslashes(str_replace("'", "''", htmlspecialchars(trim($_POST['pic_title']))));  
  15.  
  16. $pic_desc = addslashes(str_replace("'", "''", htmlspecialchars(substr(trim($_POST['pic_desc']), 0, $album_config['desc_length']))));  
  17.  
  18. $pic_username = (!$userdata['session_logged_in']) ? addslashes(substr(str_replace("'", "''", htmlspecialchars(trim($_POST['pic_username']))), 0, 32)) addslashes(str_replace("'", "''", $userdata['username'])); 



SOURCE:
Quote:
-----------------------------------
Mighty Gorgon
Sun 24 Dec, 2006 00:25

Re: Fix For Problem With Apostrophe's In Description
-----------------------------------
You should not change that replacement, because is needed to correctly parse text in POST fields.

Use ADDSLASHES in front of it instead.

Code: [Download] [Hide]
  1. $pic_title = addslashes(str_replace("'", "''", htmlspecialchars(trim($_POST['pic_title']))));  
  2.  
  3. $pic_desc = addslashes(str_replace("'", "''", htmlspecialchars(substr(trim($_POST['pic_desc']), 0, $album_config['desc_length']))));  
  4.  
  5. $pic_username = (!$userdata['session_logged_in']) ? addslashes(substr(str_replace("'", "''", htmlspecialchars(trim($_POST['pic_username']))), 0, 32)) addslashes(str_replace("'", "''", $userdata['username'])); 


This should do the trick.

Let me know.



Profile PM  
Subject: Re: "Could Not Insert New Entry"
lefty74 is correct, applying the fix above should fix the problem for you.
Others should apply the fix, but if you are not having an error with apostrophe in title/description etc it is not absolutely necessary.

Profile PM  

Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.2279s (PHP: 11% SQL: 89%)
SQL queries: 10 - Debug Off - GZIP Enabled