Can't figure out MySQL query for contact form
-
I am working on making a WordPress version of a contact form submit script that I wrote in plain PHP a while back. I am having a ton of trouble trying to figure out how to get a workable MySQL query going.
-I already set up the table through phpMyAdmin and made sure my table had the standard wp_ prefix, so I know it is not the problem.
-Here is my database include (I made it a require so it would error out if I didn’t do something right):
require('../../../wp-includes/wp-db.php');
Here is my query script. It is written pretty much in accordance with http://codex.wordpress.org/Class_Reference/wpdb:
$wpdb->query( "INSERT INTO $wpdb->NEW_CONTACTS (SUBMIT_DATE, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, COMMENTS) VALUES ('$date','$firstName','$lastName','$email','$phone','$comments')" );
When I try executing the script, I get this error message which directly corresponds to my query line:
Fatal error: Call to a member function query() on a non-object in /home/content/17/7848217/html/wordpress/wp-content/plugins/submitForm/index.php on line 44If anybody can give a second pair of eyes to this, I would greatly appreciate it. FYI, I am only interested in using the
$wpdb->query
method, not the$wpdb->insert
one. Also, the MySQL escapes will come after I figure out the problem with the query.
- The topic ‘Can't figure out MySQL query for contact form’ is closed to new replies.