Hello everyone i have created a function in a seperate file called ,,block''
were i put this function.
function nauj($b)
{
$res=mysql_query("SELECT id,title,img,Aprasymas FROM informacija WHERE kat=$b ORDER BY id DESC LIMIT 1 ",$link);
if(mysql_num_rows($res)>0)
{
$my = mysql_fetch_array($res);
do
{
printf ("
<tr>
<td><img src='%s' alt='pic'></td>
<td><a href='view_info_post.php?id=%s'>%s</a>
<p>%s</p>
</td>
</tr>",$my["img"],$my["id"],$my["title"],$my["Aprasymas"]);
}
while($my = mysql_fetch_array($res));
}
else
{
echo"Nera info";
}
}
and when i include this file in my other file and use the function it displays errors!
include('funk/block.php');
nauj(1);
errors:
Undefined variable: link in t:\home\test2.ru\www\html su php\funk\nauj.php on line 5
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in t:\home\test2.ru\www\html su php\funk\nauj.php on line 5
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in t:\home\test2.ru\www\html su php\funk\nauj.php on line 8
Nera info
plis help my
were i put this function.
function nauj($b)
{
$res=mysql_query("SELECT id,title,img,Aprasymas FROM informacija WHERE kat=$b ORDER BY id DESC LIMIT 1 ",$link);
if(mysql_num_rows($res)>0)
{
$my = mysql_fetch_array($res);
do
{
printf ("
<tr>
<td><img src='%s' alt='pic'></td>
<td><a href='view_info_post.php?id=%s'>%s</a>
<p>%s</p>
</td>
</tr>",$my["img"],$my["id"],$my["title"],$my["Aprasymas"]);
}
while($my = mysql_fetch_array($res));
}
else
{
echo"Nera info";
}
}
and when i include this file in my other file and use the function it displays errors!
include('funk/block.php');
nauj(1);
errors:
Undefined variable: link in t:\home\test2.ru\www\html su php\funk\nauj.php on line 5
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in t:\home\test2.ru\www\html su php\funk\nauj.php on line 5
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in t:\home\test2.ru\www\html su php\funk\nauj.php on line 8
Nera info
plis help my