Jump to content

I'm having trouble listing the latest data.


maviyazilim

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

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.