Jump to content

Please Help with MySQL Select


Syekiya

Recommended Posts

Hi there, please help me!

 

<?php
$dbhost = "127.0.0.1";
$dbport = "3306";
$dbname = "******";
$dbuser = "*******";
$dbpass = "******";

$con = mysql_connect($dbhost, $dbuser, $dbpass);
$members = mysql_query("SELECT * FROM accounts");
$bmembers = no;



if (!$con)
{
die('Could not connect: mysql_error());
}

mysql_select_db($dbname, $con);

echo "<table>
<tr>
<th>ID</th><th>Name</th><th>Logged In</th><th>GM</th><th>E-Mail</th>
</tr>";




while($row = mysql_fetch_array($members))
{


echo "<tr>";
echo "<td> {$row['id']} </td>";
echo "<td> {$row['name']} </td>";
echo "<td> {$row['loggedin']} </td>";
echo "<td> {$row['gm']} </td>";
echo "<td> {$row['email']} </td>";
echo "</tr>";

}

echo </table>;

?>

 

I get the following error:

 

 

Parse error: parse error in C:\Inetpub\wwwroot\lol.php on line 34

Link to comment
https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/
Share on other sites

You have to select your DB before you perform your query.  You also should check your $con before you select your DB.  Change these lines so they're in this order:

 

$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) {
   die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $con);
$members = mysql_query("SELECT * FROM accounts");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.