Syekiya Posted April 10, 2009 Share Posted April 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/ Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 Change this line to: die('Could not connect: ' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/#findComment-806114 Share on other sites More sharing options...
Syekiya Posted April 10, 2009 Author Share Posted April 10, 2009 New Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\lol.php on line 30 Line 30: while($row = mysql_fetch_array($members)) Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/#findComment-806116 Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 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"); Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/#findComment-806123 Share on other sites More sharing options...
Syekiya Posted April 10, 2009 Author Share Posted April 10, 2009 Thank you, very much! Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/#findComment-806126 Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 Thank you, very much! YW I assume this solves your problem? Please mark [sOLVED], thanks! Quote Link to comment https://forums.phpfreaks.com/topic/153426-please-help-with-mysql-select/#findComment-806127 Share on other sites More sharing options...
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.