0

I am trying to use the mysqli prepare and bind_param but it is not working. The bind_param function is not doing anything, not returning any error, and pauses execution of the rest of my codes. My codes are as follows:

$set = mysqli_fetch_array($sett);
$vxemail = $_SESSION['email'];
$profv = $flash->prepare("SELECT * FROM `user` WHERE `email`=:em");
$profv->bind_param(':em',$vxemail);
Dharman
  • 30,962
  • 25
  • 85
  • 135
Kayode
  • 1
  • 1

2 Answers2

1

If you need named query parameters like :em then you should use PDO, not mysqli.

PDO supports both named parameter placeholders and positional parameter placeholders. This is handy because some databases like Oracle normally support only named placeholders, while MySQL supports only positional placeholders. PDO translates one style to the other transparently, so you can use both.

(Just don't mix different types of placeholders in the same query. Choose one style or the other.)

I prefer PDO for reasons like this. It has a lot of nice features that make it better than Mysqli.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
0

use this code

$set = mysqli_fetch_array($sett);
$vxemail = $_SESSION['email'];
$profv = $flash->prepare("SELECT * FROM user WHERE email=?");
$profv->bind_param('s', $vxemail);

bind_param accepts the first parameter type, and then the transmitted data. for example:

$profv->bind_param('ssid', $name, $lastname, $age, $amount);

s = string, i = integer, d = double

Kongulov
  • 1,156
  • 2
  • 9
  • 19
  • Pls do consider of explaining your code and how it would help, so that others can be benefited from this. – Amit Verma Jul 12 '20 at 09:31
  • Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others. – UkFLSUI Jul 12 '20 at 12:48