homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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?
php
IndulgenceDesign




msg:4488377
 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...

<?php

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



$dbh = mysql_connect( DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD );

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,
Sherry

 

phranque




msg:4488511
 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.)

IndulgenceDesign




msg:4488855
 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,
Sherry

phranque




msg:4488909
 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...

IndulgenceDesign




msg:4488992
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved