Jump to content

mouli

Members
  • Posts

    23
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

mouli's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Several of my sites show the current date and time on the page which worked fine until I moved servers from new zealand to the USA. Is still want the sites to show new zealand time which I understand I can do using a time zone shift on the local date/time but I dont think it can account for time changes in New Zealand due to Summer Time (+1 hour) day light saving. I am currently using an include on a new zealand server to send the NZ time stamp to the pages in USA but now we have moved to summertime and the server time has not. I dont have access to the include script so what I'm looking for is a way to get the time stamp from a remote server that accounts for day light saving etc. Any ideas would be most welcome.
  2. Hi I am using a very simple date function to add a number of days to a starting date. Sounds so simple and it is but this function works for any date except 4th november 2007.. The function and a sample useage is as follows: function addDays ($days, $fmt="Y-m-d", $date=NULL) { // Adds days to date or from now // By JM, www.Timehole.com if ($date==NULL) { $t1 = time(); } else{$t1 = strtotime($date); $t2 = $days * 86400; // make days to seconds return date($fmt,($t2+$t1));} } $newdate = addDays(1,'Y-m-d','2007-11-5'); echo $newdate; and it works great for any date use but try adding one day to 2007-11-04 and i get 2007-11-04! Its the only date that I can find that doesn't work and I cant figure out why. I'm sure its a simple answer but its got me very puzzled. Have a go and tell me what you get. Many thanks
  3. Hi No I haven't tested that solution yet. I think it maybe works with php5 only. I'm using php4.4. I'm also not sure how it allows for daylight saving on a server in the remote time zone. Of course it knows its local time including DLS but does a server in USA know what the actual time is in Auckland new zealand. I have access to a server in NZ so I'm working on a simple solution that includes a page on the NZ server that returns the NZ timestamp, then I can easily echo NZ time, date etc. Thanks for yur help mouli
  4. many thanks for that suggestion. I'm not sure that it takes account of daylight savings etc though. These can result in errors of a couple of hours between a country in the northern hemisphere and one in the southern hemisphere.
  5. I've got a page on a new zealand server that, when called generates the unix time stamp on that server. So in effect I have a URL that returns the time stamp. Any idea how I can use this in a page in the USA to allow me to manipulate the timestamp.? How do I call the URL so I can get my spanners on the timestamp? Many thanks mouli
  6. Thanks for that, there is some good food for thought. I'll have play around and post my results. thanks again for your time.
  7. I have several sites that use the date function to write the local date and time in New Zealand to the page. This worked fine until I moved all my sites to a server in another time zone (the USA). I need to continue writing the New Zealand date and time to the page, not local USA time. I'm aware that I can apply a time zone offset to the output of the date function but I'm not sure that this can compensate for local summer time changes etc. The way I'd like to do it is to get the date and time from a server in the original time zone (New Zealand) so it is always accurate. Has anybody got any ideas how I might achieve this or suggest a better way to do this? Many thanks
  8. [!--quoteo(post=389091:date=Jun 29 2006, 03:33 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 29 2006, 03:33 PM) [snapback]389091[/snapback][/div][div class=\'quotemain\'][!--quotec--] As exsplained as above the varable set to $row reads the last varable to $row. $varable_chaned= mysql_fetch_assoc($artistlist); $cell_gallery=$varable_chaned['gallery']; $cell_artist_firstname=ucfirst($varable_chaned['artist_firstname']); $cell_artist_lastname=ucfirst($varable_chaned['artist_lastname']); $cell_position=$varable_chaned['position']; [/quote] Many thanks redarrow and yong. That makes sense. As I understand it the first time read the results the pointer ends up at the end so without reseting the pointer the next time I read the results I will get nothing. Even changing the variable doesn't work. I had to use a new query, then it worked. Thanks again. mouli
  9. I have a page that queries a database, the results being stored in the variable $artistlist. I then use these results to list the artists as follows: [code] <?php do { ?> <tr> <td><?php echo "<p align=\"right\">". $row_artistlist['artist_firstname']." <span class=\"emphasis\">". $row_artistlist['artist_lastname']."</span></p> "; ?> </td> <td> </td> </tr> <tr> <td><img src="spacer.gif" width="1" height="5"></td> <td></td> </tr> <?php } while ($row_artistlist = mysql_fetch_assoc($artistlist)); [/code] This works well. Next I tabulate the results using another function that uses the same query results using: [code] $row = mysql_fetch_assoc($artistlist);             $cell_gallery=$row['gallery'];             $cell_artist_firstname=ucfirst($row['artist_firstname']);             $cell_artist_lastname=ucfirst($row['artist_lastname']);             $cell_position=$row['position']; [/code] But this second use of $artistlist gives empty results ie $cell_gallery etc are null. I can use one or the other but I cant get both useages of $artistlist to work on the page. I hope that makes sense. Why can I not access the results array twice in the same page?? Many thanks mouli
  10. Further experimentation has shown that its not the function thats the problem. If I construct the table outside the function it doen't work either. On the page there is another instance of using the contents of the query result and if I remove that then the table works so my question is .... why can I not use a statement like: [code] $row = mysql_fetch_assoc($artistlist); [/code] more than once in a page. Is it that the statement leaves $artistlist empty?? I might post this question as a new topic as well. Many thanks mouli
  11. [!--quoteo(post=388755:date=Jun 28 2006, 08:03 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 28 2006, 08:03 PM) [snapback]388755[/snapback][/div][div class=\'quotemain\'][!--quotec--] For starters Ive jsut got to say.. this is pretty sloppy coding / use a functions but anyway... How are you checking your query actually returned results? [/quote] The sloppy coding is probably my own adaptation of the original function. I'd be happy to learn how it is sloppy so I can improve on it. The query works because if i assign values from the results array outside the function and echo the variables I can confirm that the array is not empty as follows [code] $row = mysql_fetch_array($artistlist);             $cell_gallery=$row['gallery'];             $cell_artist_firstname=ucfirst($row['artist_firstname']);             $cell_artist_lastname=ucfirst($row['artist_lastname']);             $cell_position=$row['position'];             print "gallery is $cell_gallery";             print "firstname is $cell_artist_firstname";             print "last name is $cell_artist_lastname";             print "position is $cell_position"; [/code] This code works outside the function but not inside the function?? Many thanks mouli
  12. I have a function that displays query results in rows of a given number of cells. It was written by Peter Cole so many thanks to him. The page has a query, the results of which are used by the function but I cant get the function read the array at all. After structuring an sql query to the database I end up with this: [code] $artistlist = mysql_query($query_artistlist, $galleries) or die(mysql_error()); [/code] This generates the results and this works fine outside the function. Then the function looks like this: [code] function display_table(){ //make variables available outside function global $totalRows_artistlist,$artistlist,$thumbrows,$thumbcols,$picvalign; //loop for rows for($r=1;$r<=$thumbrows;$r++){     print '<tr>';     //loop for columns     for($c=1;$c<=$thumbcols;$c++){         print '<td>';             //break out array of values from query row             $row = mysql_fetch_array($artistlist);             $cell_gallery=$row['gallery'];             $cell_artist_firstname=ucfirst($row['artist_firstname']);             $cell_artist_lastname=ucfirst($row['artist_lastname']);             $cell_position=$row['position'];                      print '<table width="100%">';         print '<tr>';         print "<td valign=$picvalign><div align=\"center\"><a href=\"intro_artists.php?gallery=$cell_gallery\"><img src=\"getdata.php?image=thumb&position=$cell_position\" border=\"0\" ></a></div>                           </td>";         print '</tr>';         print '<tr>';         print '<td valign="top"><div align="center">                               <a href="intro_artists.php?gallery=$cell_gallery"><p> $cell_artist_firstname $cell_artist_lastname</p></a>                             </div>                           </td>';         print '</tr>';         print '<tr>';         print '<td valign="top"><img src="images/spacer.gif" width="1"  height="<?php echo SPACERHEIGHT ?>"></td>';         print '</tr>';         print '</table>';         print '</td>';         }     print '</tr>';     } } [/code] It draws the table etc but has no data so I'm guessing that the problem lies with the way that I'm handling the results array $artistlist. Testing the contents of the variables $cell_gallery etc convinces me that it is failing to assign the array values to the variables below the comment "//break out array of values from query row". Any ideas much appreciated. Thanks for your time. mouli
  13. Yup it worked a treat. I only had to remove the $submit variable and it worked beautifully. Many thanks
  14. [!--quoteo(post=385514:date=Jun 19 2006, 03:55 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 19 2006, 03:55 PM) [snapback]385514[/snapback][/div][div class=\'quotemain\'][!--quotec--] there's the easy way and then there's the hard way: the easy way: if your form variable names match your column names, you can run a loop to build your query like so: simplified: [code] $sql = "update tablename set "; foreach($_POST as $key => $val) {    if (isset($val) && trim($val) !== '') {       $sql.= $key . "='" . $val . "',";    } } $sql = substr_replace($sql,"",-1); //get rid of the last comma $sql.= " where id = '$id'"; //assuming you are updating based on id mysql_query($sql); [/code] the hard way: doing the exact same thing except for with an if statement for each and every value, named individually. [/quote] Mmmm, this looks good. Variables match columns so I'll give it a go and get back to you. Many many thanks :)
  15. [!--quoteo(post=385498:date=Jun 19 2006, 02:01 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 19 2006, 02:01 PM) [snapback]385498[/snapback][/div][div class=\'quotemain\'][!--quotec--] Make PHP check whether the variables are null; if they are, don't do the query. [/quote] Thanks for that. What I cant figure out is how I use php to construct the query so it only updates fields for which the posted variable is not null. There are about 10 fields in the form, the user simply enters values in those fields that need updating, leaving the rest empty, so the query has to only update fields that are not null in the posted variables. Its the dynamic construction of the query that has got me stumped. Many thanks for your help. mouli
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.