Jump to content

Recommended Posts

Posted

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"

?>

Posted

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

Posted

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.

Posted
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...