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 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. 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 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 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 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 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 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 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 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 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 2 hours ago, maviyazilim said: what should I do 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 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 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 4 minutes ago, Barand said: try this link https://www.php.net/manual/tr/mysqli.query.php 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.