0
$mysqli = new mysqli("localhost", $musername, $mpass, $mdatabase);
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}
$sqquer = $mysqli->prepare('SELECT * FROM ? where id=?');
$sqquer->bind_param('is', $mtable, $_SESSION['User']['id']);
if ($sqquer==false) {
  echo "fail";
}
echo "<br>Test 2";
$sqquer->execute();
echo "<br>Test 3";
$sqquer->store_result();

This outputs none of the tests. What am I missing? I have tried changing the param function but no success, I am sure I am missing something trivial.

user2498443
  • 143
  • 6
  • is your table name is of interger type – Afsar Jun 26 '13 at 23:10
  • Are you actually defining $musername, $mpass, $mdatabase anywhere? – Kylie Jun 26 '13 at 23:10
  • 1
    What do you get if you add `error_reporting(E_ALL | E_STRICT);` to the top of your script? – Jon Jun 26 '13 at 23:12
  • 3
    Simple, table names cant be prepared. http://stackoverflow.com/questions/11312737/can-i-parameterize-the-table-name-in-a-prepared-statement, also is your table name an integer? – Lawrence Cherone Jun 26 '13 at 23:12
  • l̕aͨŵƦȆ̴̟̟͙̞ͩ͌͝ƞCͭ̏ȇ ƇhƐȓ0nè answered the question, Thanks everyone! – user2498443 Jun 27 '13 at 00:01
  • Check if you mysqli extension is loaded in php.ini. If its not, enable it. Also make sure error reporting is enabled so that you see errors. – raj Jun 26 '13 at 23:11

1 Answers1

1

Are you sure mysqli is enabled?

Check php.ini and uncomment (ie remove ;) this line....

;mysqli.dll

To...

mysqli.dll   (mysqli.so on linux)
Kylie
  • 11,421
  • 11
  • 47
  • 78