maviyazilim Posted March 11, 2021 Share Posted March 11, 2021 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 Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/ Share on other sites More sharing options...
NotionCommotion Posted March 11, 2021 Share Posted March 11, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585011 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 On 3/11/2021 at 2:38 AM, 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. Expand so sory. I did not understand anything in what you wrote. Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585012 Share on other sites More sharing options...
NotionCommotion Posted March 11, 2021 Share Posted March 11, 2021 On 3/11/2021 at 3:12 AM, maviyazilim said: so sory. I did not understand anything in what you wrote. Expand 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 Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585020 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 On 3/11/2021 at 1:03 PM, 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 Expand I read what is written. but I could not understand what was missing. what should I do Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585025 Share on other sites More sharing options...
NotionCommotion Posted March 11, 2021 Share Posted March 11, 2021 On 3/11/2021 at 5:57 PM, maviyazilim said: I read what is written. but I could not understand what was missing. what should I do Expand 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 Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585027 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 On 3/11/2021 at 7:09 PM, 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 Expand I do not know. I did not understand what was missing. sory Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585028 Share on other sites More sharing options...
Barand Posted March 11, 2021 Share Posted March 11, 2021 On 3/11/2021 at 5:57 PM, maviyazilim said: what should I do Expand Read the manual - NotionCommotion gave you the link. Compare the examples with your code. Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585029 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 sory. My English is weak. I could not understand anything from the information given. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585032 Share on other sites More sharing options...
Barand Posted March 11, 2021 Share Posted March 11, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585033 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 On 3/11/2021 at 8:40 PM, 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. Expand sorry. I read what was written but could not grasp the logic. I can't do it Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585034 Share on other sites More sharing options...
Barand Posted March 11, 2021 Share Posted March 11, 2021 try this link https://www.php.net/manual/tr/mysqli.query.php Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585035 Share on other sites More sharing options...
maviyazilim Posted March 11, 2021 Author Share Posted March 11, 2021 On 3/11/2021 at 10:43 PM, Barand said: try this link https://www.php.net/manual/tr/mysqli.query.php Expand 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 Quote Link to comment https://forums.phpfreaks.com/topic/312277-im-having-trouble-listing-the-latest-data/#findComment-1585036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.