Jump to content

alexandre

Members
  • Posts

    253
  • Joined

Everything posted by alexandre

  1. no matter what i tried , nothing is working and i have tried every single array functions. i need to compare $value1 with the $_SESSION['id'] $winners1[] = array_slice($WINNERSID, 0, $num_winners3); if ($winners2 = array_filter($winners1)) { foreach ($winners2 as $value1) { if (in_array(intval($_SESSION['id']), $value1) && $prizepaid == false) { value1 contains this: array(2) { [0]=> string(2) "24" [1]=> string(2) "25" } normally i believe it shouldnt be so complicated to see if the user id is the same as one of those numbers from the array..
  2. $stmt = 'SELECT DISTINCT participationid, usernames, totaldonated FROM donationclashdetails GROUP BY participationid ORDER BY totaldonated DESC'; $final = mysqli_query($con, $stmt); if ((mysqli_num_rows($final) > 0) && mysqli_num_rows($final) <= intval($num_winners3)) { while ($FINALROW = mysqli_fetch_assoc($final)) { echo "<div class='rankingtrue'> <table class='rankingtable'> <tr> <td>Id</td><td>username</td><td>last donation</td><td>total donated</td> </tr> <tr> <td class='remain2'>". $FINALROW['participationid']. "</td> <td class='remain2'>". $FINALROW['usernames']. "</td> <td class='remain2'>". $FINALROW['totaldonated']. "</td> </tr> </table>"; '</div>'; $WINNERS[] = intval($FINALROW['participationid']);//i need to get this WINNERS array defined for lower var_dump($WINNERS); }} $prizeamount = $winners_amount; $prizeamount = $prizeamount * 65; $prizeamount = $prizeamount / 100; $remaining_funds = $winners_amount * 35; $remaining_funds = $remaining_funds / 100; $stmt = $con->prepare("UPDATE foundationsfunds SET foundation_funds = ?"); $stmt->bind_param('d', $remaining_funds); $stmt->execute(); $WINNERSAMOUNT = $prizeamount / intval($num_winners3); $stmt = $con->prepare("SELECT prizepaid FROM donationclashdetails WHERE participationid = ?"); $stmt->bind_param('i', $_SESSION['id']); $stmt->execute(); $stmt->bind_result($prizepaid); $stmt->fetch(); $stmt->close(); if (in_array(intval($_SESSION['id']), $WINNERS) && $prizepaid == false) { // here is where it is used $stmt = $con->prepare("SELECT userbalance, totalpifcoingained, userlevel, userexperience FROM accounts WHERE id = ?"); // In this case we can use the account ID to get the account info. $stmt->execute([ $_SESSION['id'] ]); $stmt->bind_result($userbalance, $totalpifcoingained, $userlevel, $userexperience); $stmt->fetch(); $stmt->close(); for some reason the array is not getting populated or i am handeling the data in the wrong way, this is just strange because its not even showing anything on the var_dump() this is the last step of my script if anyone can help me it would be great . Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in C:\xampp\htdocs\container\donation-clash\donationclashhome.php:141 Stack trace: #0 C:\xampp\htdocs\container\donation-clash\donationclashhome.php(141): in_array(35, NULL) #1 {main} thrown in this is the only error i get apart of the undefined variable itself
  3. $stmt = 'SELECT DISTINCT participationid, usernames, donationamount, totaldonated FROM donationclashdetails GROUP BY participationid ORDER BY totaldonated DESC'; $result = mysqli_query($con, $stmt); if (mysqli_num_rows($result) > 0 ) { while ($result_row = mysqli_fetch_assoc($result)) { echo "<div class='rankingtrue'> <table class='rankingtable'> <tr> <td>Id</td><td>username</td><td>last donation</td><td>total donated</td> </tr> <tr> <td class='remain2'>" .$result_row['participationid']. "</td> <td class='remain2'>". $result_row['usernames']. "</td> <td class='remain2'>". $result_row['donationamount']. "</td> <td class='remain2'>". $result_row['totaldonated']. "</td> </tr> </table>"; '</div>'; } } so i am trying to echo a ranking and this table here is going to be way to long in lenght at some point and if i add the scroll on overflow it makes tons of scroll bars all around the bottom it is because the table is populated with the multiple arrays pulled from the database. but i do not understand why more you scroll and more the rows gets smaller like crawling on themselves.. i think i might have to display the rows in another way but for now i am clueless. and for the page going darker is because of opacity on the table that is expanding to the rest of the page.
  4. i dont know what can be causing this but it is simply that the header of the page stay as bright and more you scroll down you see the page go dark .. if anyone have an idea of what can be causing this i would appreciate.
  5. amazing thank you very much for the example of update there nothing better than to see to learn for me so i appreciate that. i will now convert to pdo. i would have a last question . with pdo will i still be able to make a ranking like that with a query or the way of doing so is changing a bit? $stmt = 'SELECT DISTINCT participationid, usernames, donationamount, totaldonated, sum(donationamount) as totaldonated FROM donationclashdetails GROUP BY participationid ORDER BY totaldonated DESC'; $result = mysqli_query($con, $stmt); if ((mysqli_num_rows($result) > 0) && mysqli_num_rows($result) < 1000) { while ($ROW = mysqli_fetch_assoc($result)) { echo $ROW['participationid']. $ROW['usernames']. $ROW['donationamount']. $ROW['totaldonated'] . ' - ' . '<br>'; }}
  6. in fact i am pretty sure that i am fetching everything at least everything before where the script breaks. if i used a store_result() before but removed it do the data could still be stored in memory or it goes when you remove the store_result()?
  7. i understand i will dive into pdo then. but for this command out of sync i am clueless since i didnt use mysqli_use_result or store_result maybe i should have in between my queries but now i will change to pdo . thank you for your answers.
  8. is there particular reason why pdo is so much better ? and as i see your opinion about mysqli i wonder if there are not some things or bugs making pdo better.
  9. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in C:\xampp\htdocs\container\donation-clash\donation-clash.php:93 Stack trace: #0 C:\xampp\htdocs\container\donation-clash\donation-clash.php(93): mysqli->prepare('UPDATE accounts...') #1 {main} thrown in C:\xampp\htdocs\container\donation-clash\donation-clash.php on line 93 here is the part of the code. $stmt = $con->prepare("UPDATE accounts SET userbalance = ?, totaldonationdc = ?, userlevel = ?, userexperience = ?, totaleventjoined = ? WHERE id = ?"); //bind parameters for markers, where (s = string, i = integer, d = double, b = blob) $stmt->bind_param('iiidii', $userbalance, $totaldonationdc, $userlevel, $userexperience, $totaleventjoined, $_SESSION['id']); $stmt->execute(); i would like to know if there is a syntax error in this code or something. or if i can simply do this , anyways any help will be appreciated.
  10. i have literally 50 tabs opened in my browser if you think i am not doing researches .. you are wrong . if i ask is because i cant find the exact answer in the manual they explain extremely bad and gives barely a couple examples that doesnt match what i need to know. maybe this answer i could have googled it but you was here answering me so i simply prefferred to enjoy some more accurate advices than digging in google. sorry if i bothered you this wont happen again.
  11. select participationid, sum(donationamount) as total_donated from donationclashdetails group by participationid order by total_donated desc so here where should i put the limit and numbers for it to actualy work without me getting synthax error beacuse i cant seem to be able to make it work
  12. yes i was thinking about starting a topic simply called web development questions. and i know i am doing things differently it is just that i was testing lots of combinaisons without it working but i think i just understood a bit better now. but do the * after the select is wrong too because i still need to pull all the data from 1000 rows and display it as ranking page.. i will have lots of research ahead 😪
  13. it is ok i removed it but now i am not sure if i can do this here $stmt = $con->prepare('SELECT * FROM donationclashdetails GROUP BY participationid ORDER BY totaldonated LIMIT(1000,0) DESC'); i am getting this Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(1000,0) DESC' at line 1 in C:\xampp\htdocs\container\donation-clash\donation-clash.php:126 Stack trace: #0 C:\xampp\htdocs\container\donation-clash\donation-clash.php(126): mysqli->prepare('SELECT * FROM d...') #1 {main} thrown in C:\xampp\htdocs\container\donation-clash\donation-clash.php on line 126
  14. new challenge for you guys $stmt = ('SELECT sum(totalpifcoincollected) FROM donationclashdetails'); $result = mysqli_query($con, $stmt); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { //displaying the total amount of pifcoin collected by participants for the week echo "the total collected this week for the donation clash:"; echo ''. ' - ' . ' - ' . ' - ' . ' - ' . $row['totalpifcoincollected']. '<br>'; } whatever i do i cant seem to be able to get past this undefined array error . it might be with the comma or placement i am not sure of what to put in the beginining of echo $rows
  15. $stmt = $con->prepare('SELECT participationid, usernames, totaldonated FROM donationclashdetails GROUP BY participationid ORDER BY totaldonated DESC'); $result = mysqli_query($con, $stmt); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { //rankings echo ''. $row['participationid'] . $row['usernames'] . $row['donationamount']. ' - ' . ' - ' . '<br>'; } } is this possible that this query cant return a string or something .. i am getting this error. Fatal error: Uncaught TypeError: mysqli_query(): Argument #2 ($query) must be of type string, mysqli_stmt given in C:\xampp\htdocs\container\donation-clash\donation-clash.php:101 Stack trace: #0 C:\xampp\htdocs\container\donation-clash\donation-clash.php(101): mysqli_query(Object(mysqli), Object(mysqli_stmt)) #1 {main} thrown in C:\xampp\htdocs\container\donation-clash\donation-clash.php on line 101
  16. no i didnt mean to say deprecated but just to change the syntax of the sample i use as structure. i just started in php. but i do like the synthax of this format. i saw some example of the pdo extension and for my understanding i chose this. it is more of a personal choice
  17. yes i forgot that i changed the deprecated query form to a prepared query so i didnt change $sql for $stmt
  18. $stmt = $con->prepare('SELECT usernames, totaldonated FROM donationclashdetails ORDER BY totaldonated DESC'); $result = mysqli_query($con, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { //rankings echo ''.' - ' . $row['usernames']. $row['totaldonated']. ' - ' . '<br>'; } } //here is the prt of code ho i think i just saw lol
  19. just like that because i am bored and i am searching this answer what would be the most secure and efficient way as an alternative for mysqli_query() whcich is telling me that it is deprecated.. Deprecated: mysqli_query(): Passing null to parameter #2 ($query) of type string is deprecated in C:\xampp\htdocs\container\donation-clash\donation-clash.php on line 101 i am almost sure that barrand got a strong opinion about it 😄 from where i am asking .
  20. oh yeah i see , its just the dangling i never read before. anyways thnak you for your help
  21. i am sorry i am french and bad in english what means a dangling comma ?
  22. i understand thank you and i also get this error for this line of code and i cant figure what is the syntax mistake i made Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') VALUES (?, ?, ?,)' at line 1 in C:\xampp\htdocs\container\donation-clash\donation-clash.php:60 Stack trace: #0 C:\xampp\htdocs\container\donation-clash\donation-clash.php(60): mysqli->prepare('INSERT IGNORE I...') #1 {main} thrown in C:\xampp\htdocs\container\donation-clash\donation-clash.php on line 60 elseif (($userbalance >= $donationamountinpending) && $donationclash == true) { $stmt = $con->prepare("INSERT IGNORE INTO donationclashdetails (participationid, usernames, donationamount,) VALUES (?, ?, ?)"); $stmt->bind_param('isi', $_SESSION['id'], $_SESSION['name'], $_POST['participation']); $stmt->execute(); } else { exit; } line 60 is the INSERT line
  23. it looks good , just need a little clarification here. do the number 1 is to pull 1 row as for using limit (something)?
  24. $sql= 'SELECT usernames, totaldonated FROM donationclashdetails ORDER BY totaldonated DESC'; $result = mysqli_query($con, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { //rankings echo ''.' - ' . $row['usernames']. $row['totaldonated']. ' - ' . '<br>'; } do this code is derived data and also i would like to know if it diplays only one row or all of them .
  25. yes i agree this is much more logical as approach only i need to make a live ranking of their donations and their total donated that is why it is confusing me a bit
×
×
  • 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.