Jump to content

Justafriend

Members
  • Posts

    101
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Justafriend's Achievements

Member

Member (2/5)

0

Reputation

  1. when i tried that with all the code it give me an Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\pawn\listtest.php on line 59 but if i i remove the having it works no problem here is the updated code $dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password); foreach($dbh->query('SELECT username,COUNT(*) as total, FROM games GROUP BY username HAVING total > 5') as $row) { echo "<tr>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['COUNT(*)'] . "</td>"; echo "</tr>"; } ?>
  2. I am still working on learning pdo slowly trying to migrate into the newest most secure operations and have an issue with the count and no idea where to look for it i have spent countless hours searching and am no further along so i thought id ask the people here if this is even possible What i have is a count total number of entries per person which i have working perfectly but the issue is i need to only count them when the total is greater then 5 $dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password); foreach($dbh->query('SELECT username,COUNT(*), WHERE COUNT(*)<5 FROM games GROUP BY username') as $row) { echo "<tr>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['COUNT(*)'] . "</td>"; echo "</tr>"; } ?> so if a user only has 4 entries it will skip his name I hope this makes sense and hope someone can help me
  3. I have this code that pulls data from a form and is supposed to check if the neptune and username are inserted 2 times it replies back with an error if not it posts the data to 2 lines with neptune username and email on one line and just email and username on the other The issue is the code i have gives me an error saying unexpected end of file below is my code any help will be appreciated <?php if(isset($_POST['choices']) && !empty($_POST['choices'])){ if($_POST['choices'] == 'four'){ //variables from form entered $username = $_POST['username']; $neptune = $_POST['neptune']; $email = $_POST['useremail']; //connect to the database $dbc = mysqli_connect('localhost', 'root', '', 'happygam_main') or die('Error connecting to MySQL server'); $check=mysqli_query($dbc,"select * from ballot where username='$username' and neptune='$neptune'"); $checkrows=mysqli_num_rows($check); if($checkrows>0) { echo "This combination of neptune and username has already been processed"; } else { //insert results from the form input in 2 rows one with neptune one without $query = "INSERT IGNORE INTO ballot(username, useremail, neptune) VALUES('$username', '$email', '$neptune')"; $query1 = "INSERT IGNORE INTO ballot(username, neptune) VALUES('$username', '$neptune')"; $result = mysqli_query($dbc, $query, $query1) or die('Error querying database.'); mysqli_close($dbc); } } ?>
  4. thank you for all you do and your help this table is only for a week long event we use each year and when its done it is backed up for next year
  5. that fixed the error but its still not updating the column here is an example of the table what im trying to do is count how many for each username that has a non null in the column neptune and if ithe same player has more then 5 Non Null values to mark the morethan5 column with yes
  6. Ok i have a table with headings username useremail randomnumber neptune morethen5 What im trying to do is if a username has more than 5 records where neptune isnt null update the morethan5 column for all username with yes this is the query i have update ballot set morethan5 = yes where username in ( select * from ( select neptune from ballot group by username having count(1) > 5 ) x ) i got first of all an error saying yes column didnt exist so i created a new column called yes and it isnt updating any records
  7. and as for the injections they are all being handled in the java verification of the form so that all data is verified before going into the php
  8. Update found the html error ty for the pointing me in right direction
  9. there are 4 different types of entries there is singles getting 2 ballots ​there is singles getting 1 ballot there is pards getting 2 ballots and there is pards getting 1 ballot Eventually each code will be going to its own confirm submission page as i stated above my post hence why i have 4 different queries ok i will have to look through the html code i just thought that once the php processes a query it doesnt use the code on the page that sent the info but i do appreciate your help and appreciate the direction
  10. first off i know all 4 headers im using are same its temporary for now eventually i will have 4 different confirmation pages The issue im having is all 4 are processing form correctly into the db but the confirmation pages are redirecting to a new tab here is the php code if needed i can supply the html code as well but seeing the header is being pulled from the php file i think thats where it is what i want is that when the html form processes that it redirects the page to one of the four confirmation pages instead of in a new tab $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } if(isset($_POST['choices']) && !empty($_POST['choices'])){ if($_POST['choices'] == 'four'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; $sql1 = "INSERT INTO ballot (username, useremail, randomnumber) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber3"]."')"; if (mysqli_query($conn, $sql)) ; if (mysqli_query($conn, $sql1)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get2ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'twoorless'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; if (mysqli_query($conn, $sql)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'sixseven'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; $sql1 = "INSERT INTO ballot (username, useremail, randomnumber) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber3"]."')"; if (mysqli_query($conn, $sql)) ; if (mysqli_query($conn, $sql1)) ; { { header("Location: http://justtheway.com/wb/events/pawn/get2ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'fiveorless'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; if (mysqli_query($conn, $sql)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } } }else{ echo "Please select once choice for submit query!"; } mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } ?>
  11. i emptied the table now its working properly ty for your help
  12. its when I run it through the code and paste it here if I copy from the list on results page and ran it through your script I get string(15) "​habs4stanley" E2 80 8B 68 61 62 73 34 73 74 61 6E 6C 65 79 string(12) "Habsfan4life" 48 61 62 73 66 61 6E 34 6C 69 66 65 string(4) "demo" 64 65 6D 6F but the names are still in the same order as above
  13. thank you all for your jhelp now i have one other ? the order by name is making it sort by count then name I thought ORDER BY username'; would make it alphabetical but its going by number of entries then alphabetical easiest way to explain what I'm looking for is this is how its resulting demo 2 Habsfan4life 2 habs4stanley 1 what id like is that it goes demo 2 habs4stanley 1 Habsfan4life 2
  14. $dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password); foreach($dbh->query('SELECT username,COUNT(*) FROM ballot GROUP BY username') as $row) { echo "<tr>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['COUNT(*)'] . "</td>"; echo "</tr>"; } the result is coming like this habs4stanley1 demo2 Habsfan4life2 ​I need it to put it like this ​habs4stanley 1 ​demo 2 ​habsfan4life 2 ​any help is greatly appreciated
×
×
  • 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.