MySQL based variable coming up as NULL in PHP -
the following code in php file building. building dynamic form show product names , other information in html divs. now, coming problem, think relatively simple. trying echo $name;
coming empty, put in test echo see if perhaps echoing different place had expected, nope, test came right up. so, did var_dump($name);
, came null. define in line before echo it, why coming null?
<?php $productquery = mysqli_query($connection, 'select * products pid="$productid"'); $productrow = mysqli_fetch_assoc($productquery); //$dbidlogin = $row5['id']; ?> <?php $name = $productrow['productname']; echo var_dump($name); echo "<br>why?"; ?>
update:
vardump($productrow['productname']) null.
vardump
ing $productquery
gives this:
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(18) ["lengths"]=> null ["num_rows"]=> int(0) ["type"]=> int(0) }
2nd update:
apparently $productid null. i'm trying set 4. have this, , still doesn't works. i've tried surrounding 4 in quotes, single , double, isn't problem. still says null line after define it.
$productid=4; $productquery = mysqli_query($connection, 'select * products pid="$productid"'); $productrow = mysqli_fetch_assoc($productquery);
$productrow['productname'] null.
figure out query returning vardump/print_r statement $productrow
Comments
Post a Comment