1

I got to design a login and sign up form using yahoo webhosting.

I have designed the login page and the sign up page using html, but I have to write a .php module to save the entered fields in the "my database" table with table name "login".

I have created the "login" table with the fields in the signup form. But I am not able to connect to the data base thorugh phpMyAdmin. I have written the following code in .php file

<? php 
$db_host = "localhost";
$db_username = "user123";
$db_pass = "password123";
$db_name = "my database";

@mysql_connect("db_host","$db_username","$db_pass") or die ("could not connect to my database");
@mysql_select_db("$db_name") or die("no database");

echo "Successful Connection";
?>

But I am getting 500 - Internal Server Error. Why?

I have to establish a connection and update the values entered in signup form by writing the php code for it.

Damien Pirsy
  • 25,319
  • 8
  • 70
  • 77
priya
  • 33
  • 5
  • 1
    It might help if you weren't using `@` to [suppress error messages](http://stackoverflow.com/questions/3621215/what-does-mean-in-php)… – Quentin Mar 07 '12 at 11:51
  • 1
    `db_host` lacks a $ before, but might just be a typo here and not in your original code. Also, you don't need double quotes there – Damien Pirsy Mar 07 '12 at 11:54
  • ohh thanks.........i also got another issue......while i was searching for some table in the data base, i accidentally changed the privileges i guess.....now i was unable to create a new table or new database in the phpmy admin account.....is there any way i can restore back the settings and priviliges? please help – priya Mar 07 '12 at 13:22
  • Thanks Quentin and Damien......Got it ! – priya Mar 07 '12 at 13:35

1 Answers1

1

You are using variables as parameters for your MySQL functions, and so you don't need (infact you shouldn't) double quotes there!

Change

@mysql_connect("db_host","$db_username","$db_pass") or die ("could not connect to my database");
@mysql_select_db("$db_name") or die("no database");

to

mysql_connect($db_host,$db_username,$db_pass) or die ("could not connect to my database");
mysql_select_db($db_name) or die("no database");
Jared
  • 396
  • 4
  • 14
  • okay thanks jared.........i also got another issue......while i was searching for some table in the data base, i accidentally changed the privileges i guess.....now i was unable to create a new table or new database in the phpmy admin account.....is there any way i can restore back the settings and priviliges? please help – priya Mar 07 '12 at 13:19