Jump to content

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");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.