I am trying to insert some data in my custom tables in wordpress database, for which I am using $wpdb object, and its implicit functions, e.g.:
$p1 = “Harriet’s Adages”;
$p2 = “WordPress’ database interface is like Sunday Morning: Easy.”;
INSERT INTO testing
( par1, par2, par3 )
VALUES ( %d, %s, %s )
The above code is working fine. However, when I am assigning the parameter p1, and p2 values from a form fields, it is inserting blank values in db.
for following code:
$p1 = $_POST[‘FirstName’];
$p2 = $_POST[‘LastName’];
The above code prints the correct value, that I entered in html textboxes, but when I pass the same paramters in insert query as stated above, it passes the blank values for string, and 0 for integer. Please suggest, what might be the problem. I am new to wordpress.
- The topic ‘how to pass parameter in wpdb prepare statement’ is closed to new replies.