Hello everybody,
first let me say I am a noobie in php. Nevertheless, I had a script that was working (and still is) fine on my old host.
Script was as follows:
Page1
1) page was loading with a preview of some articles, coming from a table in a database.
2) there was a link created with $id for each article to click on and move to page2
Page2
1) when user was clicking on article with $id=5 for example, s/he was transferred to a page www.mysite.com/articleid.php?id=5.
2) there, s/he could read full article.
Pretty basic stuff one would say.
HOWEVER
Since I've moved hosts, the script is no longer working.
When putting the mouse over the link I can see on status bar of IE (or firefox) the link appearing correctly (i.e. $id has a number).
However, when I click on the link and I am transferred to Page2 I get error
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in bla bla bla
I am completely puzzled and don't know what to do. I've spent 5 days reading on the net, but I keep turning in rounds.
Please help me.
I hereby attach the coding of the pages:
Page 1.php
<? require("/path/to/database/connect.php");
$query="SELECT * FROM table ORDER BY Date Desc, ID DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<?
$i=0;
$ID=mysql_result($result,$i,"ID");
$Category=mysql_result($result,$i,"Category");
$Title=mysql_result($result,$i,"Title");
$Picture=mysql_result($result,$i,"Picture");
$Picturetext=mysql_result($result,$i,"Picturetext");
$Preview=mysql_result($result,$i,"Preview");
$Fullview=mysql_result($result,$i,"Fullview");
$Author=mysql_result($result,$i,"Author");
$Date=mysql_result($result,$i,"Date");
?>
<table style="BORDER-COLLAPSE: collapse" borderColor="#cccccc" cellSpacing="0" width="100%" align="center" border="0">
<tr>
<td width="100%" bgColor="#000000" height="30">
<b>
<a href="<? echo "http://www.mysite.com/articleid.php?ID=$ID"?>" target="_top" style="font-family: Verdana, sans-serif; font-size: 10pt; color=#ffffff" "text-decoration: none"><? echo "$Title"; ?></a>
</b>
<hr>
<tr>
<td bgColor="#000000" style="font-family: Verdana, sans-serif; font-size: 8pt; COLOR=#ffffff">
<? echo "<img border='1' src='$Picture' align='right' width=110 height=110 alt='$Picturetext' COLOR='#0000ff' HSPACE=5 VSPACE=5>"; ?>
<? echo "$Preview"; ?>
</font>
<span style="font-size: 8pt"><i>
<a href="<? echo "http://www.mysite.com/articleid.php?ID=$ID"?>" target="_top"><? echo "Read more"; ?></i></a>
</span></td>
</tr>
</table>
<p>
and
Page2.php
<?
require("/path/to/database/connect.php");
$query="SELECT * FROM table WHERE ID=$ID";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<?
$i=0;
while ($i < $num) {
$ID=mysql_result($result,$i,"ID");
$Title=mysql_result($result,$i,"Title");
$Preview=mysql_result($result,$i,"Preview");
$Picture=mysql_result($result,$i,"Picture");
$Picturetext=mysql_result($result,$i,"Picturetext");
$Fullview=mysql_result($result,$i,"Fullview");
$Author=mysql_result($result,$i,"Author");
$Email=mysql_result($result,$i,"Email");
$Date=mysql_result($result,$i,"Date");
?>
<font face="Verdana">
<center>
<table border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="99%" id="AutoNumber24">
<tr>
<td width="100%" height="30" bgcolor="#CCCCCC">
<? echo "<b><center><font size=H1>$Title</font></center></b>"; ?>
</td>
</tr>
</table>
</center>
<p>
<? echo "<img border='1' src='$Picture' align='right' width=150 height=150 alt='$Picturetext' COLOR='#0000ff' HSPACE=5 VSPACE=5>"; ?>
<? echo "$Preview"; ?><br><br>
<? echo "$Fullview"; ?><br><br>
<a href="mailto:<? echo "$Email"; ?>"><? echo "$Author"; ?></a><? echo ", $Date"; ?>
</font>
<?
$i++;
}
?>
Any idea what is wrong?
Many thanks,
pipo