Jump to content

Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in /var/www/html/cocoa/index.php:13 Stack trace: #0 /var/www/html/cocoa/index.php(13): printf('%s %s\n', '<a href='cocoa_...') #1 {main} thrown in /var/www/html/cocoa/index.php o


bertrc

Recommended Posts

 

printf error line

<?php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysqli = mysqli_connect("localhost", "root", "P-11fl32fg14", "cocoa");

$query = "SELECT type_chocolate.type_chocolate,type_chocolate.type_chocolate FROM type_chocolate";

$result = mysqli_query($mysqli, $query);

/* numeric array */

while ($row = mysqli_fetch_array($result, MYSQLI_BOTH))

{

printf("%s %s\n","<a href='cacau_type_chocolate.php?type_chocolate=" . $row['type_chocolate'] . ">,". $row['type_chocolate'] . "</a>");?> <br>

<?php

}

?>

 

Link to comment
Share on other sites

https://www.php.net/print_f

You don't need to select the same column twice.

The %s in the print_f format argument are placeholders for the string variables ($row['type_chocolate'])

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = mysqli_connect("localhost", "root", "P-11fl32fg14", "cocoa");

$query = "SELECT type_chocolate FROM type_chocolate";

$result = mysqli_query($mysqli, $query);

while ($row = mysqli_fetch_assoc($result))

{
    printf("<a href='cacau_type_chocolate.php?type_chocolate=%s'>%s</a>", $row['type_chocolate'], $row['type_chocolate']);
}

 

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.