Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple PHP Database Connections
    primarykey
    data
    text
    <p>I am making a simple page to test a database connection. When I tried accessing it from my browser, it says: </p> <blockquote> <p>Server error</p> <p>The website encountered an error while retrieving <code>http://localhost:8888/blah/blah/test.php</code>. It may be down for maintenance or configured incorrectly.</p> <p>Here are some suggestions:</p> <p>Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.</p> </blockquote> <p>All I am doing is connecting to a database and displaying the tables. Here is what I have so far as the PHP code:</p> <pre><code>&lt;?php // Get Variables $dbname = $_GET["dbname"]; $dbusername = $_GET["dbusername"]; $dbpass = $_GET["dbpass"]; $dbhost = $_GET["dbhost"]; $connection = mysql_connect("$dbhost","$dbusername","$dbpass"); if (!$connection) { die('Could not connect: ' . mysql_error()); } else { echo "Connected"; $dbcheck = mysql_select_db("$dbname"); if (!$dbcheck) { echo mysql_error(); }else{ echo "&lt;p&gt;Successfully connected to the database '" . $database . "'&lt;/p&gt;\n"; // Check tables $sql = "SHOW TABLES FROM `$database`"; $result = mysql_query($sql); if (mysql_num_rows($result) &gt; 0) { echo "&lt;p&gt;Available tables:&lt;/p&gt;\n"; echo "&lt;pre&gt;\n"; while ($row = mysql_fetch_row($result)) { echo "{$row[0]}\n"; } echo "&lt;/pre&gt;\n"; } else { echo "&lt;p&gt;The database '" . $database . "' contains no tables.&lt;/p&gt;\n"; echo mysql_error(); } } // some code mysql_close($con); ?&gt; </code></pre> <p>My error in the WAMP Apache logs is:</p> <pre><code>[03-Feb-2013 22:47:37 UTC] PHP Parse error: syntax error, unexpected end of file in /Applications/MAMP/htdocs/coursemanager/default/verify1.php on line 52 </code></pre> <p>What would a unexpected end of file be?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload