0

So I had my website working but the hoster forced me to migrate, so I had to backup all I had and change it to the new host. The code was working but since I changed I cant get this code working. The connection to the database seems fine.

  • The code had to be changed from mysql to mysqli

  • All I get from mysqli_num_rows or mysqli_query is blank.

  • I checked the encoding and its UTF-8.

  • The query works fine on phpmyadmin

Since I only have ftp access to the publish folder Im not sure what options i have to find the problem.

$link = mysqli_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later." . mysqli_connect_error());
    mysqli_set_charset($link, "utf8");
    mysqli_select_db($dbname, $link);

    $result = mysqli_query($link, "SELECT * FROM $usertable ORDER BY Date DESC");

    //echo "result:" . $result;  returns blank
    echo "results:" . mysqli_num_rows($result);  returns blank
João Serra
  • 379
  • 1
  • 5
  • 20
  • `$usertable` is? and your quotes around the column; remove them. Not the right identifier qualifiers. – Funk Forty Niner May 31 '17 at 16:41
  • Enable error-reporting and check your logs. You have wrong quotes around your `date` too, should be backticks (or none at all). And make sure the query actually executes, what does `var_dump($result)` output? – Qirel May 31 '17 at 16:41
  • `mysqli_error($link)` would have most likely avoided the question, by you Googling that error. – Funk Forty Niner May 31 '17 at 16:42
  • and these `mysqli_select_db($dbname, $link);` need to be inverted. – Funk Forty Niner May 31 '17 at 16:43
  • Fred -ii- that seemed to be the issue (mysqli_select_db($dbname, $link); need to be inverted.) you wont believe how much time i lost searching for it – João Serra May 31 '17 at 16:49
  • I really like how duplicates *etc*. can now reference more than one original link. – Martin May 31 '17 at 16:51

0 Answers0