Jump to content

Recommended Posts

I'm having trouble listing the most recent 10 content. How can I solve this problem.

$sorgu = mysqli_query("select * from icerik order by id desc limit 0,10");

while($goster=mysqli_fetch_assoc($sorgu)) {
  echo $goster['baslik'];
  echo $goster['yazi'];
  echo $goster['yazar'];

}

error code:

Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given in C:\xampp\htdocs\blog\orta.php:3 Stack trace: #0 C:\xampp\htdocs\blog\orta.php(3): mysqli_query('select * from i...') #1 C:\xampp\htdocs\blog\index.php(4): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\orta.php on line 3

First look at what error message PHP send you.  Then take a look at https://www.php.net/manual/en/mysqli.query.php

You are doing the procedural (non OOP) version.

mysqli_query ( mysqli $link , string $query , int $resultmode = MYSQLI_STORE_RESULT ) : mixed

When you call a function or method, you need to provide something for all the arguments (i.e. inputs to the function) unless the input is followed by "=someDefaultValue".

So, you don't send the just the query but first the mysqli link and then the query.

33 minutes ago, NotionCommotion said:

First look at what error message PHP send you.  Then take a look at https://www.php.net/manual/en/mysqli.query.php

You are doing the procedural (non OOP) version.


mysqli_query ( mysqli $link , string $query , int $resultmode = MYSQLI_STORE_RESULT ) : mixed

When you call a function or method, you need to provide something for all the arguments (i.e. inputs to the function) unless the input is followed by "=someDefaultValue".

So, you don't send the just the query but first the mysqli link and then the query.

so sory. I did not understand anything in what you wrote.

9 hours ago, maviyazilim said:

so sory. I did not understand anything in what you wrote.

Please read the following, and tell me what it says in your own words.

Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given

4 hours ago, NotionCommotion said:

Please read the following, and tell me what it says in your own words.

Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given

I read what is written. but I could not understand what was missing.

what should I do

1 hour ago, maviyazilim said:

I read what is written. but I could not understand what was missing.

what should I do

mysqli_query wants at least two things, right?  How many did you give it?  Look at the second line of your original post.

Now, looking below tells you exactly what it wants.  Some sort of link and a query and an optional resultmode (in that order).  Which one didn't you give it?

mysqli_query ( mysqli $link , string $query , int $resultmode = MYSQLI_STORE_RESULT ) : mixed

 

10 minutes ago, NotionCommotion said:

mysqli_query wants at least two things, right?  How many did you give it?  Look at the second line of your original post.

Now, looking below tells you exactly what it wants.  Some sort of link and a query and an optional resultmode (in that order).  Which one didn't you give it?


mysqli_query ( mysqli $link , string $query , int $resultmode = MYSQLI_STORE_RESULT ) : mixed

 

I do not know. I did not understand what was missing. sory

1 hour ago, Barand said:

Kılavuzu okuyun - NotionCommotion size bağlantıyı verdi. (https://www.php.net/manual/en/mysqli.query.php)(

Örnekleri kodunuzla karşılaştırın.

sorry. I read what was written but could not grasp the logic. I can't do it

4 minutes ago, Barand said:

sorry. The page is in Turkish, but there is no translation. same with english. I can not understand my problem. I could not understand what to do.

thank you. I guess I can't. best to leave

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.