Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2008, 04:06 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Error with image file upload

I have added the file image upload code while I wait on a response regarding file image upload to database.

Anyway, here is the code I'm using thus far:
PHP Code:
if($_REQUEST['do'] == 'saved')
    {    
    
$upload = new vB_Upload_Image($vbulletin);
    
$upload->image =& vB_Image::fetch_library($vbulletin);
    
$upload->path './'.$options['sponsor_imgpath'];
//    if (!($upload->process_upload($vbulletin->GPC['img_file']))){
//        eval(standard_error(fetch_error('there_were_errors_encountered_with_your_upload_x', $upload->fetch_error())));
//    } 
    
        
$sql "INSERT INTO  `" TABLE_PREFIX "sponsors`
                (`title` , `url` , `image` , `description`, `inactive`, `img_file`) 
                VALUES (
                '" 
$db->escape_string($vbulletin->GPC['title']) . "',
                '" 
$db->escape_string($vbulletin->GPC['url']) . "',
                '" 
$db->escape_string($vbulletin->GPC['image']) . "',
                '" 
$db->escape_string($vbulletin->GPC['description']) . "',
                '" 
$db->escape_string($vbulletin->GPC['inactive']) . "',
                '" 
$upload->process_upload($vbulletin->GPC['img_file'] . "'
                        )"
);

$vbulletin->db->query_write($sql);
print_cp_message('Sponsor Added.''sponsors.php'5);
    } 
EDIT: Fixed previous error, new problem.

When I click submit, I get the following error:
Code:
Database error in vBulletin 3.6.8:

Invalid SQL:
INSERT INTO  `sponsors`
				(`title` , `url` , `image` , `description`, `inactive`, `img_file`) 
				VALUES (
				'Download Now',
				'www.download.com',
				'',
				'blah blah blah again',
				'0',
				';

MySQL Error  : 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 ''' at line 9
Error Number : 1064
Thanks in advance
Steve
Reply With Quote
  #2  
Old 01-24-2008, 05:39 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Missing quote, see below:
Code:
INSERT INTO  `sponsors`
				(`title` , `url` , `image` , `description`, `inactive`, `img_file`) 
				VALUES (
				'Download Now',
				'www.download.com',
				'',
				'blah blah blah again',
				'0',
>>>>>>				';
Reply With Quote
  #3  
Old 01-24-2008, 02:19 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see how I'm missing a quote. Very stange.

--------------- Added [DATE]1201192811[/DATE] at [TIME]1201192811[/TIME] ---------------

Found the problem, had to switch this line:
PHP Code:
'" . $upload->process_upload($vbulletin->GPC['img_file'] . "' 
To this:
PHP Code:
'" . $upload->process_upload($vbulletin->GPC['img_file']) . "' 
--------------- Added [DATE]1201192853[/DATE] at [TIME]1201192853[/TIME] ---------------

Still there is a problem, when it goes to upload, seems it doesn't even try to upload or anything.
Reply With Quote
  #4  
Old 01-24-2008, 02:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may want to double-check your code for the upload path. I don't think you want to say:
$upload->path = './'.$options['sponsor_imgpath'];

I think you need to add something in there:
$upload->path = './'.$vbulletin->options['sponsor_imgpath'];

?? Maybe?

I had to play with upload code for the torrents on my site. I found it very frustrating because the way I did it, it would not spit out errors to me on the screen. I keep thinking I should rewrite it, but I haven't gotten around to it.
Reply With Quote
  #5  
Old 01-24-2008, 07:01 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne, that is incorrect, I have my own settings, I am not using vBulletin's built in settings stuff. I did my own settings table, settings page, etc so its easier for upgrading and uninstalling.

Thats not the problem, not sure what is but I'm gonna have to do the file upload stand alone and go from there.
Reply With Quote
  #6  
Old 01-29-2008, 04:28 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Almost 5 days have passed and not another response. Can anyone help me get this upload stuff to work?
Reply With Quote
  #7  
Old 01-29-2008, 05:11 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
print_r($vbulletin->GPC['img_file']); 
Make sure it actually has data in it.
Reply With Quote
  #8  
Old 01-29-2008, 05:36 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LOL, I should have thought to do that, thats what happens when you have alot on your mind and too tired to think.

--------------- Added [DATE]1201592290[/DATE] at [TIME]1201592290[/TIME] ---------------

Dismounted: This is what print_r outputs:
Code:
Array ( )
--------------- Added [DATE]1201592548[/DATE] at [TIME]1201592548[/TIME] ---------------

BTW, here is the code for my admin page that has the browse file field.

PHP Code:
// Add Sponsor
if ($_REQUEST['do'] == 'add')
{
print_form_header("sponsors""saved""false""true""add_entry""90%""""true""post");
print_table_header("Add Sponsor");
print_input_row("Title""title"$vbulletin->GPC['title'], $htmlise true$size 35$maxlength 100$direction ''$inputclass false);
print_input_row("URL""url"$vbulletin->GPC['url'], $htmlise true$size 35$maxlength 100$direction ''$inputclass false);
print_input_row("Image""image"$vbulletin->GPC['image'], $htmlise true$size 35$maxlength 100$direction ''$inputclass false);
print_input_row("Description""description"$vbulletin->GPC['description'], $htmlise true$size 35$maxlength 100$direction ''$inputclass false);
print_radio_row('Suspended''inactive', array(=> 'No'=> 'Yes'), $vbulletin->GPC['inactive']);
echo 
'<tr><td class="alt2">Image File</td><td class="alt2"><input type="file" name="img_file" /></td></tr>';
print_submit_row("Add Sponsor");
print_table_footer();  
}

if(
$_REQUEST['do'] == 'saved')
    {    
    
$upload = new vB_Upload_Image($vbulletin);
    
$upload->image =& vB_Image::fetch_library($vbulletin);
    
$upload->path './'.$options['sponsor_imgpath'];
//    if (!($upload->process_upload($vbulletin->GPC['img_file']))){
//        eval(standard_error(fetch_error('there_were_errors_encountered_with_your_upload_x', $upload->fetch_error())));
//    } 
  
        
$sql "INSERT INTO  `" TABLE_PREFIX "sponsors`
                (`title` , `url` , `image` , `description`, `inactive`, `img_file`) 
                VALUES (
                '" 
$db->escape_string($vbulletin->GPC['title']) . "',
                '" 
$db->escape_string($vbulletin->GPC['url']) . "',
                '" 
$db->escape_string($vbulletin->GPC['image']) . "',
                '" 
$db->escape_string($vbulletin->GPC['description']) . "',
                '" 
$db->escape_string($vbulletin->GPC['inactive']) . "',
                '" 
$vbulletin->GPC['img_file'] . "'
                        )"
;
print_r($vbulletin->GPC['img_file']);
$vbulletin->db->query_write($sql);
print_cp_message('Sponsor Added.''sponsors.php'5);
    } 
Reply With Quote
  #9  
Old 01-29-2008, 08:18 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it's empty, it means that there's (obviously) no data to insert in the first place. Have you actually cleaned it with the cleaner? Because if you haven't, there's no way it'll magically appear in the GPC array.
Reply With Quote
  #10  
Old 01-29-2008, 01:50 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dismounted: Here is my GPC array.
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
            
'sid'                  => TYPE_INT,
            
'title'                  => TYPE_STR,
            
'url'                  => TYPE_STR,
            
'image'                  => TYPE_STR,
            
'description'          => TYPE_STR,
            
'sclicks'              => TYPE_STR,
            
'inactive'              => TYPE_STR,
            
'img_type'              => TYPE_STR,
            
'img_file'              => TYPE_FILE
        
)); 
As you can see I have img_file in there. So to answer your question, yes I have cleaned it.
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04497 seconds
  • Memory Usage 2,315KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete