Reputation: 159
When I use this, it works well and I have no problem:
$user = $_POST['uusername'];
$result=$wpdb->get_results("SELECT * FROM Materials");
foreach($result as $print)
{ echo '<pre>',print_r($print->id_customer,1),'</pre>'; }
$wpdb->print_error();
But when I try to fetch a user, it doesn't work and the worst is that I don't even get an error message:
$user = $_POST['uusername'];
$result=$wpdb->get_results("SELECT * FROM Materials WHERE mtrname=$user");
Is there any error whith this SELECT?
Upvotes: 1
Views: 337
Reputation: 9476
If you post value is string pass single quote:
$result=$wpdb->get_results("SELECT * FROM Materials WHERE mtrname='$user' ");
Upvotes: 1