Skip to main content
added 57 characters in body
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

If you need to return one value then use get_var instead of get_row. get_var will return a string. get_row will return an array or object.

$spr_liczbe_wodo = $wpdb->get_var ("select liczba_wodo from wp_ow_adres where adres='Street 12/6'");
var_dump($spr_liczbe_wodo);

The problem with your code, by the way, is that $spr_liczbe_wodo is an object, but when you loop over it $print is not but you attempt to use it as if it were an object anyway. Through in a couple of var_dumps and you can easily see the problem.

If you need to return one value then use get_var instead of get_row. get_var will return a string. get_row will return an array or object.

$spr_liczbe_wodo = $wpdb->get_var ("select liczba_wodo from wp_ow_adres where adres='Street 12/6'");
var_dump($spr_liczbe_wodo);

The problem with your code, by the way, is that $spr_liczbe_wodo is an object, but when you loop over it $print is not. Through in a couple of var_dumps and you can easily see the problem.

If you need to return one value then use get_var instead of get_row. get_var will return a string. get_row will return an array or object.

$spr_liczbe_wodo = $wpdb->get_var ("select liczba_wodo from wp_ow_adres where adres='Street 12/6'");
var_dump($spr_liczbe_wodo);

The problem with your code, by the way, is that $spr_liczbe_wodo is an object, but when you loop over it $print is not but you attempt to use it as if it were an object anyway. Through in a couple of var_dumps and you can easily see the problem.

Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

If you need to return one value then use get_var instead of get_row. get_var will return a string. get_row will return an array or object.

$spr_liczbe_wodo = $wpdb->get_var ("select liczba_wodo from wp_ow_adres where adres='Street 12/6'");
var_dump($spr_liczbe_wodo);

The problem with your code, by the way, is that $spr_liczbe_wodo is an object, but when you loop over it $print is not. Through in a couple of var_dumps and you can easily see the problem.