Hello,
I've tried everything I can think of. I've researched PHP and MySQL documentation as well as searched the web and forums like this.
What I'm doing is trying to post a random daily "article" on the home page. So I'm trying to check to see if an "article" has already been posted for that day and if so repost that. If one hasn't been posted for the day it will then do another query to find an "article" that hasn't ever been posted and post that.
I can't seem to get my queries to work. I had it working fine when I wasn't trying to search for an article that was already posted that day. When I added that query it started failing. As I have it now if there was an article posted for the current day it will show that. But if there are none in the database with today's date it will still evaluate to true and try to run the code for that. However it isn't actually finding a valid article. I've tried posting the result variable and got the "Resource ID" as, expected for an array. However when I cut the initial query down to one field from the database it still showed the "Resource ID" as the result. So I'm thinking somehow the Resource isn't getting cleared out and is throwing off the result variable, as indicated here:
http://us3.php.net/manual/en/language.types.resource.php
However every other time I use the same code it works fine.
Below is what I have. Any assistance would be appreciated.
Regards,
David Devaney, Jr.
<?php
$ptoday = Date("Y-m-d");
dbConnect("davidd_poetry");
$resultP = mysql_query("select UserID,Title,DateWritten,Poem,DatePost from ind_poems where DatePost= '$ptoday' limit 1");
if (!resultP) {
echo "no match found - $ptoday";
$result = mysql_query("select UserID,Title,DateWritten,Poem from ind_poems where Posted < 1 limit 1");
if (!$result){
echo "No Matches Found";
}else{
while ($row = mysql_fetch_row($result)){
$uid = $row[0];
dbConnect("davidd_RegUsers");
$poetresult = mysql_query("select Name from RegUser where UserID = $uid limit 1");
$poet = mysql_fetch_row($poetresult);
$poem = $row[3];
$poem = str_replace ("\r\n","<br>",$poem);
$date = convertDate($row[2], "F d, Y");
echo "<Table Border=0 cellspacing=1 cellpadding=5 width=475>
<tr><td align=left><font size=4><b>$row[1]</b></font><br>
<i>$poet[0]</i><br>
$date</td></tr>
<tr><td align=center>$poem</td></tr>";
$cdate = convertDate($row[2], "Y");
echo "<tr><td align=right><a href=copyright.php><font size=-1 color=000000>© $cdate $poet[0]</font></a></td></tr>
</table>";
}
}
}else{
echo "match found - $ptoday";
$row = mysql_fetch_row($resultP);
$uid = $row[0];
dbConnect("davidd_RegUsers");
$poetresult = mysql_query("select Name from RegUser where UserID = $uid limit 1");
$poet = mysql_fetch_row($poetresult);
$poem = $row[3];
$poem = str_replace ("\r\n","<br>",$poem);
$date = convertDate($row[2], "F d, Y");
echo "<Table Border=0 cellspacing=1 cellpadding=5 width=475>
<tr><td align=left><font size=4><b>$row[1]</b></font><br>
<i>1. $poet[0]</i><br>
2. $date<br>
3. $row[4]</td></tr>
<tr><td align=center>4. $poem</td></tr>";
$cdate = convertDate($row[2], "Y");
echo "<tr><td align=right><a href=copyright.php><font size=-1 color=000000>© $cdate $poet[0]</font></a></td></tr>
</table>";
# }
}
?>