Firstly you should always use
or die(mysql_error())
on all your databse queries.
The error you have is nearly always because the database hasn't returned a result so the function mysql_fetch_row() is passed an invalid parameter, use some sort of test to see that you have a record before passing it to mysql_fetch_row().
The code below will most probably show what is going wrong
<?php
$db = mysql_connect("localhost","root","xxxxxxxx")or die(mysql_error("Couldn't connect to DB"));
mysql_select_db("testing",$db) or die(mysql_error("Couldn't select to DB"));
$query = "SELECT * FROM test_tb";
$result = mysql_query($query) or die(mysql_error("Query Failed"));
if (mysql_num_rows($result)==0) {
echo "No records found";
} else {
while ($record = mysql_fetch_row($result)) {
echo $record[0]; //remember array counts start at zero
// echo $record[1]; have as many here as record fileds you are expecting
}
}
?>
It also loops through the result set, when you get one 😃 , and displays them, you will have to add the code for the number of fields you are expecting in the area shown.
Hope this helps.
AIS4U wrote: Usually you would use the variable $row with the mysql_fetch_row($result) function.
This is entirely unnecessary, You can use any legal variable name you like.