manik;10987048 wrote:
Is it in these line I have to make a change?
$result = mysql_db_query($db_name,$sql);
echo "<div class='produkt'>";
while($rad=mysql_fetch_array($result))
Yes. You need to change the very first line to get rid of the deprecated warning. However, you really should fix some more things.
First things first. From [man]mysql_db_query[/man]
mysql_db_query() selects a database, and executes a query on it.
So to be certain you achieve the same effect without knowing what you're doing, you'd have to replace the first line (each and every place it occurs) with
mysql_select_db($db_name);
$result = mysql_query($sql);
Where obviously $db_name and $sql may be other variable names in other places.
However, you only need to select which schema to use (which is what mysql_select_db does) right after you conncect, or later on if you want to switch which schema is used. So if you have two queries operating on the same query
# first time you need this
mysql_select_db($db_name);
$result = mysql_query($first_query);
# but not the second time
$result = mysql_query($second_query);
So you might want to go over your code and remove any unnecessary calls to select_db.
The returned values for mysql_db_query and [man]mysql_query[/man] are the same as you can see from the doc. If the query failes, the function returns false, yet you never check if it does
$result = mysql_db_query($db_name,$sql);
echo "<div class='produkt'>";
if (!$result)
{
# inform the user
echo 'There was an error. Please try again later';
# and log the error
error_log(mysql_error() . ' ('.mysql_errno() . '): ' . $sql);
}
else
{
# If you don't do the if-else check, this row would give you the error
# mysql_fetch_array() expects parameter 1 to be resource, array given
while($rad=mysql_fetch_array($result));
}