MySQL_connection error - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

MySQL_connection error

DoomCarnageDoomCarnage Posts: 2Member
edited November 2013 in PHP

Hi. I have tried this on another computer and it worked but it does not work when I switch computer. It would be great if anyone help me to resolve this problem. I have been trying to solve this problem for hours but to no avail

The error code is this database connection error

I used the test branches to test where the program would end and realise it will not get pass this line
mysql_connect('localhost', 'root', 'root') or die ('database connection error');

Perhaps it is my localhost problem. I been using port 90 and I tried substituting localhost to localhost:90 but does not work. Someone please enlightened me.

Part of my code
session_start();

mysql_connect('localhost', 'root', 'root') or die ('database connection error');
mysql_select_db('cupcakes') or die(mysql_error());

$username=$_POST['username'];
$password=$_POST['password'];

$loginprocess = mysql_query("SELECT * FROM register WHERE username = '$username' and password = '$password'");
$loginstatus = mysql_num_rows($loginprocess);
if ($loginstatus != 1)........

Comments

  • leenolanleenolan Posts: 7Member

    Maybe something in your firewall, try adding port 90.

    I don't think you can use localhost:90, you would need the ip address - 127.0.0.1:90

  • DoomCarnageDoomCarnage Posts: 2Member

    @leenolan said:
    Maybe something in your firewall, try adding port 90.

    I don't think you can use localhost:90, you would need the ip address - 127.0.0.1:90

    Sorry but I try to change the ip address to 127.0.0.1:90 and off my firewall but it does not work. I get an error code "HTTP 500 Internal Server Error"

  • davidbxdavidbx navi mumbaiPosts: 1Member
    edited November 2013

    It does not work when I switch computer. : Does your other system have same apache port setting to 90?,
    port: 80 & port: 8080 works well...!
    also cck for database in other system to match....this will resolve 'database connection error');

    <?php $db = mysql_connect('localhost', 'root', 'root', 'cupcakes') or die ('database connection error'); /// not needed mysql_select_db('cupcakes') or die(mysql_error()); $username=$_POST['username']; $password=$_POST['password']; $loginprocess = mysql_query("SELECT * FROM register WHERE username = '$username' and password = '$password'"); $loginstatus = mysql_num_rows($loginprocess); if ($loginstatus != 1){ // Login Successfull } else { // Sign Up, forget passwoord } mysqli_close($dbc); ?>

  • sunlotussunlotus Posts: 55Member

    mysql_connect(Host, db_username, db_password) ; by default, a DB server has no password and username is"root"; you have password "root" on your local machine, your localhost, but on another pc maybe you didn't add a password and you're trying to connect with a password

Sign In or Register to comment.