sql - PHP script returns no result -


i have script try date database.

the script needs show: date in database (date). click here continue. when run sql query in phpmyadmin, sql query returns date. when run in script no result.

here script:

<?php  $servername = "localhost";  $username = "root";  $password = "";  $dbname = "db";   // create connection  $conn = new mysqli($servername, $username, $password, $dbname);  // check connection  if ($conn->connect_error) {   die("connection failed: " . $conn->connect_error);  }    $sql = "set lc_time_names = 'nl_nl';";  $sql = "select date_format(date, '%e %m %y') date table id='1'";  $result = $conn->multi_query($sql);   if ($result->num_rows > 0) {   // output data of each row   while($row = $result->fetch_assoc()) {    echo "the date in database is:";    echo " " . $row['date'] . ". ";    echo "click here continue.";    }   } else {    echo "0";   } ?> 

when run script 0. when change echo "0"; echo " " . $row['date'] . ". "; empty page.

what doing wrong? how can fix this?

i had edit isn't approved...does work?

just splitting queries/variables 2 separate ones--only worry first value may not persist you.

like so:

 <?php  $servername = "localhost";  $username = "root";  $password = "";  $dbname = "db";   // create connection   $conn = new mysqli($servername, $username, $password, $dbname);  // check connection   if ($conn->connect_error) {   die("connection failed: " . $conn->connect_error);  }    $sql = "set lc_time_names = 'nl_nl'"; $sql2 = "select date_format(date, '%e %m %y') date table            id='1'";  $resultz = $conn->query($sql);  $result = $conn->query($sql2);  if ($result->num_rows > 0) {   // output data of each row   while($row = $result->fetch_assoc()) {    echo "the date in database is:";     echo " " . $row['date'] . ". ";     echo "click here continue.";    }    } else {     echo "0";    }     ?> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -