otixz Posted April 25, 2008 Share Posted April 25, 2008 Hi I have a string 22/4/2008 Im wondering how can I make it 21/4/2008 Note: this is a string and not a date... plz help! Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/ Share on other sites More sharing options...
TEENFRONT Posted April 25, 2008 Share Posted April 25, 2008 mktime() Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526944 Share on other sites More sharing options...
otixz Posted April 25, 2008 Author Share Posted April 25, 2008 Hi... can you be more specific...sorry Iam new to PHP Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526948 Share on other sites More sharing options...
TEENFRONT Posted April 25, 2008 Share Posted April 25, 2008 $yesterday = date("d/m/Y",mktime(0,0,0,date("m") ,date("d")-1,date("Y"))); Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526950 Share on other sites More sharing options...
TEENFRONT Posted April 25, 2008 Share Posted April 25, 2008 hmmm actually you said it wasnt a date... hmmm... my example probly not what your after Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526953 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2008 Share Posted April 25, 2008 You can do something like this: <?php $str = '22/4/2008'; list($d,$m,$y) = explode('/',$str) $new_str = date('j/n/Y',strtotime('-1 day ' . $y. '-' . $m . '-' . $d)); echo $new_str; ?> Ken Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526954 Share on other sites More sharing options...
otixz Posted April 25, 2008 Author Share Posted April 25, 2008 wow! that resolved my prob! Anyway do any know what is the meaning of an error: Warning: mysql_query() [function.mysql-query]: Unable to save result set in D:\xampp\htdocs\ereport\add_inquiry.php on line 144 and Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\ereport\add_inquiry.php on line 146 I have this two errors but my queries are doing well and they are giving the results that I want. What does it mean? Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526986 Share on other sites More sharing options...
otixz Posted April 25, 2008 Author Share Posted April 25, 2008 Hi I was able to resolve the other prob my concern is the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\ereport\add_inquiry.php on line 146 What does it mean? My code is: $qry = mysql_query("select * from tblcourses"); $row = mysql_num_rows($qry); if($row == 0) { echo "no record";?> <?php } else { while($b = mysql_fetch_array($qry)) { $course = $b['coursename']; $initial = $b['initial']; $title = $b['TITLE']; $q="select total , (select total from tblinquiries where inq_date='$date' and course='$course') as Total2 from tblinquiries where inq_date='$new_str' and course='$course' "; $query = mysql_query($q); $rows = mysql_num_rows($query); ?> <tr> <?php if($title == "Y") { $course = $b['coursename']; ?> <td bgcolor="#AFEEEE" width="20%"><b><?echo $course;?></td> <td bgcolor="#AFEEEE"></td> <td bgcolor="#AFEEEE" width="5%"></td> <?php }else { ?> <td width="20%"><?echo $course;?></td> <?php //for PReviews date if($rows == "0") { ?> <td><center>--</td> <td width="5%"><input type="text" size="15" name='<?php echo $course;?>' value="<?php echo $a['total2'];?>"><center></td> <?php } else { while($a= mysql_fetch_array($query)) { ?> <td><center><?php echo $a['total'];?></td> <td><center><?php echo $a['Total2'];?></td> <?php } } ?> <?php } ?> </tr> <?php } } Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526988 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2008 Share Posted April 25, 2008 When you get that message, it means that the previous mysql function did not work correctly, usually the query had a syntax error in it. Here's how I usually code my mysql queries: <?php $q = "some select statement" $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); ?> Using this, your script will tell you the query where the problem occurred and the mysql_error and then stop. Using that you can debug the problem. Ken Link to comment https://forums.phpfreaks.com/topic/102875-how-can-i-make-a-date-of-2242008-into-2142008-minus-one-day/#findComment-526998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.