macsit Posted October 3, 2010 Posted October 3, 2010 To lmk if there is anything wrong in this code? Thanks in advanced! <?php $con = mysql_connect("localhost","name","*password*"); if (!$con) { die('Could not connect: ' . mysql_error()); } $sql = "SELECT value FROM `phplist_userstats` WHERE value > 1000"; echo "$sql users on the mailing list" ?>
philwaud Posted October 3, 2010 Posted October 3, 2010 Good start! Once you have your SQL script, you have to actually execute it, then count the rows. Easy... $query = mysql_query($sql); $noofusers = mysql_num_rows($query); Hope this helps! Phil
tom_newton Posted October 3, 2010 Posted October 3, 2010 Yes - something fairly fundamental - you need to actually RUN the sql, not just print it! Also, the SQL would seem to be looking for the number of users, as long as it's over 1000. Odd. Have you tried reading the tutorials on PHP/mysql? Beaten to it - phil's answer looks reasonable - he's actually running the sql, although for either of us to get it "right" we'd need to know how the table is organised and what data you want.
macsit Posted October 4, 2010 Author Posted October 4, 2010 Good start! Once you have your SQL script, you have to actually execute it, then count the rows. Easy... $query = mysql_query($sql); $noofusers = mysql_num_rows($query); Hope this helps! Phil Tried that, and got an error with the $noofusers line Wow.. This is getting much harder than I thought lol
tom_newton Posted October 5, 2010 Posted October 5, 2010 Hey, this isn't hard - debugging errors with "got an error" as your only info is hard... come on, what did it say?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now