Help With Php Script

windows

Guest
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 "<b>Usename</b>" and "<b>Password</b>" inserted):<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml" ><br /><head><br />    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/><br /><br />    <title>Connect to G2 Database</title><br />    <br />    <link rel="stylesheet" href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"http://www.hintzefamily.com/test/Just_A_Test/stylescss/stylesheet1e.css" type="text/css" /><br /></head><br /><br /><body><br /><br /><?php //Script to connect to G2 Database "Connect to G2 Database<br /><br />    ini_set ('display_errors" 1);<br />    error_reporting (E_ALL & ~E_NOTICE);<br />    <br />    if ($dbh=mysql_connect ("localhost", "username", "password")) {<br />        print "<p>Successfully connected to MySQL.</p>";<br />        mysql_close();<br />        <br />    } else {<br />        die ("<p>Could not connect to MySQL because: <b>" . mysql_error . "</b></p>");    <br /><br />    }        <br />?>    <br /><br /></body><br /></html><!--c2--></div><!--ec2--><br /><br />When I attempt to run oit, however, I get the following error:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Parse error: syntax error, unexpected $end in /home/russ/public_html/test/testphp/connect_to_g2..php on line 31<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />I imagine I am missing something basic. Can anyone take pity on a newbie and point out my error? :-)<!--content-->
In doing some research on the internet I came accross this thread in <a href="http://72.14.207.104/search?q=cache:DhHp8Dz1Vk8J:www.phpaddict.com/forum1/834.html+php+%22unexpected+%24end+%22&hl=en&gl=us&ct=clnk&cd=3" target="_blank">php Addict</a> which suggests that the error is an indication missing "}", but I seem to have all the curly brackets closed?<!--content-->
This line appears to be the problem:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->ini_set ('display_errors" 1);<!--c2--></div><!--ec2--><br />1) <i>'display_errors"</i> starts with a single quote and ends with a double quote, and<br /><br />2) There is a comma missing between <i>display_errors</i> and the <i>1</i>.<br /><br />The line should look like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->ini_set ("display_errors", 1);<!--c2--></div><!--ec2--><!--content-->
Thank you very much David. That worked - my guess at the password was wrong <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> , but the script did work as intended <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> .<!--content-->
 
Back
Top