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 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()); 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)) 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"); 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! 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! 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
Archived
This topic is now archived and is closed to further replies.