homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

getdate vs. nowdate?

 5:04 am on Aug 26, 2012 (gmt 0)

Another question that will unfortunately reveal my need for serious time spent on tutorials in php...


require( '../sinai_admin/includes/configure.php' );


mysql_select_db( DB_DATABASE );

$query = "select *,DATE_FORMAT(CURDATE(),'%M %D, %Y') as nowdate from sermon_title where date= CURDATE();";

$result = mysql_query( $query, $dbh );

$sermon_title = mysql_fetch_array( $result );

<p><?php echo $sermon_title['rabbi_image'];?></p>
<p><?php echo $sermon_title['presenter'];?></p>
<p><?php echo $sermon_title['sermon_title'];?></p>

displays perfectly; however, what I need it to do is change to next week's information at midnight 'tonight' (Shabbat is Saturday evening, so if it changes to the following week at midnight on Saturday, everyone will be happy)

I tried using:
$query = "select *,DATE_FORMAT(CURDATE(),'%M %D, %Y') as nowdate from sermon_title where ((TO_DAYS(endate) - TO_DAYS(CURDATE())) >=0) and ((TO_DAYS(endate) - TO_DAYS(CURDATE())) < 7) and DATE_FORMAT(endate,'%w') = 6";

in place of the current; borrowed from another working script but it produced error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sbloom02/public_html/_testSermonTitle.php on line 17

Any suggestions greatly appreciated... this will eventually save me a lot of stress when I'm not at the computer on a Saturday evening!

Thanks in advance,



 10:35 pm on Aug 26, 2012 (gmt 0)

welcome to WebmasterWorld, IndulgenceDesign!

if (!$result) {
die('Invalid query: ' . mysql_error());

i would also print the values of the arguments you are supplying to mysql_fetch_array.
(i.e. make sure the db handle and query string are valid.)


 10:08 pm on Aug 27, 2012 (gmt 0)

and again, I feel like a nuisance... adding this to the code just produced the error that the scripting told it to show. This one isn't AS pressing as the directory ordering as it's more for me than for them (to save me work but they'll see the same thing).

Thanks either way for all of your help,


 12:28 am on Aug 28, 2012 (gmt 0)

did you print out $query and $dbh to verify if they were valid values?

the directory ordering

i'm not sure what you are referring to - there is no mention of directories in your OP and no ORDER BY clause in your SQL query...


 7:24 am on Aug 28, 2012 (gmt 0)

No - what I meant is because I actually have 2 posts going right now, the other one is more important.

as for $query and $dbh, I copied the script in the OP from another script that pulls from a similar database (to show the current parashat, which begins showing at the right time, the week prior to that actual Saturday) and modified it just slightly to point to the new database I created for the sermon title information.

Effectively, I'm not sure what I did wrong or right at this point

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved