-1

I'm just trying to get something basic to appear for now and it's not working. It should display 1 on the screen. Is my logic wrong? I paste my statement in console and get 1.

<?php

$sql = mysqli_query("Select moist_measure_avail from sigh_in_account where moist_measure_avail = '1'");

$result = mysqli_fetch_array($sql);

echo $result['moist_measure_avail'];
Cave Johnson
  • 6,499
  • 5
  • 38
  • 57
Cody O'Meara
  • 55
  • 10
  • 1
    `mysqli_query` takes a connection object as its first argument. You should enable error reporting to help with your debugging.https://stackoverflow.com/questions/22662488/how-to-get-mysqli-error-information-in-different-environments – Don't Panic Mar 04 '19 at 18:13
  • Here's a basic example of how to establish a connection and use it in `mysqli_query`: http://php.net/manual/en/mysqli.query.php#refsect1-mysqli.query-examples – Don't Panic Mar 04 '19 at 18:15
  • Possible duplicate of [mysqli\_query() expects parameter 1 to be mysqli,](https://stackoverflow.com/questions/46357905/mysqli-query-expects-parameter-1-to-be-mysqli) – user3783243 Mar 04 '19 at 18:22

2 Answers2

0
$sql = mysqli_query("Select moist_measure_avail from sigh_in_account where moist_measure_avail = '1'");

pass connection as first param in above method. something like this

$sql = mysqli_query($conn,"Select moist_measure_avail from sigh_in_account where moist_measure_avail = '1'");

where $conn is mysql connection

0

First of all you should have to create a connection

<?php
    $conn = mysqli_connect("localhost "," root","","dbname");
?>

And then you have to include the conn variable in your query

$sql = mysqli_query( $conn, " SELECT moist_measure_avail from sigh_in_account WHERE moist_measure_avail = '1'");

The sql statements must be either all caps or all small

Farazzz
  • 145
  • 1
  • 1
  • 10