Support » Plugins » Hacks » MySQL query returns null when ran from template file

  • Welton122


    Hello all,

    Okay i have a template file which im using for some customer PHP code but for some reason my mysql query keeps returning null where it shouldn’t. Can anyone see why??

    Heres the code?

    // Database variables
    DEFINE ('DB_USER', 'test');
    DEFINE ('DB_PASSWORD', 'test');
    DEFINE ('DB_HOST', 'localhost');
    DEFINE ('DB_NAME', 'testdatabase');
    // Make the connection
    $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error());
    $q = "SELECT * FROM <code>test</code>";
    $result = mysqli_query($dbc, $q);
     echo"No results<br>";
     while ($row = $result->fetch_assoc())
     $test = $row['email'];
     echo"result: $test";

    Are you even able to make mysql querys from templates?


Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    I can’t imagine why you couldn’t do this from a template, but I haven’t done this, so I could be wrong.

    Do you really have a table named “test“? Seems rather unlikely, which would explain why you are not getting anything returned.

Viewing 1 replies (of 1 total)
  • The topic ‘MySQL query returns null when ran from template file’ is closed to new replies.