1
$result = mysqli_query("query") or die('Cannot get product. ' . mysqli_error());
$row = mysqli_fetch_assoc($result);

I'm making a simple bank app in php, the database connects but I get the following errors on a particular page

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/np9saef160p0/public_html/mybank/admin/account/detail.php on line 19

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/np9saef160p0/public_html/mybank/admin/account/detail.php on line 19 Cannot get product.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    We need to see that line 19! – Hamza Abdaoui Mar 07 '18 at 13:36
  • 1
    looks like you are using mysqli_* functions as the old mysql_*. i see that because you are missing parameters.. i advice you to look into the PHP manual. http://php.net/manual/en/mysqli.query.php – Raymond Nijland Mar 07 '18 at 13:36
  • $result = mysqli_query("query") or die('Cannot get product. ' . mysqli_error()); $row = mysqli_fetch_assoc($result); – Izuchi Eazydon Macaulay Mar 07 '18 at 13:38
  • Apologies if my question appears disjointed. I'm new here and still trying to get a hang of it – Izuchi Eazydon Macaulay Mar 07 '18 at 13:40
  • It is not possible to determine anything here because the shown code fails to meet the requirements for a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve), as explained in stackoverflow.com's [help center](https://stackoverflow.com/help/how-to-ask). You need to read the help center, then edit your question, and provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Dave Mar 07 '18 at 13:52
  • **`mysqli_query() expects at least 2 parameters, 1 given`** explain everything what is wrong here – Yupik Mar 07 '18 at 14:01
  • you can't used `mysqli_query("query")` because the syntax is: `mysqli_query(connection, query, resultmode);` in your example query is a string instead of a connection: `$con=mysqli_connect("localhost","db_user","db_password_db","db_name");` read this : https://www.w3schools.com/php/func_mysqli_query.asp – Jérôme Teisseire Nov 19 '19 at 22:40
  • Does this answer your question? [mysqli\_query expects at least 2 parameters](https://stackoverflow.com/questions/8073278/mysqli-query-expects-at-least-2-parameters) – Dharman Apr 20 '21 at 20:44

1 Answers1

0

you can't used mysqli_query("query") because the syntax is:

mysqli_query(connection, query, resultmode);

in your example "query" is a string instead of a connection:

$con=mysqli_connect("localhost","db_user","db_password_db","db_name");

read this : https://w3schools.com/php/func_mysqli_query.asp

Jérôme Teisseire
  • 1,518
  • 1
  • 16
  • 26