Russ Posted May 7, 2006 Posted May 7, 2006 Hi. I created a database for my Gallery2 installation. I forgot the password, but I have an idea what it might be. I had the idea of writing a script connecting to the database. My theory was this if the connection was successful, I remembered the password correctly. I wrote the following script (with actual "Usename" and "Password" inserted): ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>Connect to G2 Database</title> <link rel="stylesheet" href="http://www.hintzefamily.com/test/Just_A_Test/stylescss/stylesheet1e.css" type="text/css" /> </head> <body> <?php //Script to connect to G2 Database "Connect to G2 Database ini_set ('display_errors" 1); error_reporting (E_ALL & ~E_NOTICE); if ($dbh=mysql_connect ("localhost", "username", "password")) { print "<p>Successfully connected to MySQL.</p>"; mysql_close(); } else { die ("<p>Could not connect to MySQL because: <b>" . mysql_error . "</b></p>"); } ?> </body> </html> When I attempt to run oit, however, I get the following error: Parse error: syntax error, unexpected $end in /home/russ/public_html/test/testphp/connect_to_g2..php on line 31 I imagine I am missing something basic. Can anyone take pity on a newbie and point out my error? :-) Quote
Russ Posted May 7, 2006 Author Posted May 7, 2006 In doing some research on the internet I came accross this thread in php Addict which suggests that the error is an indication missing "}", but I seem to have all the curly brackets closed? Quote
TweezerMan Posted May 7, 2006 Posted May 7, 2006 This line appears to be the problem: >ini_set ('display_errors" 1); 1) 'display_errors" starts with a single quote and ends with a double quote, and 2) There is a comma missing between display_errors and the 1. The line should look like this: >ini_set ("display_errors", 1); Quote
Russ Posted May 7, 2006 Author Posted May 7, 2006 Thank you very much David. That worked - my guess at the password was wrong , but the script did work as intended . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.