+ Post New Thread
Results 1 to 5 of 5
Web Development Thread, Script of mySql question in Coding and Web Development; To lmk if there is anything wrong in this code? Thanks in advanced! <?php $con = mysql_connect("localhost","name","*password*"); if (!$con) { ...
  1. #1

    Join Date
    Nov 2008
    Location
    Northwest
    Posts
    86
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script of mySql question

    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"
    ?>

  2. #2

    Join Date
    Jul 2010
    Location
    Wakefield
    Posts
    87
    Thank Post
    3
    Thanked 11 Times in 11 Posts
    Rep Power
    10
    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

  3. #3


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,461
    Thank Post
    866
    Thanked 845 Times in 667 Posts
    Rep Power
    195
    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.

  4. #4

    Join Date
    Nov 2008
    Location
    Northwest
    Posts
    86
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by philwaud View Post
    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

  5. #5


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,461
    Thank Post
    866
    Thanked 845 Times in 667 Posts
    Rep Power
    195
    Hey, this isn't hard - debugging errors with "got an error" as your only info is hard... come on, what did it say?

SHARE:
+ Post New Thread

Similar Threads

  1. MYSql - Script batch create users & dbs
    By peterdoherty in forum How do you do....it?
    Replies: 9
    Last Post: 15th January 2014, 10:06 AM
  2. MySQL - mostly harmless?
    By BJG in forum Windows Server 2000/2003
    Replies: 4
    Last Post: 8th October 2009, 03:17 PM
  3. MySQL
    By nicholab in forum MIS Systems
    Replies: 1
    Last Post: 16th May 2008, 05:29 PM
  4. MYSQL Help
    By danIT in forum General Chat
    Replies: 2
    Last Post: 18th December 2007, 09:52 PM
  5. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •