beennn Posted September 27, 2011 Share Posted September 27, 2011 heres what iv made; <? $con = mysql_connect("localhost","username","password"); mysql_select_db("db_name", $con); $result = mysql_query("SELECT * FROM table_name"); while($row = mysql_fetch_array($result)){$showHits = $row['downloadCounter'];} ?> Line 8: while($row = mysql_fetch_array($result)) any idea what im doing wrong? >.< Link to comment Share on other sites More sharing options...
Ingolme Posted September 27, 2011 Share Posted September 27, 2011 You haven't told us what the error says, but I'm thinking it probably looks like this: mysql_fetch_array() expects parameter 1 to be a resource, boolean found. It means that the query that you assigned to $result failed. You should test for that and see what the problem if:$result = mysql_query("SELECT * FROM table_name");if(!$result) { echo mysql_error();} That will tell you what the error is. I'm going to take a guess as to what that error is too: No database selected. You might have misspelled the database name in the mysql_select_db() statement. Anyways, read the error messages. Link to comment Share on other sites More sharing options...
beennn Posted September 27, 2011 Author Share Posted September 27, 2011 ^.- you were right about everything until You might have misspelled the database name in the mysql_select_db() statement., the spelling is correct yet im still getting 'no database selected' EDIT: Thank you very much, fixed. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.