Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

Using “->” in a page to exceute $wpdb query gives error

$
0
0

I am doing some SQL queries in a WordPress page using the Insert PHP plugin,
but the -> object operator changes to -> when I write code in the Text editor, or view in the Visual editor. When I execute the code it says:

Parse error: syntax error, unexpected ‘&’ in
/home/content/p3pnexwpnas09_data03/81/2766081/html/wp-content/plugins/insert-php/insert_php.php(48)
: eval()’d code on line 9

[insert_php]
    if ( isset( $_POST['submit'] ) ) {
        global $wptd;
        $n1 = $_POST['n1'];
        $n2 = $_POST['n2'];
        $n3 = $_POST['n3'];
        $n4 = $_POST['n4'];
        $wpdb->query( prepare( 
            "INSERT INTO $wpdb->communitycauses (des,city,state,date)
                VALUES (%d,%s,%s)",
            array ( 
                $n1, 
                $n2, 
                $n3, 
                $n4 
            ) 
        ) ); 
    } else {
        echo "Enter the cause Please";
    }
[/insert_php]

Viewing all articles
Browse latest Browse all 44

Trending Articles