how to pass parameter in wpdb prepare statement
-
Hi,
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.”;$wpdb->query( $wpdb->prepare(
“
INSERT INTO testing
( par1, par2, par3 )
VALUES ( %d, %s, %s )
“,
10,
$p1,
$p2
) );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’];echo $p1;
echo $p2;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.
Thanks,
Isha[No bumping. If it’s that urgent, consider hiring someone.]
- The topic ‘how to pass parameter in wpdb prepare statement’ is closed to new replies.