Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8968215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:25:11+00:00 2026-06-15T17:25:11+00:00

Got a problem! Though I found almost similar threads but none helped :( I’ve

  • 0

Got a problem! Though I found almost similar threads but none helped 🙁

I’ve written a php script to fetch the number of registered users from my MySQL database. The script is working great in my localhost; it is using the given username,pass and host name which are “root”, “root”, and “localhost” respectively, but the script is not using the given username/pass/host rather using root@localhost (password: NO) in Live server.

In the Live server I created a MySQL user, set an different password, and hostname there is of course not localhost. I updated the script with my newly created mysql users data. BUT, whenever I run the script, I see that the script is still using “root”, “root”, and “localhost”!!

take a look at the script:

    //database connection
    $conn = mysql_connect( "mysql.examplehost.com", "myusername", "mypass" );
$db = mysql_select_db ("regdb",$conn); //Oops, actually it was written this way in the script. I misstyped it previously. now edited as it is in the script.

    //Query to fetch data
$query = mysql_query("SELECT * FROM regd ");            
while ($row = mysql_fetch_array($query)): 
$total_regd = $row['total_regd'];
endwhile;   

echo $total_regd;

— Some says to change the default username and pass in the config.ini.php file located in phpMyAdmin directory. Would this help?? I didn’t try this because either my hosting provider didn’t give me privilege to access that directory (because I am using free hosting for testing scripts) or I simply didn’t find it 🙁

Please help….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:25:12+00:00Added an answer on June 15, 2026 at 5:25 pm

    Foreword: The MySQL extension is marked as deprecated, better use mysqli or PDO


    Though you store the connection resource in $conn you’re not using it in your call to mysql_query() and you’re not checking the return value of mysql_connect(), i.e. if the connection fails for some reason mysql_query() “is free” to establish a new default connection.

    <?php
    //database connection
    $conn = mysql_connect( "mysql.examplehost.com", "myusername", "mypass" );
    if ( !$conn ) {
        die(mysql_error()); // or a more sophisticated error handling....
    }
    
    $db = mysql_select_db ("regdb", $conn);
    if ( !$db ) {
        die(mysql_error($conn)); // or a more sophisticated error handling....
    }
    
    //Query to fetch data
    $query = mysql_query("SELECT * FROM regd ", $conn);
    if (!$query) {
        die(mysql_error($conn)); // or a more sophisticated error handling....
    }
    
    while ( false!=($row=mysql_fetch_array($query)) ): 
        $total_regd = $row['total_regd'];
    endwhile;   
    
    echo $total_regd;
    

    edit: It looks like you’re processing only one row.
    Either move the echo line into the while-loop or (if you really only want one record) better say so in the sql statement and get rid of the loop, e.g.

    // Query to fetch data
    // make it "easier" for the MySQL server by limiting the result set to one record
    $query = mysql_query("SELECT * FROM regd LIMIT 1", $conn);
    if (!$query) {
        die(mysql_error($conn)); // or a more sophisticated error handling....
    }
    
    // fetch data and output
    $row=mysql_fetch_array($query);
    if ( !$row ) {
        echo 'no record found';
    }
    else {
        echo htmlspecialchars($row['total_regd']);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found similar questions while searching for a solution for my problem but I
I got problem with sending data in Android using httpPost. I found some example,
Previously, I have worked on local notifications, but I got problem in it now.
Got a problem with Apache and PHP-files of Wordpress. When I go to any
I've found several questions that are sort of similar to mine, but not 100%.
Like many I get this error but none of the solutions I found here
I have started a jetty server in my remote server. But I got problem
i got problem with my code and hopefully someone able to figure it out.
I've got problem with DirectX in C#. I want to draw some lines. Firstly
I've got problem for my application. I want to start connectbot from my application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.