Jump to content

Error At Line 8


beennn

Recommended Posts

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

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

Archived

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

×
×
  • Create New...