Jump to content

mouli

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by mouli

  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
  16. Hi I have a form that uploads images to a mysql database and it works great. If it detects a duplicate entry based on the unique key it then uses an UPDATE query to update the record. This works as well except that you must enter values in all the form fields or it obviously updates those field with null values. I'd like to be able to only update fields for which the posted variable from the form is not null so that it leaves fields unchanged where the posted variable is null. Many thanks mouli
  17. Hi I have a small script that sends email from a form using the mail function. The recipient is using Outlook. If I set the content-type header to: text/plain; charset=us-ascii the email gets through but obviously as plain unformatted text. However if I set the content-type header to text/html; charset= iso-8859-1 they receive a blank email with the original content attached as a .dat file Any ideas would be much appreciated as they'd like the emails received with active links etc. Many thanks mouli
  18. I have a page which includes 4 images pulled from a mysql database. One is large, the other three are thumbnails. When the visitor clicks on a thumnail I'd like the large image to change to the thumnail image, the thumbnail being replaced by the previously large image. (Does that make sense?) I can set up a swop image behaviour using javascript but because the image source is a php script I need to reload the page when the viewer clicks on the thumnail for the image to appear. This is the part that stumps me? Any ideas much appreciated. Many thanks mouli
  19. [!--quoteo(post=353422:date=Mar 10 2006, 11:54 AM:name=RobBob)--][div class=\'quotetop\']QUOTE(RobBob @ Mar 10 2006, 11:54 AM) [snapback]353422[/snapback][/div][div class=\'quotemain\'][!--quotec--] Can't you just do a: INSERT ....... ON DUPLICATE KEY UPDATE ....... ??? check out [a href=\"http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/ins...-duplicate.html[/a] for more syntax info on how that might work for you.. --RobBob [/quote] Yup I reckon that might do the job and I learn something new as well. many thanks RobBob mouli
  20. [!--quoteo(post=353397:date=Mar 10 2006, 10:24 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 10 2006, 10:24 AM) [snapback]353397[/snapback][/div][div class=\'quotemain\'][!--quotec--] IF I say your request back this way, is it still true? You want to update the links to some pictures if they already exist, or add them if they don't... Is that right? [/quote] Nearly true... I want to upload images to a database with a code number for the record. When I upload an image I specify the code number of the record I want the image added to. For instance I want to upload 45.jpg to field 'webpic1' in record with 'id' = L203 If 'id'= L203 exists then I want it to simply update 'webpic1' with 45.jpg If 'id'=L203 doesn't exist then I want it to insert a new record with 'id'=L203 with 'webpic1'=45.jpg I can do it by querying the database for the existance of 'id'=L203, then using an IF statement to decide whether to insert or update but I was thinking there must be a quicker, slicker way to do it. Any ideas much appreciated. mouli
  21. Hi I'm reposting this because I think it got buried and I didn't get a useful reply so I thought I'd try again. I have a page that uploads images to a database. Each record has an id number and 4 images. When I upload an image I'd like to check whether the id already exists, in which case I simply update that record with the new image, or if the id doesn't exist i would insert a new record. I figure I can do this by querying the database for the id then test the results for the existance of the id then use another query to insert or update the record but I just wondered whether there's a smoother way to do it such that there is only one query that inserts or updates depending on the existance in the database of the id number. Many thanks
  22. [!--quoteo(post=352997:date=Mar 9 2006, 10:19 AM:name=txmedic03)--][div class=\'quotetop\']QUOTE(txmedic03 @ Mar 9 2006, 10:19 AM) [snapback]352997[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well, my number one question is, why do you have four images per row? It would make things simpler to use seperate rows for each image unless there is a really good reason for grouping those 4 images. Even then you could assign some kind of grouping tag. I only say this because it may make things simpler for you. I don't know the purpose for doing what you did, so I can't say you did something good/bad here, but I am curious as to the reasoning. The next thing I would like to know is why you are defining the id outside of the mysql database? I just wonder why you do not let mysql auto_increment the value of id where id is the primary unique identifier. You could do something to where if image is being re-uploaded it passes a variable to the $_POST or $_GET with the id number of the image you want to re-upload/replace then if there was no id specified it creates a new record. You could use other error correcting like if your queries fail alert the user or take some other action, but this is just what seems to be simplest to me. Again, I don't know exactly what you are trying to accomplish and what you want to be able to do with the images once you have them in the database, so I am just passing along suggestions. I hope it helps. [/quote] Hi James The website is selling items. Each item has a stock code (the id mentioned above) and has 4 images of the item so having them all in one record with the unique product id makes sense to me. The user uploads an image and specifies the product id. If the product id exists then it only needs to update the images for that product but if id doesn't exist then it inserts a new record with the new image. What I want to do is check for the existance of the id so i can then update or insert as required. many thanks mouli
  23. Hi I have a page that uploads images to a database. Each record has an id number and 4 images. When I upload an image I'd like to check whether the id already exists, in which case I simply update that record with the new image, or if the id doesn't exist i would insert a new record. I figure I can do this by querying the database for the id then test the results for the existance of the id then use another query to insert or update the record but I just wondered whether there's a smoother way to do it such that there is only one query that inserts or updates depending on the existance in the database of the id number. Many thanks
×
×
  • 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.