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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2007, 03:31 PM
Guest210212002
Guest
 
Posts: n/a
Default Basic SQL query question

I realize this is really basic, I'm learning as I go.

I'm trying to make a simple page to add data to a database. The database is named 'php', and I have a table with: id (int, auto increment) and text fields named lastname, firstname, org, cdate and notes.

My form input is a quick table, the inputs look like this:

Code:
<td width="100">Lastname</td>
<td><input name="lastname" type="text" id="lastname"></td>
So I assume that's posting "lastname".

I've defined these variables to grab the post data:

Code:
$lastname = $_POST['lastname'];
$firstname = $_POST['firstname'];
$org = $_POST['org'];
$cdate = $_POST['cdate'];
$notes = $_POST['notes'];
And here's my query:

Code:
// Add the info
$query = "INSERT INTO users (lastname, firstname, org, cdate, notes) VALUES ('$lastname', '$firstname', '$org', '$cdate', '$notes')";
mysql_query($query) or die('Error, insert query failed');
Which as you can guess, doesn't work. I'm reading and googling, but right now I'm kind of stuck at this point and not sure what I'm missing. If anyone could enlighten me, I'd really appreciate it.
Reply With Quote
  #2  
Old 04-29-2007, 03:41 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Replace the query line with this to see the error being generated:
Code:
mysql_query($query) or die(mysql_error());
Also, it is generally not a good idea to insert GPC data directly. See example 1396 on this page for how to escape data.
Reply With Quote
  #3  
Old 04-29-2007, 03:49 PM
Guest210212002
Guest
 
Posts: n/a
Default

Aah, thanks.

Quote:
Access denied; you need the RELOAD privilege for this operation
That's the error I get with the actual output string. I'll definitely check that page out, right now I'm just trying to get the hang of things.

Edit: Woohoo! I got it!

That error is because I'm going by the O'Reilly book and was flushing privelages after the submit. Honestly I don't even know what it does (hehehe) so I dumped it and it works now.

Thank you very much!
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 04:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04050 seconds
  • Memory Usage 2,171KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (1)postbit_onlinestatus
  • (3)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
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_imicons
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete