Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Uncaught ArgumentCountError: mysqli_error() expects exactly 1 argument, 0 given [duplicate]

Ask Question

I get this error. the thing it should do is update the table in the database and my view order but i only get this error. How do i fix it any idea?

Fatal error: Uncaught ArgumentCountError: mysqli_error() expects exactly 1 argument, 0 given in C:\xampp\htdocs\final\Admin\edit1.php:108
Stack trace:
#0 C:\xampp\htdocs\final\Admin\edit1.php(108): mysqli_error()
#1 {main} thrown in C:\xampp\htdocs\final\Admin\edit1.php on line 108

File name:edit1.php

My Codes

<?php $status = ""; if(isset($_POST['new']) && $_POST['new']==1) { $id=$_REQUEST['id']; $name =$_REQUEST['name']; $email =$_REQUEST['email']; $phone=$_REQUEST['phone']; $address=$_REQUEST['address']; $mode=$_REQUEST['pmode']; $products=$_REQUEST['products']; $amount_paid=$_REQUEST['amount_paid']; $Status=$_REQUEST['Status']; $update="update orders set name='".$name."', email='".$email."', phone='".$phone."', address='".$address.",'pmode='".$mode."', products='".$products."', amount_paid='".$amount_paid."', Status='".$Status."' where id='".$id."'"; mysqli_query($con, $update) or die(mysqli_error()); $status = "Record Updated Successfully. </br></br><a href='view1.php'>View Updated Record</a>"; echo '<p style="color:#FF0000;">'.$status.'</p>'; }else { ?>

My button Codes/placeholder

<form name="form" method="post" action="">  <input type="hidden" name="new" value="1" /> <input name="id" type="hidden" value="<?php echo $row['id'];?>" /> <p><input type="text" name="name" placeholder="Enter Name" required value="<?php echo $row['name'];?>" /></p> <p><input type="text" name="email" placeholder="Enter Email" required value="<?php echo $row['email'];?>" /></p> <p><input type="text" name="phone" placeholder="Enter Phone" required value="<?php echo $row['phone'];?>" /></p> <p><input type="text" name="address" placeholder="Enter Address" required value="<?php echo $row['address'];?>" /></p> <p><input type="text" name="pmode" placeholder="Enter Payment Mode" required value="<?php echo $row['pmode'];?>" /></p> <p><input type="text" name="products" placeholder="Enter products" required value="<?php echo $row['products'];?>" /></p> <p><input type="text" name="amount_paid" placeholder="Enter Amount Paid" required value="<?php echo $row['amount_paid'];?>" /></p> <p><select name="Status" required value="<?php echo $row['Status'];?>" class="form-control">
          <option value="" selected disabled>-Select Status-</option>
          <option value="Incomplete">Incomplete</option>
          <option value="Complete">Complete</option>
        </select> </p> <p><input name="submit" type="submit" value="Update" /></p> 
                The error is on line 108, which we can't see. The error says that mysqli_error on line 108 expects arguments, but you gave it none.
– Jesse
                Apr 4, 2021 at 3:45
                forgot to specify line 108..line 108 is 'mysqli_query($con, $update) or die(mysqli_error());'....also i new to this stuff i have no idea what argument it is expecting me to give
– Hunter
                Apr 4, 2021 at 3:51

When you call mysqli_error you have to provide the connection object, according to the docs:

https://www.php.net/manual/en/mysqli.error.php

You are calling mysql_error like this: mysql_error() which is incorrect.

I cannot see in your code where you create the mysql connection but lets pretend it is a variable named $conn. You should change mysql_error() to mysql_error($conn)

i tried to change the 'mysql_error()' to 'mysql_error($con)' but the error im getting now is 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'pmode='COD', products='1 Liter Milk(50)', amount_paid='500', Status='Complete...' at line 1' – Hunter Apr 4, 2021 at 4:05 That is expected, of course. It was trying to call mysql_error() initially because you have an error in your mysql statement. – Jesse Apr 4, 2021 at 4:07 So, review the error you can now see and adjust your MySQL statement as necessary, as you can now see the error – Jesse Apr 4, 2021 at 4:07