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 07-12-2005, 02:18 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Stuck on an INSERT..

I feel really dumb for asking this.

I'm still fairly new to coding in PHP so I'm a little confused here: Simply put, I'm trying to insert data into a table from a simple form but I can't get it to work. I've tried everything I can think of and I still don't understand.. Can anyone see an obvious error in the code?

Also, when sending the form an error popup tells me the following: (even when linking to member.php?u=$userinfo[userid])
Quote:
This user has not registered and therefore does not have a profile to view.
PHP Code:
if ($_POST['do'] == 'insertnewcomment') {
    
globalize($_POST, array('comment' => INT,'title' => STR_NOHTML));
    
    
$DB_site->query("
    INSERT INTO "
.TABLE_PREFIX."usercomment (userid,postedbyid,comment,title,dateline) 
    VALUES ("
.$userinfo[userid].",".$bbuserinfo[userid].",".mysql_escape_string($comment)."',".mysql_escape_string($title)."',".TIMENOW."')");

    
$url "member.php?$session[sessionurl]u=$userinfo[userid]";
    eval(
print_standard_redirect('redirect_postthanks'));


HTML Code:
<form action="member.php" method="post">
	<input type="hidden" name="do" value="insertnewcomment" />
	<input type="hidden" name="userid" />
	<input type="hidden" name="postedbyid" />
	<input type="hidden" name="s" value="$session[sessionhash]" />
	<input class="bginput" type="text" name="title" size="45" maxlength="80" /><br />
	<input class="bginput" type="text" name="comment" size="45" maxlength="80" /><br />
		<input type="submit" class="button" value="Submit" accesskey="s" />
		</form>
Thanks,
Reply With Quote
  #2  
Old 07-12-2005, 03:54 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
 $DB_site->query(
INSERT INTO "
.TABLE_PREFIX."usercomment (userid,postedbyid,comment,title,dateline) 
VALUES (
$userinfo[userid],$bbuserinfo[userid],'".mysql_escape_string($comment)."','".mysql_escape_string($title)."',TIMENOW)"); 
Change line to the above.

Also you are globalizing $comment as an integer, but i think you want it to be text. So either change the globalize to STR, or remove the quotes and the mysql_escape_string.
Reply With Quote
  #3  
Old 07-12-2005, 04:04 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm. Thanks Marco.

I changed the line, and added "STR" instead of "INT" but I still can't seem to get it to enter into the database. Perhaps it has something to do with this?

Quote:
Also, when sending the form an error popup tells me the following: (even when linking to member.php?u=$userinfo[userid])
"This user has not registered and therefore does not have a profile to view."
Which I'm also completely stuck on.. haha, I'm getting the hang of it though!
Thanks for your help.
Reply With Quote
  #4  
Old 07-12-2005, 04:22 AM
Guest190829
Guest
 
Posts: n/a
Default

Are you using 3.5.0? I'm editing member.php(For 3.0.7) ATM too, and I used $userid to get the userid of the member's profile currently been viewed, and it worked.
Reply With Quote
  #5  
Old 07-12-2005, 04:45 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope, 3.0.7

Sorry, I should have specified that before.

Are you meaning:
HTML Code:
<form action="member.php?u=$userid" method="post">
It's linking to the correct user id, but it's giving me the error message that you receive if putting in a non-existing userid. If that makes sense?

I'll post a screen:
It's giving me the error message, but the user id clearly does exist.. just kind of weird.
Attached Images
File Type: jpg ar2.jpg (27.9 KB, 0 views)
Reply With Quote
  #6  
Old 07-12-2005, 04:49 AM
Guest190829
Guest
 
Posts: n/a
Default

When you go to http://www.yoursite.com/member.php?u=1, does that bring you to a profile? Or do you get the same error message?
Reply With Quote
  #7  
Old 07-12-2005, 04:53 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When I go directly there it gives me the profile. What's weird is when I have that error message, I click "Go" in the browser and it loads the profile just fine.
Reply With Quote
  #8  
Old 07-12-2005, 04:54 AM
Guest190829
Guest
 
Posts: n/a
Default

Oh and to get the query to run try

PHP Code:
<form action="member.php?u=$userid&do=insertnewcomment" method="post"
That may be what's causing the query not to run, although not sure about a the error.
Reply With Quote
  #9  
Old 07-12-2005, 05:02 AM
KTBleeding's Avatar
KTBleeding KTBleeding is offline
 
Join Date: Feb 2004
Location: Tooele, UT
Posts: 756
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dang, no deal. Still doesn't enter into the database, and still getting this strange redirect error. Thanks for the help though guys, I'm not sure if I'd have any hair left if I didn't get help on some things.
Reply With Quote
  #10  
Old 07-12-2005, 06:03 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm i am no HTML guru, but i don't think you can pass variables with the 'form action=...'.

You should use a hidden input field to pass those variables.
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 10:09 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.05412 seconds
  • Memory Usage 2,282KB
  • Queries Executed 12 (?)
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
  • (2)bbcode_html
  • (3)bbcode_php
  • (2)bbcode_quote
  • (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
  • (1)postbit_attachment
  • (7)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_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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete